How to slow down a video

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

How to slow down a video

Ulf Zibis
Hi,

I want to slow down a mp4 video from 30 to 15 fps, so it has twice duration. Also I want the audio stream to to transform so that the audio is transformed to the natural frequency, i.e. the speach is in half speed.

How can I do this?

-Ulf

--
Von meinem Seibert gesendet

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to slow down a video

penguin flying
for video: -vf setpts=0.5*PTS
for audio: -af atempo=2

Ulf Zibis <[hidden email]> 于2020年3月27日周五 上午8:42写道:

> Hi,
>
> I want to slow down a mp4 video from 30 to 15 fps, so it has twice
> duration. Also I want the audio stream to to transform so that the audio is
> transformed to the natural frequency, i.e. the speach is in half speed.
>
> How can I do this?
>
> -Ulf
>
> --
> Von meinem Seibert gesendet
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to slow down a video

kumowoon1025
Hi,

> for video: -vf setpts=0.5*PTS
> for audio: -af atempo=2


Actually, he wanted to slow down the video so you probably meant the reciprocal of this, 2*PTS and atempo 1/2

Regards,
Ted Park

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to slow down a video

Ulf Zibis

Am 27.03.20 um 04:06 schrieb Ted Park:
> Hi,
>
>> for video: -vf setpts=0.5*PTS
>> for audio: -af atempo=2
>
> Actually, he wanted to slow down the video so you probably meant the reciprocal of this, 2*PTS and atempo 1/2

Thanks alot, this works fine.

Now I want to tweak a little bit more. I want to slow down the video by 1.4 and then increase the audio frequency by 1.25. So I did:
ffmpeg -i in.mp4 -vf setpts=PTS*1.4 -af asetrate=48000*1.25,atempo=1/1.25/1.4 out.mp4

This resulted in really bad audio quality. The reason is maybe, that the sampling rate of the output was transformed to 64.000, but I want 48.000. I guess there is a possibility to get a better result by using -af aresample, but I have problems to understand it's syntax.

Can one please give me a hint for my purpose?

-Ulf

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to slow down a video

Ulf Zibis
In reply to this post by kumowoon1025

Am 27.03.20 um 04:06 schrieb Ted Park:
> Hi,
>
>> for video: -vf setpts=0.5*PTS
>> for audio: -af atempo=2
>
> Actually, he wanted to slow down the video so you probably meant the reciprocal of this, 2*PTS and atempo 1/2

Thanks alot, this works fine.

Now I want to tweak a little bit more. I want to slow down the video by 1.4 and then increase the audio frequency by 1.25. So I did:
ffmpeg -i in.mp4 -vf setpts=PTS*1.4 -af asetrate=48000*1.25,atempo=1/1.25/1.4 out.mp4

This resulted in really bad audio quality. The reason is maybe, that the sampling rate of the output was transformed to 64.000, but I want 48.000. I guess there is a possibility to get a better result by using -af aresample, but I have problems to understand it's syntax.

Can one please give me a hint for my purpose?

-Ulf


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to slow down a video

Michael Koch
Am 04.05.2020 um 11:00 schrieb Ulf Zibis:

>
> Am 27.03.20 um 04:06 schrieb Ted Park:
>> Hi,
>>
>>> for video: -vf setpts=0.5*PTS
>>> for audio: -af atempo=2
>>
>> Actually, he wanted to slow down the video so you probably meant the
>> reciprocal of this, 2*PTS and atempo 1/2
>
> Thanks alot, this works fine.
>
> Now I want to tweak a little bit more. I want to slow down the video
> by 1.4 and then increase the audio frequency by 1.25. So I did:
> ffmpeg -i in.mp4 -vf setpts=PTS*1.4 -af
> asetrate=48000*1.25,atempo=1/1.25/1.4 out.mp4
>
> This resulted in really bad audio quality. The reason is maybe, that
> the sampling rate of the output was transformed to 64.000, but I want
> 48.000. I guess there is a possibility to get a better result by using
> -af aresample, but I have problems to understand it's syntax.

try  -af aresample=48000

Michael

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to slow down a video

Ulf Zibis-2
Am 04.05.2020 um 12:56 schrieb Michael Koch:
> Am 04.05.2020 um 11:00 schrieb Ulf Zibis:
> >//>/Am 27.03.20 um 04:06 schrieb Ted Park: />>/Hi, />>//>>>/for video: -vf setpts=0.5*PTS />>>/for audio: -af atempo=2 />>//>>/Actually, he wanted to slow down the video so you probably meant the />>/reciprocal of this, 2*PTS and atempo 1/2 />//>/Thanks alot, this works fine. />//>/Now I want to tweak a little bit more. I want to slow down the video />/by 1.4 and then increase the audio frequency by 1.25. So I did: />/ffmpeg -i in.mp4 -vf setpts=PTS*1.4 -af />/asetrate=48000*1.25,atempo=1/1.25/1.4 out.mp4 />//>/This resulted in really bad audio quality. The reason is maybe, that />/the sampling rate of the output was transformed to 64.000, but I want />/48.000. I guess there is a possibility to get a better result by using />/-af aresample, but I have problems to understand it's syntax. /
> try  -af aresample=48000
Do you mean, I should add this at the end of my filter chain? I can't imagine, that using it singular instead would do what I want.

