How to pause a live source in pipeline?

Neicole 932194884 at qq.com
Thu Jul 31 04:24:32 PDT 2014


Hello guys:    I have a problem about how to pause a live source pipeline.(Gstreamer Version 1.2.0)
    I really have tried many times and searched many information from internet, but I still don't know how to do. So, I want to ask for help here.
    First, my pipeline is show as follows:
    gst-launch-1.0   \
            mpegtsmux name=mux \
            !  filesink location="/root/test/pause_test.ts" \
            \
            rtspsrc name=src  lanteny=200 location="rtsp://myip/stream"  \
            src. \  
            ! rtph264depay \
            ! queue  leaky=2  ‍\
            ! avdec_h264  \
            ! videorate  \
            ! videoscale \
            ! capsfilter caps="video/x-raw, format=(string)I420, width=1024, height=768, framerate=25/1"   \
            ! x264enc  tune=4 bitrate=4096 \
            ! video/x-h264, profile="high"  \
            ! mux. 
            src. \
            ! fakesink name=audiofake


    Now, I want to record a file (MP4 or ts) via pipeline from rtspsrc to filesink plugin, the question is how can I pause when the file is recording.


    First,  I have tried to set pipeline GST_STATE_PAUSED‍ state directly when it is in state GST_STATE_PLAYING. And then, I can see GST_MESSAGE_STATE_CHANGED Bus Call Message, pipeline element and elements in pipeline states are all change to  GST_STATE_PAUSED, meanwhile, rtspsrc element occour an Error about " 无法从资源阅读(English meaning is: Unable to read from resource)" and  " 无法从资源写入(English meaning is: Unable to write from resources)" . After that, I set pipeline state to GST_STATE_PLAYING and the file can be recorded continue. Then, I set pipeline state to GST_STATE_NULL. Finally, I tried to play the recorded file. The file can play in ubuntu but the pausing part is still in the file and the pausing part has no image. Besides, I try to set queue element leaky attribute to 0 and retry the steps above. There's something different, the file cannot recorded again after setting pause. Actually, I don't know why, I just try to set it as some guy said in the internet. I think it is because queue leaky attribute can make the data flow continue that the pipeline not died.‍


     Secondly, somebody said I should set the segment in filesink element. So, I started to follow the ideas, I get the src-pad from queue first, set it to be leaky=downstream and block the src-pad via gst_pad_add_probe(...)‍. Then, I try to pause the pipeline and remember the probe buffer pts as pause timestamp in the probe callback function, the video sub-pipeline paused but the audio sub-pipeline and rtspsrc element was still in playing state. After that, if I wasn't block(lock) the probe function to make it finish soon, the pipeline changed back to playing state automatically soon. So, I pause the pipeline through used a mutex to lock the function. When I want to continue recording the file, I unlock the probe function and the pipeline started again automatically. At the same time, I got the rtph264depay-src pad and block it via gst_pad_add_probe(...). I remember the probe buffer pts as continue timestamp. Last,  I sent event  and set segment by gst_segment_to_stream_time(...) to filesink-sink, but there was no effects. I don't know how to set a right segment in live pipeline, is there any examples?‍


      Actually, I want to know what's wrong with my step and if my steps are right, what details I should pay attention.  Is there some examples to my question?
      PS: My source code will be sent by attachment. ‍


Regards‍,
Neicole
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20140731/d998a66e/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_pause.cpp
Type: application/octet-stream
Size: 22907 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20140731/d998a66e/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_pause.h
Type: application/octet-stream
Size: 1618 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20140731/d998a66e/attachment-0003.obj>


More information about the gstreamer-devel mailing list