Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to resend the received frame #2

Open
shahidmuneer-skku opened this issue Oct 17, 2024 · 0 comments
Open

Unable to resend the received frame #2

shahidmuneer-skku opened this issue Oct 17, 2024 · 0 comments

Comments

@shahidmuneer-skku
Copy link

Hi,

I am trying to send the received from in onFrame function:

def on_frame(self, channel_id, remote_uid, frame:VideoFrame):
    logger.info(f"on_frame, channel_id={channel_id}, remote_uid={remote_uid}, width={frame.width}, height={frame.height}, y_stride={frame.y_stride}, u_stride={frame.u_stride}, v_stride={frame.v_stride}, len_y={len(frame.y_buffer)}, len_u={len(frame.u_buffer)}, len_v={len(frame.v_buffer)}")
    
    if self._save_to_disk:
        file_path = os.path.join(log_folder, channel_id + "_" + remote_uid + '.yuv')
        y_size = frame.y_stride * frame.height
        uv_size = (frame.u_stride * frame.height // 2)         
        # logger.info(f"on_frame, file_path={file_path}, y_size={y_size}, uv_size={uv_size}, len_y={len(frame.y_buffer)}, len_u={len(frame.u_buffer)}, len_v={len(frame.v_buffer)}")
        # self.push_yuv_frame()
        with open(file_path, 'ab') as f:
            f.write(frame.y_buffer[:y_size])
            f.write(frame.u_buffer[:uv_size])
            f.write(frame.v_buffer[:uv_size])
    # if self.video_frame_sender!=None:
        # logger.info(f"on_frame, file_path={file_path}, y_size={y_size}, uv_size={uv_size}, len_y={len(frame.y_buffer)}, len_u={len(frame.u_buffer)}, len_v={len(frame.v_buffer)}")
        # exit()
        # if self.loop:
    self.push_yuv_frame(frame, self.video_frame_sender, "Frame Metadata")
    # await asyncio.create_task(self.push_yuv_frame(frame, self.video_frame_sender, "hello metadata"))

    return 1

def on_user_video_track_subscribed(self, agora_local_user, user_id, info, agora_remote_video_track):
    logger.info(f"on_user_video_track_subscribed, agora_local_user={agora_local_user}, user_id={user_id}, info={info}, agora_remote_video_track={agora_remote_video_track}")
    return 0
def push_yuv_frame(self,frame: VideoFrame, video_sender: VideoFrameSender, metadata: str):
    yuv_buffer = bytearray(frame.y_buffer) + bytearray(frame.u_buffer) + bytearray(frame.v_buffer)

    external_frame = ExternalVideoFrame()
    external_frame.buffer = yuv_buffer
    external_frame.type = 1  # Assuming a certain type, modify as necessary
    external_frame.format = 1  # Assuming YUV format, modify as necessary
    external_frame.stride = frame.y_stride
    external_frame.height = frame.height
    external_frame.timestamp = 0  # Modify if timestamp handling is needed
    external_frame.metadata = metadata

    ret = video_sender.send_video_frame(external_frame)
    logger.info(f"Frame sent with status {ret}")
    exit(0)

In video frame observer. I am not sure whether you support this or not? Where I can do that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant