I have using ffmpeg to create short preview of videos...
$length = $length_video/5;
$ffmpeg_path." -i ".$content." -vf select='lt(mod(t\,".$length.")\,1)',setpts=N/FRAME_RATE/TB -af aselect='lt(mod(t\,".$length.")\,1)',asetpts=N/SR/TB -an ".$content_new.";
Actually this will create 5sec. video. and problem is because first frame is extracted from 0-1 sec.
There is any chance to skip first frame and extract next 5?
Problem is because first frame is actually useless because of video intro
This select filter should skip the first 5 frames:
$ ffmpeg -i input_file -vf select="gte(n\, 5)" ...
For timespan it's even easier. Here's how you skip the first 30 seconds:
$ ffmpeg -i input_file -ss 30 ...
To skip the first 30 seconds and keep the next 120 seconds of the original video, add -t:
$ ffmpeg -t input_file -ss 30 -t 120 ...
-ss time_off set the start time offset
-t duration record or transcode "duration" seconds of audio/video
Both -ss and -t take a time duration:
The following examples are all valid time duration:
5555 seconds
12:03:4512 hours, 03 minutes and 45 seconds
23.18923.189 seconds
None of these methods will be perfectly accurate due to the very mechanics of how video compression works (P and B frames can not stand on their own). ffmpeg will try to adjust accordingly:
Note that in most formats it is not possible to seek exactly, so ffmpeg will seek to the closest seek point before position. When transcoding and
-accurate_seekis enabled (the default), this extra segment between the seek point and position will be decoded and discarded. When doing stream copy or when-noaccurate_seekis used, it will be preserved.
Refer to the ffmpeg documentation for more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With