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

Carl Zwanzig cpz at tuunq.com
Mon Jul 17 08:43:11 EEST 2023


On 7/15/2023 11:04 PM, Sam Logan wrote:
> ffmpeg -i "InputFile.mp4" -vf "select='between(n, 1069, 1263)',
> setpts=PTS-STARTPTS" -af "aselect='between(t, 1069, 1263)',
> asetpts=N/SR/TB" "OutputAttempt.mp4"
> 
> but this just results in an output file that has no audio track at all.

For a start 't' is not a frame number - "The PTS of the filtered frame, 
expressed in seconds."

Example from the doc-
Select only frames contained in the 10-20 time interval:
    select=between(t\,10\,20)
(and you probably need to escape the commas)

Looks like you need 'n' - "The (sequential) number of the filtered frame, 
starting from 0." (See example in the doc 
https://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect


> What can I do to fix this?

Please check the doc on the select filter, and post the complete and 
unedited output.

Later,

z!


More information about the ffmpeg-user mailing list