Am 05.05.2020 um 09:06 schrieb Michael Koch:

> Regarding your question about audio length / sample rate / tempo, see also chapter 3.3 here:
> www.astro-electronic.de/FFmpeg_Book.pdf
Thanks for your hint, I will look at this.

-Ulf

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to slow down a video

Michael Koch
Am 05.05.2020 um 13:21 schrieb Ulf Zibis:

> Am 04.05.2020 um 12:56 schrieb Michael Koch:
>> Am 04.05.2020 um 11:00 schrieb Ulf Zibis:
>> >//>/Am 27.03.20 um 04:06 schrieb Ted Park: />>/Hi, />>//>>>/for
>> video: -vf setpts=0.5*PTS />>>/for audio: -af atempo=2
>> />>//>>/Actually, he wanted to slow down the video so you probably
>> meant the />>/reciprocal of this, 2*PTS and atempo 1/2 />//>/Thanks
>> alot, this works fine. />//>/Now I want to tweak a little bit more. I
>> want to slow down the video />/by 1.4 and then increase the audio
>> frequency by 1.25. So I did: />/ffmpeg -i in.mp4 -vf setpts=PTS*1.4
>> -af />/asetrate=48000*1.25,atempo=1/1.25/1.4 out.mp4 />//>/This
>> resulted in really bad audio quality. The reason is maybe, that
>> />/the sampling rate of the output was transformed to 64.000, but I
>> want />/48.000. I guess there is a possibility to get a better result
>> by using />/-af aresample, but I have problems to understand it's
>> syntax. /
>> try  -af aresample=48000
> Do you mean, I should add this at the end of my filter chain? I can't
> imagine, that using it singular instead would do what I want.
>

yes, add it at the end of the filter chain.

Michael

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to slow down a video

Ulf Zibis-2

Am 05.05.20 um 13:25 schrieb Michael Koch:
> Am 05.05.2020 um 13:21 schrieb Ulf Zibis:
>> Am 04.05.2020 um 12:56 schrieb Michael Koch:
>>> Am 04.05.2020 um 11:00 schrieb Ulf Zibis:
>>> >//>/Am 27.03.20 um 04:06 schrieb Ted Park: />>/Hi, />>//>>>/for video: -vf setpts=0.5*PTS />>>/for audio: -af atempo=2 />>//>>/Actually, he wanted to slow down the video so you probably meant the />>/reciprocal of this, 2*PTS and atempo 1/2 />//>/Thanks alot, this works fine. />//>/Now I want to tweak a little bit more. I want to slow down the video />/by 1.4 and then increase the audio frequency by 1.25. So I did: />/ffmpeg -i in.mp4 -vf setpts=PTS*1.4 -af />/asetrate=48000*1.25,atempo=1/1.25/1.4 out.mp4 />//>/This resulted in really bad audio quality. The reason is maybe, that />/the sampling rate of the output was transformed to 64.000, but I want />/48.000. I guess there is a possibility to get a better result by using />/-af aresample, but I have problems to understand it's syntax. /
>>> try  -af aresample=48000
>> Do you mean, I should add this at the end of my filter chain? I can't imagine, that using it singular instead would do what I want.
>>
>
> yes, add it at the end of the filter chain.

Thanks!

I now tried:
ffmpeg -i in.mp4 -vf setpts=PTS*1.4 -af atempo=1/1.25/1.4,asetrate=48000*1.25,aresample=48000 out.mp4

The audio quality is still bad, i.e. the voices flip in a way. Therefore I'm thinking about using aresample with:
async
     For swr only, simple 1 parameter audio sync to timestamps using _stretching_, _squeezing_, filling and trimming. Setting this to 1 will enable filling and trimming, larger values represent the maximum amount in samples that the data may be stretched or squeezed for each second. Default value is 0, thus no compensation is applied to make the samples match the audio timestamps.

But I'm lost how use it correctly. I want to slow down the video by 1.4 and then increase the audio frequency (pitch) by 1.25.

Can you give me some hint?

-Ulf

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to slow down a video

kumowoon1025
Hi,

> But I'm lost how use it correctly. I want to slow down the video by 1.4 and then increase the audio frequency (pitch) by 1.25.


So if you slow the video down by 1.4, You are also slowing down the audio by the same amount right? I think 1/1.4, and to add to the pitch to 1.25 ratio you'd have to multiply by 1.75, using filters to change frequency/pitch, librubberband has a simple pitch ratio factor you can multiply to whole spectrum. Or you could resample to your output format rate * 0.8 (1/1.25) then asetrate to the output sample rate after strectching/shrinking the audio to be 1.25 times the video length I think it will have a similar effect.

