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.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I have a FLAC audio file that I want to slice into 5 second segments. I don't need to resample or change the data in any way.
What tools/libraries are there for this? Should I be looking at ffmpeg? I actually want to create a HLS stream so a tool that would do that would be a bonus but if I can simply chunk the audio data I can create the playlist myself.
Use the segment muxer:
ffmpeg -i input.flac -f segment -segment_time 5 output_%03d.flac
In this example outputs will be named output_001.flac, output_002.flac, etc.
Add -reset_timestamps 1 if your need to reset timestamps at the beginning of each segment.
Since you asked there is also the HLS muxer, but that's a different topic from the question title.
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 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I was looking for a very long time and everywhere I look it's just like it was something obvious, a common knowledge. What does the "setpts" filter of ffmpeg do exactly? Why would you want to reset it to zero with setpts=PTS-STARTPTS ? Thanks.
PTS stands for Presentation TimeStamps. See What is video timescale, timebase, or timestamp in ffmpeg?
The setpts filter evaluates the expression and assigns the value as the timestamp for the current frame it is processing
e.g. setpts=2*N+5/TB where N is frame index starting from 0, and TB is the timebase of the stream. Let's say it is 1/1000, so each PTS unit is 1 millisecond.
So, for each frame, it would go as follows,
N expression New PTS New PTS time
0 2*0+5/(1/1000) 5000 5.000 sec
1 2*1+5/(1/1000) 5002 5.002 sec
2 2*2+5/(1/1000) 5004 5.004 sec
...
Filters which work upon multiple inputs sync by timestamp i.e. in overlay filter, the filter will overlay overlay input with timestamp 5.0 upon main input with PTS time 5.0. If the streams have different starting PTS, this can lead to unexpected output, so timestamps are reset so each stream starts from 0. Of course, if you have a custom sync in mind, then you would modify the setpts expr accordingly.
Another reason is that when a stream has a non-zero starting timestamp, ffmpeg may duplicate frames in -vsync cfr mode to plug the gap from timestamp 0 till that initial timestamp. This is only relevant in a few scenarios.
When trimming values you can often run into issues where the start isn’t from 0 anymore. So when using the -ss and -t flag you might want to be re setting that
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'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
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'