15

I'm using ffmpeg in flash builder (Action script 3) to convert a video to a time lapse of the video. I've worked out how to use setpts to do this, but the resulting output file is the same length as the input (with just the last frame displayed after the time lapse), I want the duration to be changed based on the settings passed to ffmpeg.

I'm trying the below through the command line first:

ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" output.mp4

Any help would be greatly appreciated!

18

Problem solved. I wasn't removing the audio, so presumably it was playing the, near empty, audio file for the full time of the video.

ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" -an output.mp4

-an removes the audio from the video.

1

Some more details here on speeding up audio. You can do up to 2x, but you can trick it to speed up even more (source):

Speeding up/slowing down audio

You can speed up or slow down audio with the atempo audio filter. To double the speed of audio:

ffmpeg -i input.mkv -filter:a "atempo=2.0" -vn output.mkv

The atempo filter is limited to using values between 0.5 and 2.0 (so it can slow it down to no less than half the original speed, and speed up to no more than double the input). If you need to, you can get around this limitation by stringing multiple atempo filters together. The following with quadruple the audio speed:

ffmpeg -i input.mkv -filter:a "atempo=2.0,atempo=2.0" -vn output.mkv

Using a complex filtergraph, you can speed up video and audio at the same time:

ffmpeg -i input.mkv -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mkv

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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