Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
On the FFmpeg documentation (here, and here) I read that, by default, FFmpeg chooses to extract frames at 25 frames per second (otherwise you can specify a framerate with the -r option)
My problem is that I have a folder with dozens of videos, each of them recorded at different frame rates, so my question is:
Is there a way to ask FFmpeg to extract frames from a video at the "native" frame rate (i.e. the original frame rate at which the video was recorded)?
In case it matters, I am working with MP4 files
To get the original frame rate:
ffmpeg -i file.mp4 2>&1 | grep -o '[0-9]\{1,3\}\sfps'
Example Output:
25 fps
You can futher pipe it to sed ... | sed 's/\sfps//' to keep only the 25, and store it into a variable, so you can use that variable to convert the videos e.g. ffmpeg -r $originalFps.
grep -o will extract the match, instead of the whole line containing the match.
[0-9]\{1,3\} will match one to three digits
\sfps will match a white space followed by 'fps'
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
How can I create a mpg/mp4 file from let's say 10 images using ffmpeg.
Each image shall stay for 5 minutes, after the 5 minutes are over the next image shall appear and so on....
How can I achieve this?
If your images are numbered in a sequence (img001, img002, img003..), use
ffmpeg -framerate 1/300 -i img%3d.jpg -r 5 video.mp4
(I've set an output framerate of 5 for player compatibility. Each image will still remain for 300 seconds)
If your filenames are irregular, and you are executing in a Unix shell like bash, you can run
ffmpeg -framerate 1/300 -pattern_type glob -i '*.jpg' -r 5 video.mp4
For MPEG-2,
ffmpeg -framerate 1/300 -i img%3d.jpg -c:v mpeg2video -b:v 2000k -r 5 video.mpg
No idea what minimum output framerates are expected of MPEG-2. Experiment.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I have a video of 120MB.I need to reduce its size to 20 MB without changing its quality.Is there any direct ffmpeg command which i can run?
I know the commands to reduce video size between specific time intervals and for resolution.Is there any way ffmpeg can reduce the size in MB?
I need to reduce its size [..] without changing its quality.
That is generally not possible.
I have a video of 120MB. I need to reduce its size to 20 MB
Welcome to video coding (and audio coding). Tell us something about the input file. Run:
ffprobe input
This will tell us how the file is currently coded. Then, let's work on re-encoding it. First, I'm assuming you don't want to change resolution/framerate, so we'll keep that the same. Second, let's select a video codec/encoder. Depending on the options built into your ffmpeg binary, the typical options are H.264 (x264), VP9 (libvpx) or HEVC (x265).
There's various ways to encode videos (CRF 2-pass, VBR 2-pass), so which do you choose? Since you want a video of a particular size, you want VBR (CRF is if you want it to be of a particular quality and don't care about size). How do you calculate the bitrate? ffprobe tells you the duration of the video (in seconds), and target bitrate is calculated as:
target_rate_bits_per_second = target_size_bytes * 8 / duration_seconds
And then you use this bitrate as value for the -b:v option in each variable bitrate command I just linked to.
[edit] Assuming you have audio also, distribute the available bits between video and audio streams so that the total bitrate sum gives 20MB. Also assume a little bit of container overhead. [/edit]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
I'm trying to get the 10 last seconds of a video of which I dont know the length and then save those 10 seconds as a new video. Is this do able with the ffmpeg command prompt? And if so, how?
Thanks for the help
Greets
Use the -sseof input option. From the documentation:
-sseof position (input)
Like the -ss option but relative to the "end of file". That is negative values are earlier in the file, 0 is at EOF.
Example:
ffmpeg -sseof -10 -i input.mp4 output.mp4
Note that in stream copy mode (by using the -c copy output option or equivalent) the cut will occur on the nearest keyframe, so it may cut on your exact desired time. If more accuracy is needed you will have to re-encode instead of stream copy.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I'm using ffmpeg command below to convert video to a format of the defined scale and in order to hardcode the subtitles
Original syntax
ffmpeg -i "Original File.mov" -vf subtitles=Subtitles.srt -vf scale=1920:1080 \
-crf 12 "Final File".mov
Problem
I would like to expand this command further and:
ensure that the produce file is under 2GB
I would like to include additional parameters with advanced subtitle options, like setting the canvas size and fixing the potential delay
Side notes
I reckon that in case of predefining the file size the -crf 12 paramater will be redundant?
You can sort of set an upper limit on file size by defining an average bitrate e.g. -b:v 4000k and maximum bitrate -maxrate 5000k -bufsize 5000k, based on the duration of your video. as explained at FFmpeg wiki. You can use CRF in place of -b:v but you'll need to keep the maxrate and bufsize.
To apply multiple filters, you specify them in one filterchain, separated by commas, so:
-vf subtitles=Subtitles.srt,scale=1920:1080
As far as I know, those advanced subtitle optionsare applicable to subtitles presented as a regular input, not via the hardcoding subtitles filter
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
any one can give me a hind how to split video (and can be played in separeat parts) ,by split here I mean to split it to 4 parts for example and each part can be running (paying)
You could try using ffmpeg with the -ss option to seek to a point in the video and then use -vframes or -t to extract a specific number of frames or seconds, respectively.
See http://ffmpeg.org/ffmpeg-doc.html