Как с помощью fft ускорить звук
Перейти к содержимому

Как с помощью fft ускорить звук

  • автор:

 

Speeding up/slowing down video

The speed of a video stream can be changed by changing the presentation timestamp (PTS) of each video frame. This can be done via two methods: using the ​ setpts video filter (which requires re-encoding) or by erasing the timestamps by exporting the video to a raw bitstream format and muxing to a container while creating new timestamps.

Note that in the following examples, the audio stream is not changed, so it should ideally be disabled with -an .

raw bitstream method

This method is lossless and apart from changing the timestamps, copies the video stream as-is. Use this if you require no other changes to your input video.

First, copy the video to a raw bitstream format.

Then generate new timestamps while muxing to a container:

Change the value of -r to the desired playback frame rate.

setpts filter

To double the speed of the video with the setpts filter, you can use:

The filter works by changing the presentation timestamp (PTS) of each video frame. For example, if there are two succesive frames shown at timestamps 1 and 2, and you want to speed up the video, those timestamps need to become 0.5 and 1, respectively. Thus, we have to multiply them by 0.5.

Note that this method will drop frames to achieve the desired speed. You can avoid dropped frames by specifying a higher output frame rate than the input. For example, to go from an input of 4 FPS to one that is sped up to 4x that (16 FPS):

To slow down your video, you have to use a multiplier greater than 1:

 

Smooth

You can smooth out slow/fast video with the ​ minterpolate video filter. This is also known as «motion interpolation» or «optical flow».

Speeding up/slowing down audio

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

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:

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

With the raw bitstream method example from above, there is no need for a complex filtergraph. You can slow down a 30 fps video and audio at the same time with:

FFmpeg | Ускорить или замедлить аудио/видео

Этим фильтром я и сам часто пользуюсь, когда нужно ускорить видео процесса рисования, стримы или просто какое-то видео, которое затем нужно вставить в видеоредакторе, потому что там обычно ограничения на кратность ускорения.

Для ускорения или замедления видео используется фильтр setpts:
-vf setpts= коэффициент_скорости *PTS
Если коэффициент скорости больше единицы, то видео замедлится, если меньше — ускорится.

Замедлить видео в 5 раз:

Для ускорения можно использовать такой формат:
-vf setpts=PTS/ коэффициент_ускорения
Где коэффициент_ускорения должен быть больше единицы.

Ускорить видео в 4 раза:

Ускорить/замедлить аудио темп Для изменения темпа используется аудиофильтр atempo:
-af atempo= темп
Темп должен быть в пределах 0.5. 100

 

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *