0

I have one input file, and I want to extract the first minute and the second minute, and then recombine them so the first minute is on the top, and the second minute is on the bottom, playing simultaneously.

I cobbled this together, but for some reason, the upper clip freezes after a few seconds, while the bottom clip continues as expected. The input file has the resolution 640x352.

ffmpeg -i input.avi -filter_complex "
    nullsrc=size=640x704:duration=60 [base];
    [0:v] trim=0:60, setpts=PTS-STARTPTS [v0];
    [0:v] trim=60:120, setpts=PTS-STARTPTS [v1];
    [base][v0] overlay=x=0:y=0 [t1];
    [t1][v1] overlay=x=0:y=352 [out]" \
-map "[out]" output.mkv

I suspect this is a problem internally in ffmpeg, and I have to first extract the two clips into separate input files.

1

The parallel processing is happening slow enough that FFmpeg is flushing frames in buffer for the first trimmed clip. You can use the fifo filter to avoid that. Also, you can use vstack and skip the nullsrc/overlay route.

ffmpeg -i input.avi -filter_complex "
    [0:v] trim=0:60, setpts=PTS-STARTPTS, fifo [v0];
    [0:v] trim=60:120, setpts=PTS-STARTPTS [v1];
    [v0][v1] vstack [out]" \
-map "[out]" output.mkv

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.