Muxer not syncing audio and video - Printable Version +- Lindeni Forum (http://forum.lindeni.org) +-- Forum: Lindenis V5 (http://forum.lindeni.org/forumdisplay.php?fid=5) +--- Forum: General Discussion on Lindenis V5 (http://forum.lindeni.org/forumdisplay.php?fid=6) +--- Thread: Muxer not syncing audio and video (/showthread.php?tid=491) |
Muxer not syncing audio and video - tylerjbrooks - 12-02-2018 I have the output of a video encoder and the output of an audio encoder bound to a muxer group and channel. The video is 1080p@30fps compressed to h264. The audio is 16bit, 48K audio compressed with AAC. I have asked the muxer to write MPEG-TS files. I am manually gathering the video (AW_MPI_ISE_GetData) and the audio (AW_MPI_AI_GetFrame) in my own threads and sending them into the encoders in the normal way (AW_MPI_VENC_SendFrame & AW_MPI_AENC_SendFrame). The audio in the resulting MPEG-TS files seems to be 'behind' the video by several hundred milliseconds. Voices, for instance, don't sync with the lip movements in the video. How can I fix this? I noticed that the timestamp on the audio data (AUDIO_FRAME_S mTimeStamp) is set to zero when I retrieve it with AW_MPI_AI_GetFrame. The video PTS (VIDEO_FRAME_S mpts) does seem to be set correctly. My thought was that I needed to sync the video and audio timestamps (by using clock()) so the muxer can sync them up. However, when I set mTimeStamp of the audio frames to something non-zero, I get the follwing error message when I call AW_MPI_AENC_SendFrame: E1202 19:23:16.867974 1173 AudioEnc_Component.c:971] <AudioEncEmptyThisBuffer> fatal error! RecRender should not call this function! The error return from AS_MPI_AENC_SendFrame is '-1'. Am I supposed to set the audio timestamp? If not, how can I get the audio and video to sync up? |