Avidemux Forum

Avidemux => Unix-Like (Linux/Bsd/...) => Topic started by: Kibu on June 17, 2018, 09:12:57 AM

Title: Audio track out sync after editing MP4
Post by: Kibu on June 17, 2018, 09:12:57 AM
hi,

I'm using ffmpeg to concat and transform ts videos into mp4. Also I let move the metadata (title and so on) to the beginning of the mp4 video for better handling with dlna clients. This works OK so far.
When I now edit the mp4 cutting off trailing and leading parts and save it as mp4, audio is behind video track for about 1 second. This does not happen if I dont't move metadata to the beginning of the video. For target format I'm using copy for audio, video and MP4 muxer with default settings.
I'm using avidemux  2.7.1 on ubuntu 18.04.
Any ideas ?
TIA
Kibu
Title: Re: Audio track out sync after editing MP4
Post by: eumagga0x2a on June 17, 2018, 01:00:28 PM
Please provide a sample without moving metadata and the same source with metadata moved to the start of the file. Meanwhile, you should be able to compensate using a negative audio shift of 1000 ms.
Title: Re: Audio track out sync after editing MP4
Post by: Kibu on June 24, 2018, 11:26:36 AM
I have to correct my last posting. I made a new test without generating/moving metadata and the effect is the same. Don't know if it's a good idea to upload dozens of MB video data here. But you can reproduce it. Take a ts file (generated by vdr recording tool), transform it with
ffmpeg -i video.ts c:a copy -c:v copy [-copyts -movflags -faststart -metadata title="Some Title"] -f mp4 -y video.mp4
The attributes in brackets generate the metadata and move them to the start.
When playing the result with avidemux, you can see the video / audio time offset. When I first transform and cut the ts file with avidemux into mp4 and then madd/move the moov atom part to the start with ffmpeg, video and audo have no offset.

Kibu
Title: Re: Audio track out sync after editing MP4
Post by: eumagga0x2a on June 27, 2018, 09:21:24 PM
I can confirm the issue, but I am not sure that Avidemux is at fault here. parseElst (https://github.com/mean00/avidemux2/blob/master/avidemux_plugins/ADM_demuxers/Mp4/ADM_mp4Analyzer.cpp#L403) reports that ffmpeg (here: version 4.0.1) specifies a huge audio delay. This happens only when muxing to MP4, a ffmpeg-generated MKV doesn't exhibit the problem.