Discussion:
How do you speed up section of a video
(too old to reply)
Oliver
2024-11-05 20:23:54 UTC
Permalink
After the sig is a series of video conversion commands I'm using on Windows
10 to fix videos uploaded to Amazon for product reviews - which are great.

But today I have a video that is too long as it's a video of how a water
pump will self start when the water level gets high & stop when it's low.

Meanwhile the pump goes through stages, so I had to video the entire five
minute process - but three or more of the five minutes are just waiting.

Rather than chop the video (which leads the reader to think it's fudged), I
would just like to speed it up (somehow) during the interim periods.

How do you normally go about speeding up a section of a five minute MP4?

I don't even know what the proper term to google for is but I found this:
https://shotstack.io/learn/ffmpeg-speed-up-video-slow-down-videos/

According to that article, this command will double the video's speed.
ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" -an output.mp4
But I need the humming of the motor so I'll remove the audio none option.
ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" output.mp4
But you still need to speed up the audio so they add the atempo option.
ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" -af "atempo=2.0" output.mp4

But how do you speed up just a disjoint section or two of a video clip?
--
1. Create a copy of your MP4 (just in case)
C:\> copy amazon.mp4 amazon1.mp4

2. Remove metadata (spaces matter in the command below!)
C:\> exiftool -all= amazon1.mp4

(prolly should use ffmpeg for this step)

3. Test that the metadata was removed
Rightclick on the video review > Open With... > Media Info

(again, prolly should use ffmpeg)

4. Deshake the video (if needed)
C:\> ffmpeg -i amazon1.mp4 -vf deshake amazon2.mp4

5. Create captions if needed (assume a 68-second video below)
C:\> gVim amazon2.srt
1
00:00:05,000 --> 00:00:15,000
I think this product is crummy
Because it failed all my tests

2
00:00:20,000 --> 00:00:30,000
Even the cat didn't like this product

3
00:00:40,000 --> 00:00:50,000
But there was one saving grace

4
00:00:55,000 --> 00:00:68,000
The product didn't cost all that much

6. Merge captions into the file for upload to Amazon
C:\> ffmpeg -i amazon2.mp4 -vf subtitles=vine.srt amazon3.mp4

The result is a single stead(ier) file with burned-in captions.
If you can make ALL the steps using ffmpeg, that would be better.
Paul
2024-11-06 00:51:02 UTC
Permalink
Post by Oliver
After the sig is a series of video conversion commands I'm using on Windows
10 to fix videos uploaded to Amazon for product reviews - which are great.
But today I have a video that is too long as it's a video of how a water
pump will self start when the water level gets high & stop when it's low.
Meanwhile the pump goes through stages, so I had to video the entire five
minute process - but three or more of the five minutes are just waiting.
Rather than chop the video (which leads the reader to think it's fudged), I
would just like to speed it up (somehow) during the interim periods.
How do you normally go about speeding up a section of a five minute MP4?
https://shotstack.io/learn/ffmpeg-speed-up-video-slow-down-videos/
According to that article, this command will double the video's speed.
ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" -an output.mp4
But I need the humming of the motor so I'll remove the audio none option.
ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" output.mp4
But you still need to speed up the audio so they add the atempo option.
ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" -af "atempo=2.0" output.mp4
But how do you speed up just a disjoint section or two of a video clip?
You would likely chop the video into sections to begin with.

Then if you know a section is annoying and needs a speed up,
you do the transformation on just the section. Then, splice
all the pieces of processed video together.

Maybe at the splices, you ad a fade out/fade in.

Some Youtubers, seem to do speed changes right in the
middle of something, with no fades or anything... and usually
with a few "glitches" in the vid.

Paul
Oliver
2024-11-06 02:31:16 UTC
Permalink
Post by Paul
Post by Oliver
But how do you speed up just a disjoint section or two of a video clip?
You would likely chop the video into sections to begin with.
Thanks for that advice to chop up the video into sections, say one minute
sections for a five minute video, and then speed up section 2 & 4 perhaps.

Now I have to look up how to chop an MP4 which shouldn't be too hard to do.
https://www.plainlyvideos.com/blog/ffmpeg-trim-videos

That article suggests using ffmpeg like this where they say this command
will start at five seconds and add ten and end up with fifteen seconds.
ffmpeg -ss 00:00:05 -i video1.mp4 -to 00:00:10 video1-cut1.mp4

Instead of the length they say you can specify the time such as
ffmpeg -ss 00:00:05 -i video1.mp4 -t 30 video1-cut1.mp4
which is more intuitive in that it goes from five seconds to 35 seconds.

Since those re-encode, they suggest "-c copy" skips encoding steps:
ffmpeg -ss 00:00:05 -i video1.mp4 -to 00:00:10 -c copy video1-cut1.mp4

Apparently the method used messes with timestamps, which will be important
to me because I write and burn subtitles into the Amazon video reviews.

Once I get all the pieces trimmed and then some sections sped up (and the
timestamps not messed up), I can reassemble the videos into one long video.
https://stackoverflow.com/questions/7333232/how-to-concatenate-two-mp4-files-using-ffmpeg
https://trac.ffmpeg.org/wiki/Concatenate

Since my videos are all from the same source, they won't have different
aspect ratios, so it seems I should likely use the ffmpeg "concat demuxer"
instead of the ffmpeg "concat video filter" (which does re-encoding again).
:: Create File List
echo file file1.mp4 > mylist.txt
echo file file2.mp4 >> mylist.txt
echo file file3.mp4 >> mylist.txt

:: Concatenate Files
ffmpeg -f concat -i mylist.txt -c copy output.mp4

So I think I have it now.
A. I'll use ffmpeg to chop the original MP4 into a few sections.
B. I'll use ffmpeg to speed up a couple of the sections.
C. I'll use ffmpeg to reassemble the sections

Hopefully the timestamps aren't messed up because then I still have to
a. Create a text srt file using timestamps to display captions
b. Burn that text srt file into the video
c. Upload the results to Amazon for the video review

But that 2nd section of stuff you already helped me figure out how to do.
Geoff
2024-11-06 01:29:55 UTC
Permalink
Post by Oliver
After the sig is a series of video conversion commands I'm using on Windows
10 to fix videos uploaded to Amazon for product reviews - which are great.
But today I have a video that is too long as it's a video of how a water
pump will self start when the water level gets high & stop when it's low.
Meanwhile the pump goes through stages, so I had to video the entire five
minute process - but three or more of the five minutes are just waiting.
Rather than chop the video (which leads the reader to think it's fudged), I
would just like to speed it up (somehow) during the interim periods.
How do you normally go about speeding up a section of a five minute MP4?
https://shotstack.io/learn/ffmpeg-speed-up-video-slow-down-videos/
According to that article, this command will double the video's speed.
ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" -an output.mp4
But I need the humming of the motor so I'll remove the audio none option.
ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" output.mp4
But you still need to speed up the audio so they add the atempo option.
ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" -af "atempo=2.0" output.mp4
But how do you speed up just a disjoint section or two of a video clip?
Don't know about free stuff, but in Vegas Pro you simply apply a
velocity envelope and set it or fade it to whatever speed you like .
--
geoff
B. R. 'BeAr' Ederson
2024-11-06 19:56:50 UTC
Permalink
Post by Oliver
how do you speed up just a disjoint section or two of a video clip?
This speedup.cmd should speed up 2 sections inside a 50-minutes video.
Streams not explicitly referenced will be left from output.

:: ----------------------------------------------------------------------
set "filter= [0:v]trim = 00: 600 [v_01];"
set "filter=%filter%[0:a]atrim = 00: 600 [a_01];"
set "filter=%filter%[0:v]trim = 600:1200,setpts=(PTS-STARTPTS)*.5 [v_02];"
set "filter=%filter%[0:a]atrim = 600:1200,asetpts=PTS-STARTPTS,atempo=2[a_02];"
set "filter=%filter%[0:v]trim = 1200:1800 [v_03];"
set "filter=%filter%[0:a]atrim = 1200:1800 [a_03];"
set "filter=%filter%[0:v]trim = 1800:2400,setpts=(PTS-STARTPTS)*.5 [v_04];"
set "filter=%filter%[0:a]atrim = 1800:2400,asetpts=PTS-STARTPTS,atempo=2[a_04];"
set "filter=%filter%[0:v]trim = 2400:3000 [v_05];"
set "filter=%filter%[0:a]atrim = 2400:3000 [a_05];"
set "filter=%filter: =%"

set "parts=[v_01][a_01][v_02][a_02][v_03][a_03][v_04][a_04][v_05][a_05]"
set "out=concat=n=5:v=1:a=1[new]"

ffmpeg -i in.mp4 -filter_complex "%filter% %parts% %out%" -map "[new]" out.mp4
:: ----------------------------------------------------------------------

(F-Up set to acf.)

BeAr
--
===========================================================================
= What do you mean with: "Perfection is always an illusion"? =
===============================================================--(Oops!)===
Loading...