[FFmpeg-user] When clipping by exact frame, how to get correct audio to match that clip?

Michael Koch astroelectronic at t-online.de
Wed May 24 08:02:57 EEST 2023


Am 24.05.2023 um 05:37 schrieb Sam Logan:
> I am trying to extract a clip of a video by the exact frames.
>
> I tried
>
> ffmpeg -i "InputFile.mp4" -vf select="between(n\, 1069\,
> 1263),setpts=PTS-STARTPTS" "OutputAttempt1.mp4"
>
> and
>
> ffmpeg -i "InputFile.mp4" -vf
> trim=start_frame=1069:end_frame=1264,setpts=PTS-STARTPTS
> "OutputAttempt2.mp4"
>
> (In the second command, the ending frame is 1 greater than in the first
> command
> because the documentation indicates "end_frame" is the first frame that
> gets
> dropped, and I want to include frame 1263.)
>
> The video in the output files is correct and covers the frames that I want.
> The
> problem is that in both my attempts, the ENTIRE audio track is copied over
> to
> the output file, when I only want the portion of the audio track that plays
> at
> the same time (in the input video) as the video frames that I extracted for
> the
> output video. How do I get ONLY that portion of the audio into the output?

Have a look at the commands -af, aselect and atrim.

Michael



More information about the ffmpeg-user mailing list