[FFmpeg-user] Decimating video frames to shorten movie
Rae, Philip John
prae at lanl.gov
Tue Jul 5 22:52:25 CEST 2016
Henk, many thanks.
For some reason my installation balked at the lbx264 part of the command despite the lbx264 library being used successfully elsewhere.
ffmpeg -r 5timesoriginalspeed -i source.ext -c:v lbx264 -c:a copy -r originalspeed resultwith20%oforiginalframes.ext
However, the following worked very well since I needed the movies as a small portable mp4 or .mov anyway.
ffmpeg -r 72 -i in.avi -pix_fmt yuv420p -r 12 out.mp4
There is no sound in typical high-speed movies and so that very complex problem of dealing with a decimated audio track is not an issue.
On Jul 3, 2016, at 16:54, Henk D. Schoneveld <belcampo at zonnet.nl> wrote:
> On 04 Jul 2016, at 00:45, Henk D. Schoneveld <belcampo at zonnet.nl> wrote:
>> On 03 Jul 2016, at 23:28, Rae, Philip John <prae at lanl.gov> wrote:
>>> I am new to ffmpeg and I have a question about ‘decimating’ movies to remove unwanted frames. I have a high speed movie with too many frames (too little motion between frames) that I want to remove 4 in 5 frames (for instance) and resave the shorter one (fewer frames and a shorter duration movie).
>>> I thought the following would work after some research
>>> ffmpeg -y -i Test_too_slow.avi -filter:v "select='not(mod(n\,5))'” out.avi
>>> but it keeps the duration of the movie the same as the input rather than a fifth as long and it appears to do this by repeating frames. This is obviously not what I want. The original had 700 frames and played at 12 fps. 700/5 is 140. Indeed looking at the output below, the number of processed frames is 141, however, the duration is still 58 seconds rather than 11.6.
>>> I have tried playing with the -r and -framerate options, but this appeared to do nothing useful in this case.
>>> I also tried post processing the output
>>> ffmpeg -i out.avi -filter:v "setpts=0.2*PTS" out2.avi
>>> but that worked poorly since the movie became very jumpy as if the extraction did not rip out evenly spaced extra dummy frames installed by the previous operation but a variable frame each few cycles.
>>> I am sure there is a simple fix, but it escapes me at the moment.
>> What works: ffmpeg -r 5timesoriginalspeed -i source.ext -c:v lbx264 -c:a copy -r originalspeed resultwith20%oforiginalframes.ext
>> frame= 7942 fps= 69 q=-1.0 Lsize= 92340kB time=00:26:27.16 bitrate= 476.6kbits/s dup=0 drop=31758
>> Resulting 7942 frames and dropped 31758. It obviously plays at 5 times the speed of the original.
> Sound isn’t synced that’s another hurdle to be solved though. Audio is unsynced and undecimated.
>>> Many thanks
>>> ffmpeg -y -i Test_too_slow.avi -filter:v "select='not(mod(n\,5))'" out.avi
>>> ffmpeg version 3.1.1-tessus Copyright (c) 2000-2016 the FFmpeg developers
>>> built with Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
>>> configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --as=yasm --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-version3 --disable-ffplay --disable-indev=qtkit --disable-indev=x11grab_xcb
>>> libavutil 55. 28.100 / 55. 28.100
>>> libavcodec 57. 48.101 / 57. 48.101
>>> libavformat 57. 41.100 / 57. 41.100
>>> libavdevice 57. 0.101 / 57. 0.101
>>> libavfilter 6. 47.100 / 6. 47.100
>>> libswscale 4. 1.100 / 4. 1.100
>>> libswresample 2. 1.100 / 2. 1.100
>>> libpostproc 54. 0.100 / 54. 0.100
>>> Input #0, avi, from 'Test_too_slow.avi':
>>> Duration: 00:00:58.27, start: 0.000000, bitrate: 138830 kb/s
>>> Stream #0:0: Video: rawvideo, bgr24, 800x600, 138993 kb/s, 12.05 fps, 12.05 tbr, 12.05 tbn, 12.05 tbc
>>> [avi @ 0x7fc38a00fc00] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
>>> Output #0, avi, to 'out.avi':
>>> ISFT : Lavf57.41.100
>>> Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 800x600, q=2-31, 200 kb/s, 12.05 fps, 12.05 tbn, 12.05 tbc
>>> encoder : Lavc57.48.101 mpeg4
>>> Side data:
>>> cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
>>> Stream mapping:
>>> Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
>>> Press [q] to stop, [?] for help
>>> frame= 141 fps=0.0 q=4.5 Lsize= 956kB time=00:00:58.18 bitrate= 134.5kbits/s speed= 134x
>>> video:934kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.362345%
"You are entitled to your own opinion, but you are not entitled to your own facts.", Daniel Patrick Moynihan (1927-2003)
PO Box 1663, MS-J564
Tel:- 505 667 4436
Fax:- 505 667 9809
e-mail:- prae at lanl.gov
More information about the ffmpeg-user