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

Sam Logan shapableline at gmail.com
Mon Jun 12 08:15:26 EEST 2023


But -aselect and -atrim select by audio sample numbers or timestamp, rather
than by video frame numbers, so how do I determine what arguments to pass
to -aselect and -atrim?

Could someone please show me a command line with exactly what arguments to
pass to -aselect or -atrim, based on my original post of wanting to clip
video frames 1069 to 1263?

Thanks.

On Wed, May 24, 2023 at 1:03 AM Michael Koch <astroelectronic at t-online.de>
wrote:

> 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
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-user mailing list