For example, slowing the video down could be -vf setpts=1.4*PTS, and for audio -af atempo=1/1.25/1.4,aresample=36000,asetrate=48000

Regards,
Ted Park

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to slow down a video

Ulf Zibis-2

Am 05.05.20 um 15:07 schrieb Edward Park:

> Hi,
>
>> But I'm lost how use it correctly. I want to slow down the video by 1.4 and then increase the audio frequency (pitch) by 1.25.
>
> So if you slow the video down by 1.4, You are also slowing down the audio by the same amount right? I think 1/1.4, and to add to the pitch to 1.25 ratio you'd have to multiply by 1.75, using filters to change frequency/pitch, librubberband has a simple pitch ratio factor you can multiply to whole spectrum. Or you could resample to your output format rate * 0.8 (1/1.25) then asetrate to the output sample rate after strectching/shrinking the audio to be 1.25 times the video length I think it will have a similar effect.
>
> For example, slowing the video down could be -vf setpts=1.4*PTS, and for audio -af atempo=1/1.25/1.4,aresample=36000,asetrate=48000
>
> Regards,
> Ted Park

Swapping aresample with asetrate is an interesting aproach. It seems to have very little better quality.

Aside I have a question: Where can I find a list of properties, which can be used as parameter in commands. E.g. I can use "PTS" for current picture time stamp and "h" for the heigth. In my case interesting: What is the parameter for the audio rate to use with asetrate=RATE*1.25 ?

-Ulf

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to slow down a video

Michael Koch
Am 05.05.2020 um 18:27 schrieb Ulf Zibis:

>
> Am 05.05.20 um 15:07 schrieb Edward Park:
>> Hi,
>>
>>> But I'm lost how use it correctly. I want to slow down the video by
>>> 1.4 and then increase the audio frequency (pitch) by 1.25.
>>
>> So if you slow the video down by 1.4, You are also slowing down the
>> audio by the same amount right? I think 1/1.4, and to add to the
>> pitch to 1.25 ratio you'd have to multiply by 1.75, using filters to
>> change frequency/pitch, librubberband has a simple pitch ratio factor
>> you can multiply to whole spectrum. Or you could resample to your
>> output format rate * 0.8 (1/1.25) then asetrate to the output sample
>> rate after strectching/shrinking the audio to be 1.25 times the video
>> length I think it will have a similar effect.
>>
>> For example, slowing the video down could be -vf setpts=1.4*PTS, and
>> for audio -af atempo=1/1.25/1.4,aresample=36000,asetrate=48000
>>
>> Regards,
>> Ted Park
>
> Swapping aresample with asetrate is an interesting aproach. It seems
> to have very little better quality.
>
> Aside I have a question: Where can I find a list of properties, which
> can be used as parameter in commands. E.g. I can use "PTS" for current
> picture time stamp and "h" for the heigth.

Either in the documentation, or in the built-in help function (which
does sometimes contain more details).
ffmpeg -h filter=asetrate

> In my case interesting: What is the parameter for the audio rate to
> use with asetrate=RATE*1.25 ?
>

I don't think such a variable exists for asetrate filter. Or it's
undocumented.

Michael
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to slow down a video

Ulf Zibis-2

Am 05.05.20 um 20:14 schrieb Michael Koch:

> Am 05.05.2020 um 18:27 schrieb Ulf Zibis:
>>
>> Aside I have a question: Where can I find a list of properties, which can be used as parameter in commands. E.g. I can use "PTS" for current picture time stamp and "h" for the heigth.
>
> Either in the documentation, or in the built-in help function (which does sometimes contain more details).
> ffmpeg -h filter=asetrate
>
>> In my case interesting: What is the parameter for the audio rate to use with asetrate=RATE*1.25 ?
>>
>
> I don't think such a variable exists for asetrate filter. Or it's undocumented.

Ah, the usable parameters are dependent from the filter in use, right?

(I thought, that those parameters are common for all.)

-Ulf

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to slow down a video

Michael Koch
Am 05.05.2020 um 20:58 schrieb Ulf Zibis:

>
> Am 05.05.20 um 20:14 schrieb Michael Koch:
>> Am 05.05.2020 um 18:27 schrieb Ulf Zibis:
>>>
>>> Aside I have a question: Where can I find a list of properties,
>>> which can be used as parameter in commands. E.g. I can use "PTS" for
>>> current picture time stamp and "h" for the heigth.
>>
>> Either in the documentation, or in the built-in help function (which
>> does sometimes contain more details).
>> ffmpeg -h filter=asetrate
>>
>>> In my case interesting: What is the parameter for the audio rate to
>>> use with asetrate=RATE*1.25 ?
>>>
>>
>> I don't think such a variable exists for asetrate filter. Or it's
>> undocumented.
>
> Ah, the usable parameters are dependent from the filter in use, right?

That's right. And you have to be careful because for some filters they
are upper case and for other filters lower case.

Michael

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".