Search code examples
videovideo-streaminggstreamervideo-processing

How to speed up a video (make a time lapse) using gstreamer?


I'm looking to take a video of say 1 minute in length, and speed it up so that it is only say 10 seconds long (x6). I don't want to just change the display rate, I'd like to actually drop 5 out of 6 frames in this example to reduce the size and the length of the video.

How can I achieve this using the gstreamer command line?

I've tried using the videorate filter:

gst-launch-1.0 filesrc location=in.mp4 ! qtdemux name=demux demux.video_0 \
! queue ! h264parse ! avdec_h264 ! videoconvert ! videorate 
! video/x-raw,framerate=180/1 ! x264enc ! mp4mux ! filesink location=output.mp4

but no matter what parameters I pass, although frames are dropped, the length of the video stays the same.


Solution

  • Use the rate parameter to videorate.

    Here's your pipeline updated:

    gst-launch-1.0 filesrc location=in.mp4 ! qtdemux name=demux demux.video_0 \
    ! queue ! h264parse ! avdec_h264 ! videoconvert ! \
    \
    videorate rate=6 \
    \
    ! video/x-raw,framerate=180/1 ! x264enc ! mp4mux ! filesink location=output.mp4
    

    I think you want to reduce the frame rate at the same time:

    gst-launch-1.0 filesrc location=in.mp4 ! qtdemux name=demux demux.video_0 \
    ! queue ! h264parse ! avdec_h264 ! videoconvert ! \
    \
    videorate rate=6 \
    ! video/x-raw,framerate=30/1 ! \
    \
    x264enc ! mp4mux ! filesink location=output.mp4
    

    (I asked someone this question on the mailing list a few months back. Thanks should really go to them!)