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

Bo Berglund bo.berglund at gmail.com
Thu May 5 01:22:44 EEST 2022


On Wed, 4 May 2022 16:08:13 +0100, Rob Hallam <ffmpeg at roberthallam.com> wrote:

>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.
>
>HTH,
>Rob

THANKS!

That might be a way out, but exactly what should I put in the -c:a xxx part?
If I check the format of an output file from the download script I see this:

$ ffprobe -hide_banner 2022-05-04_15_video.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 01:04:00.01, start: 0.000000, bitrate: 527 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 852x480,
473 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (HE-AAC) (mp4a / 0x6134706D), 48000 Hz, stereo,
fltp, 48 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

So it seems like your suggested aac should be the correct choice here, I guess.

I have changed the script in this way, now I just have to wait for another
interruptionm so I can test the concat on the split recording.
I will report back when/if that happens again.


-- 
Bo Berglund
Developer in Sweden



More information about the ffmpeg-user mailing list