Not your workmate
Not your workmate

Reputation: 45

Forcing a GStreamer pipeline to run in real time when encoding video

Folks,

I'm testing a computer vision element in a GStreamer pipeline; my element receives a live video stream from a webcam and runs some image processing code on it and saves the results to a database. When compiled with a debug flag, it also updates the video stream with some debugging marks. For debugging and development, I also run it from recorded videos.

My pipeline for live debugging from a recorded video (it works):

gst-launch filesrc location=test-16.avi ! h264parse ! ffdec_h264 ! people-heatmap db-path=test-16.sqlite ! xvimagesink

When I try a blind debug (i.e., save the data to the database, but with no video output), I do:

gst-launch filesrc location=test-16.avi ! h264parse ! ffdec_h264 ! people-heatmap db-path=test-16.sqlite ! fakesink sync=true

notice the sync=true in the fakesink. Without it, the code runs in a very high framerate and my vision algorithm gets lost (as it depends on the system clock to run).

But, when I try to re-encode the debug-marked video to a file (for later analysis) with:

gst-launch filesrc location=test-16.avi ! h264parse ! ffdec_h264 ! people-heatmap db-path=test-16.sqlite ! ffmpegcolorspace ! ffenc_mpeg4 ! ffmux_avi ! filesink location="debug-test-16.avi"

my code runs at a high frame rate (which, I suppose, is the maximum supported by my CPU).

I assumed it was the same problem I solved with the sync=true in the blind-debug case, but putting this option in the filesink element got me nothing.

So, how can I force the entire pipeline to run in real time (according to the video frame rate) when encoding the video to a file?

Thanks in advance,

Upvotes: 4

Views: 4802

Answers (1)

Pavel  Krasavin
Pavel Krasavin

Reputation: 175

I not sure I get it correctly, but you could try to use tee element ended with 'fakesink sync=true' to get similar effect.

So, it will be something like:

gst-launch filesrc location=test-16.avi ! tee name=t ! queue \
  ! h264parse ! ffdec_h264 ! people-heatmap db-path=test-16.sqlite \
  ! ffmpegcolorspace ! ffenc_mpeg4 ! ffmux_avi ! filesink location="debug-test-16.avi" t. \
  ! queue ! avidemux ! fakesink sync=true

Upvotes: 3

Related Questions