Why the following ffmpeg command outpus an eleven minutes long video?
ffmpeg -ss 600 -i 01x01TheStrongestMan.mp4 -to 660 -vcodec copy -acodec copy -y outputxxx.mp4
I want to slice the video from the 600 second to the 660 second, the output should be a 1 minute long video.
How can I do that and why my command is wrong?
Thanks.
Here's a few little test examples I did which may shed some light.
Seek before: (Quicker but less accurate)
ffmpeg -ss 600 -to 660 -i movie.mkv -vcodec copy -acodec copy -y output1.mp4
Seek after: (Slower but more accurate)
ffmpeg -i movie.mkv -ss 600 -to 660 -vcodec copy -acodec copy -y output2.mp4
Seek before and after: (Quick and accurate)
ffmpeg -ss 500 -i movie.mkv -ss 100 -to 160 -vcodec copy -acodec copy -y output3.mp4
However........
Depending on which frames are which, you'll not always get accurate cuts/trims. You'll also get different results, or find one method better than another, depending on whether you are just copying streams, or encoding.
Related
In my input video is a 48 second range that I wish to speed up. I wish to save only that sped up portion to a new video.
Solution:
ffmpeg -y -ss 00:00:03 -t 00:00:48 -i input.mp4 -an -crf 20 -pix_fmt yuv420p -vf "scale=1080:-1, setpts=PTS/10.0" "output.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
Let's say I have a video called Concert.mp4. I want to extract a performance from it quickly with minimal reencoding. I want to do the equivalent of this, but faster:
ffmpeg -i "Concert.mp4" -ss 00:11:45 -to 00:18:15 -preset veryfast -y artist.mp4
This takes 17 seconds, which is way too long for our needs.
Now, it turns out that 11:45 and 18:15 don't fall on iframes, so if you try this you will get a 3 second delay at the beginning before the video shows:
ffmpeg -i "Concert.mp4" -ss 00:11:45 -to 00:18:15 -c copy -y artist.mp4
Running this command, we can see where we need to cut:
ffprobe -read_intervals "11:00%19:00" -v error -skip_frame nokey -show_entries frame=pkt_pts_time -select_streams v -of csv=p=0 "Concert.mp4" > frames.txt
So what we need to do is encode the first 3.708 seconds, copy the middle, and then encode the last 5.912 seconds.
I can get the 3 segments to all look perfect (by themselves) like this:
ffmpeg -ss 698.698 -i "Concert.mp4" -ss 6.302 -t 3.708 -c:v libx264 -c:a copy -c:s copy -y clipbegin.mp4
ffmpeg -ss 708.708 -to 1089.088 -i "Concert.mp4" -c copy -y clipmiddle.mp4
ffmpeg -ss 1089.088 -i "Concert.mp4" -t 5.912 -c:v libx264 -c:a copy -c:s copy -y clipend.mp4
ffmpeg -f concat -i segments.txt -c copy -y artist.mp4
segments.txt of course contains the following:
file 'clipbegin.mkv'
file 'clipmiddle.mkv'
file 'clipend.mkv'
I saw this solution presented here, but no amount of tweaking gets it to work for me:
https://superuser.com/a/1039134/73272
As far as I can tell, this method doesn't work at all. It crashes VLC pretty hard no matter what I try.
The combined video keeps glitching after the 3 seconds, probably because the PTS times are different or something (using some options, I have seen warning messages to this effect). Is there anything I can add to the commands above to get this to work? The only requirement is that the middle command must not re-encode the video, but must do a fast copy.
Thanks in advance.
OK, so the answer was just that the latest VLC seems to be buggy. What I did above plays just fine with a very slight pause at the cut point in ffplay, mplayer and PotPlayer.
Following #Gyan's advice, I set the profile and level to match the original (using -profile:v main -level:v 4) and even the slight pause went away.
ffmpeg -ss 698.698 -i "Concert.mp4" -ss 6.302 -t 3.708 -c:v libx264 -c:a copy -c:s copy -profile:v main -level:v 4 -y clipbegin.mp4
ffmpeg -ss 708.708 -to 1089.088 -i "Concert.mp4" -c copy -y clipmiddle.mp4
ffmpeg -ss 1089.088 -i "Concert.mp4" -t 5.912 -c:v libx264 -c:a copy -c:s copy -profile:v main -level:v 4 -y clipend.mp4
ffmpeg -f concat -i segments.txt -c copy -y artist.mp4
I've been trying to find out solutions but could not, on how to extract a video segment (say an mp4) from a given m3u8 file, where the video starts from some offset and has a particular duration. Wish someone could help.
I tried this:
ffmpeg -i http://foo.herokuapp.com/input_test.m3u8 -acodec copy -vcodec copy -y -loglevel info -f mp4 myNewVideo.mp4
It generates the video, but now I need it to start from a particular offset and it needs to last a particular duration. I know that the offset might need the -ss flag, but it doesn't seem to be working.
Examples for a capture starting at 30s (-ss) with a duration of 10s (-t).
If the input HLS playlist is of type VOD you can do:
ffmpeg -ss 00:00:30 -i http://foo.herokuapp.com/input_test.m3u8 -t 10 -c copy -bsf:a aac_adtstoasc -flags +global_header -y output.mp4
If the input is a Live stream then:
ffmpeg -i http://foo.herokuapp.com/input_test.m3u8 -ss 00:00:30 -t 10 -c copy -bsf:a aac_adtstoasc -flags +global_header -y output.mp4
The seek is done on the output in the second case (-ss after -i).
You can also add a -re before -i for the live stream if you want to avoid fetching the latest 3 segments at once when you execute the command.
I want to compress a raw video .y4m to mpg, and I want then to extract the frames from the mpg video, I need the GOP of the compression to be :IBBPBBPBBPBBPBBIBBP....15:2
I used this command:
ffmpeg -i video.ym4 -vcodec libx264 -sameq -y -r 30 output.avi 2>list.txt
ffmpeg -i output.avi -vcodec libx264 -y -sameq -vf showinfo -y -f image2 image%3d.jpeg -r 30 2>list1.txt
The output contains only 2 I frames, 100 P and 198 B frames, it is not 15:2 GOP, what to do?
I need one I-frame every 15 frames, and the pattern to b IBBPBBP..
Sorry, Im new to ffmpeg, please help me, this is the input to my project, it is the important step to me.
Try (according to http://ffmpeg.org/ffmpeg.html#Video-Encoders)
ffmpeg -i video.ym4 -vcodec libx264 -g 15 -y -r 30 output.avi
I think option -sameq (means "same quantizers") is not needed in your case.