1

I use ffmpeg because I want to do video editing without re-encoding. I only know the bare bones options for this though:

ffmpeg -i input.mp4 -ss 00:00:30 -to 00:05:00 -acodec copy -vcodec copy output.mp4

The audio, for the output of the above command, starts at 30 seconds, however this video only starts at the next i-frame after the 30 second mark, sometimes this might even be around 33 seconds.

Using -ss as input option together with -c:v copy might not be accurate since ffmpeg is forced to only use/split on i-frames. Though it will—if possible—adjust the start time of the stream to a negative value to compensate for that. Basically, if you specify "second 157" and there is no key frame until second 159, it will include two seconds of audio (with no video) at the start, then will start from the first key frame. So be careful when splitting and doing codec copy. https://trac.ffmpeg.org/wiki/Seeking

This is quite annoying, to have audio playing and be waiting for the video.

Is there a way to seek the audio to the same timestamp as the first video time?

3
  • Did you ever find a solution to this issue? I'm encountering the same problem.
    – ACPrice
    Sep 28, 2022 at 22:29
  • @ACPrice no perhaps you should ask on a different stackexchange site Sep 28, 2022 at 22:35
  • @ACPrice I figured out the answer Apr 20 at 6:41

1 Answer 1

0

The answer is contained in this SE answer https://unix.stackexchange.com/a/388148/551103

You use two -ss. Before the input: -ss ${starting_timestamp_minus_10s}. After the input: -ss 10.

i.e.

ffmpeg -ss ${starting_timestamp_minus_10s} -i input_file -ss 10 output_file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.