0

I'm concatenating .ts chunks intended for an HLS player into a single .mp4 video. Unlike in other questions 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).

enter image description here

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) out of a freeware cartoon to demonstrate the problem. The 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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.