[FFmpeg-user] concat a/v desync (only in MPC-HC)

basinilya at gmail.com basinilya at gmail.com
Tue Feb 2 21:09:11 EET 2021


Hi List. I asked this on stackexchange, but never got an answer. ( https://video.stackexchange.com/q/33173/11453 )

I'm concatenating .ts chunks intended for an HLS player into a single .mp4 video. These chunks possess same stream properties, however, some chunks have audio stream shorter than video stream and in that case the resulting clip has audio artifacts when playing in Media Player Classic (MPC-HC).



Workaround: demux video and audio streams into separate .m4a and .m4v files, concatenate them and then mux again.

Goal: create single clips from .ts chunks *without intermediate files*

Please help me find proper ffmpeg flags.

I have created sample chunks (this repo) <https://github.com/basinilya/ffconcat-question> out of a freeware cartoon to demonstrate the problem. he chunk |516-x.ts| has audio stream 50ms shorter than video and in |517-x.ts| it's longer.

Download: https://github.com/basinilya/ffconcat-question/archive/master.zip <https://github.com/basinilya/ffconcat-question/archive/master.zip>

    ffmpeg -y -i playlist-x.ffconcat -c copy result.mp4

The created `result.mp4` is played fine in `ffplay` or Windows Media Player, but there's a short silence in MPC-HC in the second half of the clip.

Workaround script:

    ffmpeg -y -i 516-x.ts -an -c:v copy 516-x.m4v
    ffmpeg -y -i 516-x.ts -vn -c:a copy 516-x.m4a
   
    ffmpeg -y -i 517-x.ts -an -c:v copy 517-x.m4v
    ffmpeg -y -i 517-x.ts -vn -c:a copy 517-x.m4a
   
    ffmpeg -y -i playlist-x-a.ffconcat -c copy result.m4a
   
    ffmpeg -y -i playlist-x-v.ffconcat -c copy result.m4v
   
    ffmpeg -y -i result.m4v -i result.m4a -c copy result-good.mp4



More information about the ffmpeg-user mailing list