I have 1300 frames, and I convert them at 21fps. That should be over a minute of footage from my sequence of images, but the lossless command I'm using is producing an 18 second video out of the 1300 frames. Am I doing this wrong?
Command:
ffmpeg -framerate 21 -i Blots_%04d.0001_x2-standard-scale-2_00x.tif -c:v libx264rgb -crf 0 Blots.mp4
The video in Media Player Classic says it only draws 337 frames at 21fps.
I also tried the following which resutls in the same size file and issue:
ffmpeg -r 21 -i Blots_%04d.0001_x2-standard-scale-2_00x.tif -c:v libx264rgb -crf 0 Blots.mp4
Turns out there is no problem with FFMPEG, but an error with my batch processing program, which did a 300 of the frames in one setting, and the rest in another, resulting in a different file name setup.
Related
I am trying to use FFmpeg to make 1457 frames into a video, and it's not working.
I am using this command:
ffmpeg -i "frame%6d.png" -framerate 24 -c:v libx265 -preset slow -crf 17 -vf "scale=4096x4096" -pix_fmt yuv420p -an -movflags faststart -r 24 "video.mp4"
The problem is that it stops collecting frames after 1399, and I have no idea why. I have tried changing to fps=24 instead of -r 24 for the output but that didn't work. I have also tried adding one more frame at the end of the image sequence and then the command stopped after frame 1400. I also tried changing the name of the last frame to a bigger number but then the command stopped at frame 1399 again. Why is this happening?
I have more than a thousand images that I want to transform into a 3 minutes video. I tried using this line ffmpeg -r 30 -i "E:/White-box-Cartoonization/test_code/cartoonized_images/$flower%03d.bmp" -c:v libx264 -pix_fmt yuv420p out.mp4 it worked but creates only a 5 seconds video. What do I need to do to turn it into a full length 3 minutes video?
If you have 1250 images and want an output duration of 180 seconds:
ffmpeg -framerate 1250/180 -i input%03d.bmp -c:v libx264 -vf format=yuv420p output.mp4
This example results in a frame rate of 6.94. Some players can't handle such low frame rates. If your player does not like it then add the -r output option to make a normal output frame rate. ffmpeg will duplicate the frames but the output will look the same.
ffmpeg -framerate 1250/180 -i input%03d.bmp -c:v libx264 -vf format=yuv420p -r 25 output.mp4
For 3 minutes of video at 30 frames per second (-r parameter) you'd need 30*60*3 images: 5400 images.
Your source parameter specifies there would be only 3 digits, so you have a maximum of 1000 source images:
$flower%03d.bmp => $flower000.bmp .. $flower999.bmp
1000 images at 30 frames per second should give about 30 seconds of video ... if you actually have $flowerxxx.bmp files.
You might need a 4th digit in there somewhere.
$flower%04d.bmp
Using avconv (or even ffmpeg, so I can use as a reference), how can I create a time lapse video by taking only anchor/reference frames from another video? Most information I find is on how to create a time lapse video by combining images, and I'd like to do it by extracting frames from a video. Say, if a video is 30 seconds long at 30 FPS, I'd like to take 60 out of those 900 frames (900/60 = every 15 seconds) to produce a 2 second video.
To take every 15th frame, use
ffmpeg -i in.mp4 -vf select='not(mod(n,15))',setpts=N/FRAME_RATE/TB out.mp4
Another method is to use the framestep filter
ffmpeg -i in.mp4 -vf framestep=15,setpts=N/FRAME_RATE/TB out.mp4
I had a H264 video from a camera and after lots of attempts found following command that produce 16x faster video with good result and 60 FPS (option -r) that is good for the YouTube timelapse
ffmpeg -i video.avi -r 60 -filter:v "setpts=0.0625*PTS" -vcodec libx264 -an timelapse.avi
You can check the result here https://www.youtube.com/watch?v=azhRqKQ7kCU
Since you are asking for 1/15 frame it will be 1/15 ~= 0.06667 with 30 FPS result video you will need command
ffmpeg -i video.avi -r 30 -filter:v "setpts=0.06667*PTS" -vcodec libx264 -an timelapse.avi
I have a directory that contains 2001 PNG files. I can convert all of the frames to an mp4 video using ffmpeg and the following command:
ffmpeg -framerate 60 -start_number 0 \
-i pic.comp2.%07d.png -c:v libx264 -r 30 \
-pix_fmt yuv420p input1ia.mp4
This works fine. However, I am creating a more complicated application that needs to read only the first 1020 files in the directory (specifically 0 thru 1019). Some googling around led me to the -vframes option. My problem is -- it seems to get ignored or at least interpreted differently than I expect.
My modified command looks like:
ffmpeg -framerate 60 -start_number 0 \
-i pic.comp2.%07d.png -vframes 1020 -c:v libx264
-r 30 -pix_fmt yuv420p input1.mp4
It seems like many other people doing the same thing as me do not encounter this issue. So I did some more digging. I tried changing vframes from 1020 to -vframes 20, and this seemed to work properly. So now I am thinking it might be some kind of mismatch between -framerate and -r?
The full resultant video is 33 sec long... which makes sense mathematically.
1 sec
--------- x 2001 frames = 33.35 seconds
60 frames
That's why I thought that specifying ~1/2 of the PNGs as the 'end point' would result in a video of the first ~16-17 seconds. But I always get the full length video from using the -vframes option.
I assume my input to -vframes must be incorrect mathematically, since a small number of frames seems to work. However, I do not understand why.
The most educated guess I can seem to make is that it is reading the PNGs as 60fps (-framerate), but the -r makes the output video 30fps or something? However, then I would assume that the full output video would not be 33 seconds long.
When the input and output rates don't match, ffmpeg drops or duplicate frames as per a regular scheme to achieve the output rate. So, for an input rate of 60 and an output rate of 30, half the frames are dropped. With the vframes option, 1020 frames at a output rate of 30 should produce a video of duration 1020/30 = 34 seconds.
To achieve what you want, use the t option
ffmpeg -framerate 60 -start_number 0 -t 17 \
-i pic.comp2.%07d.png -c:v libx264 -r 30 \
-pix_fmt yuv420p input1ia.mp4
where 17 is number of frames to be used / input rate
I have been trying to extract keyframes from video using ffmpeg 0.11.1 . So far all the commands I have tried do not extract keyframes but return all the frames ie 25fps*total time number of frames in the output.
I tried setting the keyint_min as 25 to make sure there is a amximum of 1 keyframe per second.
ffmpeg -vf select="eq(pict_type\,PICT_TYPE_I)" -g 250 -keyint_min 25 -i C:\test.mp4 -vsync 2 -f image2 C:\testTemp\thumbnails-%02d.jpeg
But still all the frames are returned.
Then i tried, to separate the keyframes by 20 seconds.
ffmpeg -i C:\test.mp4 -vf select='eq(pict_type\,I)*(isnan(prev_selected_t)+gte(t-prev_selected_t\,20))' -vsync 0 -f image2 C:\testTemp\%09d.jpg
Again same result, all the frames are returned.
What should I do?
In your first command you are using the filter as an input option. I don't know how ffmpeg will interpret that.
Try this:
ffmpeg -i C:\test.mp4 -vf select='eq(pict_type\,I)',setpts='N/(25*TB)' C:\testTemp\%09d.jpg
Change 25 to the frame rate of your source: 30000/1001 for NTSC video, 24000/1001 for NTSC film, 25 for PAL, etc.
Control output quality with the -q:v or -qscale:v option (just called -qscale in old ffmpeg). Range for mpeg* is 1-31 where 31 is the worst quality.
Next time remember that ffmpeg usage questions are to be asked at superuser.com since stackoverflow is specifically for programming.