Capture and encode problem
Hello, I am trying to do real-time capturing and encoding of the TV signal from my cable. I am using tvtime for capturing and ffmpeg for encoding and muxing the output. Below is the captured output of my program. The audio has some noise in there, the video frame flow has some jittering, and audio and video stream are out of sync. <output file> http://www.yousendit.com/download/M3BuUWVzQ1BFd2MwTVE9PQ<javascript:ol('http://www.yousendit.com/download/M3BuUWVzQ1BFd2MwTVE9PQ');> My code looks roughly as followed: 1. Initialization of ffmpeg video and audio stream 2. Start the capturing thread: while (isCapturing) { if (audio_st) { audio_pts = (double)audio_st->pts.val * video_st->time_base.num / \ audio_st->time_base.den; } else { audio_pts = 0; } if (video_st) { video_pts = (double)video_st->pts.val * video_st->time_base.num / \ video_st->time_base.den; } else { video_pts = 0; } if (!video_st || (video_st && audio_st && audio_pts < video_pts)) { write_audio_frame(); } else { write_video_frame(); } } Inside write_video_frame(), I retrieve a video frame from the video buffer, encode, and use av_write_frame to write it to the output file. Inside write_audio_frame(), I call snd_pcm_readi to read an audio frame, encode, and use av_write_frame to write it to the output file. Anything might have gone wrong? Thanks, Phuoc
participants (1)
-
pdo.cloud@gmail.com