How to record RTSP video as a 1 fps-but-faster-playback timelapse?

My idea was:

  1. From rtspsrc source (IP camera) take only one frame per second using videorate.
  2. Scale frame down to save space using videoscale.
    3.Then, that one-per-second frame rate increase into 30fps (for example) again
    4 Re-encode it into .mp4 file.

End result would be 30fps video where every frame is actually 1 second apart from original recording point of view, i.e. fast “timelapse” video.

But what I get is just 30 frames copied of that single frame per second, i.e. just bigger file, without “timelapse” speedup…

My current pipeline that just takes one frame per second and re-encodes it is:

timeout -s SIGINT 10s gst-launch-1.0 -e rtspsrc location="rtsp://x:y@host:554/Streaming/Channels/101" ! rtph264depay ! h264parse ! queue ! avdec_h264 ! queue ! videorate ! video/x-raw,framerate=1/1 ! videoscale ! video/x-raw,width=426,height=240 ! queue ! videoconvert ! video/x-raw,format=NV12 ! vah264enc ! queue ! h264parse ! qtmux ! filesink location=output.mp4

Adding videorate ! video/x-raw,framerate=30/1 does not help, as it just copies that single frame 30 times, but it does not change it’s PTS (or whatever?).

Is it possible to make that one frame playback faster, as if it’s interval was not 1 second but 1/30 seconds?

Thanks!

Not sure, but you may try rate property of element videorate:

# Normal
timeout -s SIGINT 10s  gst-launch-1.0 -e rtspsrc location=rtsp://127.0.0.1:8554/test ! rtph264depay ! h264parse ! avdec_h264 ! x264enc ! h264parse ! qtmux ! filesink location=test_rate_1.mp4

# 30x speedup timelapse
timeout -s SIGINT 10s  gst-launch-1.0 -e rtspsrc location=rtsp://127.0.0.1:8554/test ! rtph264depay ! h264parse ! avdec_h264 ! videorate rate=30 ! x264enc ! h264parse ! qtmux ! filesink location=test_rate_30.mp4

Note that the latter case will only have a few frames (10 seconds for 30 fps rtsp source = 300 frames divided by 30 = 10 frames).

1 Like

Yep, videorate rate=30 works, thanks!