Skip to content

Instantly share code, notes, and snippets.

@tamsky
Last active February 5, 2019 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamsky/889465ac334d79a3005daecee868b1ad to your computer and use it in GitHub Desktop.
Save tamsky/889465ac334d79a3005daecee868b1ad to your computer and use it in GitHub Desktop.
notes on slowing down video+audio using ffmpeg

I noticed that simply using

i=0.7 && ffmpeg -i delay1.mp4 -filter:a "atempo=$i" -vf "setpts=(PTS-STARTPTS)/$i" output-$i.mp4

always had a significant a/v sync issue.

I tried jogging the source first:

ffmpeg -i input.mp4 -itsoffset 0.3 -i input.mp4 -vcodec copy -acodec copy -map 0:1 -map 1:0 delay1.mp4

and then slowing down the resulting de-sync'ed video(delay1.mp4), but it still had sync issues.

I wound up discovering, when I converted just a clip (eg. -t 30) they retained the itsoffset I was trying for, and remained correctly sync'ed.

So, in the end I used the (0.3) desync-ed input (delay1.mp4) with a -t <duration> argument:

ffmpeg -ss 0:0 -i delay1.mp4 -filter:a "atempo=$i" -vf "setpts=(PTS-STARTPTS)/$i" -t <DURATION> output-$i.mp4 && open output-$i.mp4

DURATION varies inversely with the value of $i -- trial and error was used to find an approximately correct duration for each rate.

Resources used:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment