FFMPEG - конвертировать видео в замедленную съемку

7455
Sandwich

Я использую ffmpeg во Flash Builder (Action script 3), чтобы конвертировать видео в промежуток времени. Я разработал, как использовать setpts, чтобы сделать это, но конечный выходной файл имеет ту же длину, что и вход (только последний кадр отображается после промежутка времени), я хочу, чтобы продолжительность была изменена на основе переданных настроек к ffmpeg.

Я пытаюсь ниже через командную строку сначала:

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

Любая помощь будет принята с благодарностью!

8

2 ответа на вопрос

9
Sandwich

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
Sun

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

Похожие вопросы