ffmpeg -i in.mp4 -vf "select='if(gt(scene,0.03),st(1,t),lte(t-ld(1),4))',setpts=N/FRAME_RATE/TB" -an trimmed2.mp4
my code but, it did not work for my case. help pls
Say you want to trim from 1.25 seconds in to 5 seconds in:
ffmpeg -ss 1.25 -i in.mp4 -to 5 -an trimmed2.mp4
Same thing but specifying duration instead of end point (preferred probably):
ffmpeg -ss 1.25 -i in.mp4 -t 3.75 -an trimmed2.mp4
Or if you only wanted exactly 40 frames:
ffmpeg -ss 1.25 -i in.mp4 -frames:v 40 -an trimmed2.mp4
More info on seeking / trimming here: https://trac.ffmpeg.org/wiki/Seeking#Cuttingsmallsections
Related
ffmpeg -ss 2 -i input.mp4 -c copy -t 5 out.mp4
after I executed the ffmpeg command.
the out.mp4 total have 7 seconds,it starts from the second frame of input.mp4 to the seventh frame of input.mp4.
It only has 5 effective seconds of the input.mp4, the last 2 seconds of input.mp4 is empty.
ffmpeg -ss 00:00:02.00 -i input.mp4 -t 5 out_5seconds.mp4
I've got a video with the length of 200 minutes.
And also got the timestamp for each snapshot that will be taken.
I've tried to use ffmpeg to take snapshot with following commands.
However, it is very slow, and takes about 10 seconds for each snapshot.
Is there any way that can speed up? Thanks.
OS: win10; PC: Intel NUC8i5
ffmpeg -i 1.mp4 -ss 00:00:04 -vframes 1 000004.jpg
ffmpeg -i 1.mp4 -ss 00:00:08 -vframes 1 000008.jpg
ffmpeg -i 1.mp4 -ss 00:00:12 -vframes 1 000012.jpg
ffmpeg -i 1.mp4 -ss 00:00:16 -vframes 1 000016.jpg
ffmpeg -i 1.mp4 -ss 00:00:17 -vframes 1 000017.jpg
ffmpeg -i 1.mp4 -ss 00:00:20 -vframes 1 000020.jpg
ffmpeg -i 1.mp4 -ss 00:00:24 -vframes 1 000024.jpg
ffmpeg -i 1.mp4 -ss 00:00:26 -vframes 1 000026.jpg
ffmpeg -i 1.mp4 -ss 00:00:28 -vframes 1 000028.jpg
ffmpeg -i 1.mp4 -ss 00:00:32 -vframes 1 000032.jpg
ffmpeg -i 1.mp4 -ss 00:00:36 -vframes 1 000036.jpg
ffmpeg -i 1.mp4 -ss 00:00:38 -vframes 1 000038.jpg
ffmpeg -i 1.mp4 -ss 00:00:43 -vframes 1 000043.jpg
If the timestamps are at irregular intervals (as appears to be the case from your example) you can use a select filter:
ffmpeg -i 1.mp4 -filter:v \
"select='lt(prev_pts*TB\,4)*gte(pts*TB\,4) \
+lt(prev_pts*TB\,12)*gte(pts*TB\,12) \
+lt(prev_pts*TB\,17)*gte(pts*TB\,17) \
+lt(prev_pts*TB\,28)*gte(pts*TB\,28) \
+lt(prev_pts*TB\,43)*gte(pts*TB\,43)'" \
-vsync drop out/%03d.jpg
This will grab the frame at the specified timestamp and if there is not a frame at that precise timestamp, it will grab the following frame.
Try split video (200 min one) in 200 parts, then load one by one. Loading whole video to ram is expensive. Try with small video to see how it will improve
I used VLC to solve this problem.
The basic idea is to use VLC's http interface to control vlc to jump to specific timestamp and take the snapshot.
The cosumption of RAM is very low, and the speed is much faster.
It takes about 16 minutes to take 3800 snapshots.
The below code is in autohotkey.
#Include, VLC_HTTP2.ahk
Loop, read, %A_ScriptDir%\TimeStamps.txt
{
VLC_JumpTime:=A_LoopReadLine
VLCHTTP2_Jumpto(VLC_JumpTime)
Sleep, 100
VLCHTTP2_Snapshot()
}
return
VLCHTTP2_Jumpto(VLC_JumpToTime)
{
VLC_CurrentTime:=VLCHTTP2_TimeSeconds()
SeekBackwardTime:=VLC_CurrentTime-VLC_JumpToTime
if SeekBackwardTime >0
VLCHTTP2_JumpBackward(SeekBackwardTime)
else if SeekBackwardTime <0
{
SeekForwardTime:=-SeekBackwardTime
VLCHTTP2_JumpForward(SeekForwardTime)
}
}
Make a video from a series of 100 figures
ffmpeg -framerate 10 -i input_figure%01d.png out.mp4
How can I only make figure numbers from [0-49] with a slower speed like -framerate 5?
My try is
ffmpeg -start_number 1 -framerate 5 -i input_figure%01d.png -vframes 49 \
-start_number 50 -framerate 10 -i input_figure%01d.png \
out.mp4
Doesn't work
The naive method is to create videos in parts, then concat them togother
ffmpeg -framerate 5 -i input_fig%01d.png -vframes 49 part_1.mp4
ffmpeg -start_number 50 -framerate 10 -i input_fig%01d.png part_2.mp4
ffmpeg -f concat -safe 0\
-i <(for f in ./part_*.mp4; do echo "file '$PWD/$f'"; done)\
-c copy out.mp4
rm part_*.mp4
Hi I am trying to speed up and trim clips with FFMPEG version 4.2.2. Is there a limit to how fast you can speed up a clip? If I try to speed up a clip over a certain then the output file cannot be opened.
I have tried two methods without any luck: 1. using the setPTS filter and 2. inputing the file at a faster frame rate.
1.
ffmpeg -i GH012088.MP4 -y -ss 18 -t 0.48 -an -filter:v "setpts=0.096*PTS" -r 25 output.MP4
2.
ffmpeg -r 312.1875 -i GH012088.MP4 -y -ss 18 -t 0.48 -r 25 -an output.MP4
I am trying to create a clip from the input that starts at 1 second in the original clip, plays at 10.4166 x speed and lasts for 0.48 seconds
What am I doing wrong?
Thanks
Use
ffmpeg -ss 1 -i GH012088.MP4 -y -t 0.48 -an -filter:v "setpts=0.096*PTS" -r 25 output.MP4
The seek has to be on the input side, before frames are retimed. The -t has to be on output side, after frames are retimed.
Does the movie have sound?
If yes, than we have to sync speed up audio and video by combine filter:
ffmpeg -i video.avi -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" -f avi video1.avi
So I have three images that I need to combine into a 10 second video, I have searched around and in the end I came up with the following command, it is generating a video but not what I expected.
ffmpeg.exe -loop 1 -framerate 1 -i 20180627124135055101050.JPG -i 20180627124135056101051.JPG -i 20180627124135057101052.JPG -i 20180627124135056101051.JPG -vf framestep=4,setpts=N/FRAME_RATE/TB -c:v mpeg4 -t 10 video.mp4
It is currently generating a video of 12 seconds in length, but it is also only showing the first image, I have played around with the framerate option and the framestep option values but all change that I can see is in the length of the video, it never actually shows the images in the order I need them to display. What I basically need as a result is a giff of the 3 images in the order image 1, image 2, image 3, image 2. But as a mp4 of 10 seconds long.
Any assistance would be greatly appreciated
EDIT 1
So I have made some progress, I am now using the following command to get the correct video output, but now I need it to loop so the total video length can be 10 seconds
ffmpeg -loop 1 -framerate 25 -t 0.25 -i 20180627124135055101050.JPG -loop 1 -framerate 24 -t 0.25 -i 20180627124135056101051.JPG -loop 1 -framerate 24 -t 0.25 -i 20180627124135057101052.JPG -loop 1 -framerate 24 -t 0.25 -i 20180627124135056101051.JPG -filter_complex "[0][1][2][3]concat=n=4:v=1:a=0" video.mp4
Ok so I finally figured it out, the command I had to use to get this working was:
ffmpeg -loop 1 -framerate 30 -t 0.16 -i 20180627124135055101050.JPG -loop 1 -framerate 30 -t 0.16 -i 20180627124135056101051.JPG -loop 1 -framerate 30 -t 0.16 -i 20180627124135057101052.JPG -loop 1 -framerate 30 -t 0.16 -i 20180627124135056101051.JPG -filter_complex "[0][1][2][3]concat=n=4:v=1:a=0[v1],[v1]loop=20:32767:0" video.mp4