Cole
Cole

Reputation: 116

FFMPEG hold multiple frames and use as a movie

I have a video that I'm trying to create jump shots from. For example I want the output of my command to show frame 5 of the original clip for 30 frames, and frame 25 of the OG clip to show for 30 frames.

assuming the OG clip is 30 FPS

ffmpeg -t 1 -i og_clip.mp4 -filter_complex "
    [0]select=eq(n\,5)[H1];[0][H1]overlay[O1];
    [0]select=eq(n\,25)[H2];[0][H2]overlay[O2];
    [O1][O2]concat=n=2[Merge]" -map "[Merge]" out.mp4

The above doesnt work right.

What I've been doing up until now has been a two part command:

ffmpeg -i og_clip.mp4 -vf "select=eq(n\,5)" -vframes 1 -y out_0.png
ffmpeg -i og_clip.mp4 -vf "select=eq(n\,25)" -vframes 1 -y out_1.png
ffmpeg -t 1 -i og_clip.mp4 -i out_0.png -i out_1.png -filter_complex "
    [0][1]overlay[H1];[0][2]overlay[H2];
    [H1][H2]concat=n=2[Merge]" -map "[Merge]" out.mp4

Which has been working for me. The only problem is that the process of converting to a png first for each frame I want to use, takes too long. I'm trying to condense it all into one command. I figure that the encoding of the png is what takes so long.

Any help would be much appreciated!

Upvotes: 0

Views: 1352

Answers (1)

Gyan
Gyan

Reputation: 92928

Use

ffmpeg -t 1 -i og_clip.mp4 -filter_complex "[0]select=eq(n\,5)+eq(n\,25),settb=1/30,setpts=N*30,fps=30" -an out.mp4

After selecting the frames, the timestamps are adjusted to be 30 frames apart. Then the fps filter will plug those gaps with cloned frames.

Upvotes: 1

Related Questions