4

I want to cut the audio from frame 2928 to frame 5177 of a 23.976 fps blu-ray-movie.

I have read through some articles but don't see how to do that accurate.

Cutting videos at exact frames with ffmpeg select filter

https://video.stackexchange.com/questions/25291/how-to-precisely-trim-video-with-ffmpeg-ss-and-t-are-off-by-more-than-a-half

How to cut at exact frames using ffmpeg?

From my point of view I have to extract the audio first:

ffmpeg.exe -i movie.mkv -map 0:1 -c:a flac -sample_fmt:a s16 audio.flac

Check if audio and video starts at the same time:

ffprobe -show_entries stream=codec_type,start_time -v 0 -of compact=p=1:nk=0 movie.mkv stream|codec_type=video|start_time=0.000000 stream|codec_type=audio|start_time=0.000000

And cut the audio with frame/time-calculation:

ffmpeg.exe -i audio.flac -ss (2928/(24000/1001)) -to (5177/(24000/1001)) -codec flac audio_cut.flac ffmpeg.exe -i audio.flac -ss 122.122 -to 215.9240417 -codec flac audio_cut.flac

A frame is a moment in time for video but a time slot for audio. So I have to include frame 2928 and frame 5177. But I'm not sure, where I have to start and stop the cutting.

From ffmpeg-documentation:

-ss: When used as an output option [...] decodes but discards input until the timestamps reach position.

-to: Stop writing the output or reading the input at position.

So when I want to extract audio for first frame I have to cut like this:

ffmpeg.exe -i audio.flac -ss (0/(24000/1001)) -to (1/(24000/1001)) -codec flac audio_cut.flac

With that in mind I have to cut for 2928 to 5177 like this:

ffmpeg.exe -i audio.flac -ss (2927/(24000/1001)) -to (5177/(24000/1001)) -codec flac audio_cut.flac

Is that correct?

FLX
  • 191

1 Answers1

2

ffmpeg starts to count at 0.

ffmpeg.exe -i audio.flac -ss (2927/(24000/1001)) -to (5177/(24000/1001)) -codec flac audio_cut.flac

--> 2927 - 5176

ffmpeg.exe -i audio.flac -ss (2928/(24000/1001)) -to (5178/(24000/1001)) -codec flac audio_cut.flac

--> 2928 - 5177

I need to cut until 5178 to get the audio from frame 5177.

FLX
  • 191