Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting video sped-up with FFmpeg to have the correct duration

Tags:

video

ffmpeg

I've been speeding up video using ffmpeg by following these instructions. For example, to speed up the video by 4 times, I run the following command:

ffmpeg -i vid.MP4 -filter:v "setpts=0.25*PTS" vid_fast.MP4

While the video is sped up by the indicated amount, the duration of the video (as indicated under its properties, and also when I play the video in VLC) remains the same as the original. For example, if vid.MP4 is initially 4 minutes, then vid_fast.MP4 is also 4 minutes, rather than being 1 minute long as expected. (The additional 3 minutes just consist of the video being frozen on the last frame.)

This is a bit of a hassle, since I need to delete the additional 3 minutes that I'm not interested in. Is there any way to avoid this?

Here is a bit more information on the version of ffmpeg I'm using:

ffmpeg version N-69060-gcd960c8 Copyright (c) 2000-2015 the FFmpeg developers
  built on Jan 14 2015 22:13:45 with gcc 4.9.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-lib
modplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw
b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --en
able-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
 --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-
libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enab
le-zlib
  libavutil      54. 16.100 / 54. 16.100
  libavcodec     56. 20.100 / 56. 20.100
  libavformat    56. 18.101 / 56. 18.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5.  7.101 /  5.  7.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Hyper fast Audio and Video encoder
like image 282
Vincent Tjeng Avatar asked Oct 31 '22 20:10

Vincent Tjeng


1 Answers

After speeding up the video just trim the output video which in your case is vid_fast.mp4 to the duration. Use following command

ffmpeg -i vid_fast.MP4 -vcodec copy -t 60 out_fast.mp4

It will create an output video of 1 minute.

like image 111
Ahmed_Faraz Avatar answered Jan 04 '23 14:01

Ahmed_Faraz