[FFmpeg-user] Pasting together different parts of a downloaded video

Rob Hallam ffmpeg at roberthallam.com
Wed May 4 18:08:13 EEST 2022

On Wed, 4 May 2022 at 08:27, Bo Berglund <bo.berglund at gmail.com> wrote:
> I have a script that downloads a video live stream into a mp4 file while on the
> fly changing the format, basically re-encoding the video.
> It uses this basic download command:
> CMD="ffmpeg -hide_banner ${MODE} -i \"${M3U8URL}\" -vf scale=w=-4:h=480 -c:v
> libx264 -preset fast -crf 26 -c:a copy -t $DIFF $TARGETFILE"
> [...]
> I had expected the concatenated file to be a combination of the two sections
> with no real problems but it turns out that the audio is completely out of sync
> in the output. Looks like by a *LOT*.
> [...]
> Grateful for any suggestions on what I can do!

Without the console output my suggestion would be: re-encode the audio
portion as well in your first step. (-c:a aac or similar)

I've run into similar desync issues when concat-ing half reencoded
segments, so now if I'm re-encoding video I re-encode audio too.


More information about the ffmpeg-user mailing list