How to save rtsp video stream with correct framerate

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to save rtsp video stream with correct framerate

sulli_xue
Hello everyone!
I've now used gstreamer to receive a live camera video stream successfully.
I want to save the rtsp video stream as a video file which could be processed by opencv later.
My gstreamer pipeline is "gst-launch-1.0 rtspsrc location=rtsp://admin:admin12345@192.168.1.88:554/h264/ch33/main/av_stream latency=0 ! tee name=t ! queue ! rtph264depay ! h264parse ! mpegtsmux ! filesink location=\"test.avi\" t. ! queue ! decodebin ! videoconvert ! xvimagesink
"
I can open test.avi by vlc successfully.
And now my question is why when I use opencv's functions(cvGetCaptureProperty,CV_CAP_PROP_FRAME_COUNT...) to get the information of the saved video file named "test.avi",it's framerate is 180000 and it's framenum is also a very big number. It is impossible because the live rtsp video stream's framerate is 25fps.Could you please fix the problem?

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to save rtsp video stream with correct framerate

sulli_xue
Now I know how to save video file with correct framerate,the pipeline is as follow:"gst-launch-1.0 rtspsrc do-timestamp=true is_live=true location=rtsp://admin:admin12345@192.168.1.64:554/h264/ch33/main/av_stream latency=0 ! tee name=t ! queue ! application/x-rtp, media=video,framerate=25,encoding-name=H264 ! rtph264depay ! h264parse config-interval=1 ! matroskamux ! filesink location=\"test.mkv\" t. ! queue ! decodebin ! videoconvert ! xvimagesink"
Just replace "mpegtmux" with "matroskamux" can get correct framerate number 25 by cvGetCaptureProperty(capture,CV_CAP_PROP_FPS).However cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_COUNT) still get wrong number and cvSetCaptureProperty(capture,CV_CAP_PROP_POS_FRAMES) cannot goto correct position.Could someone help me?Please~
Reply | Threaded
Open this post in threaded view
|

Re: How to save rtsp video stream with correct framerate

Michael MacIntosh

Hey,

I'm not sure what framerate you are getting and what you are expecting, but I am going to assume because it is an RTP source, and they can be unreliable, porbably need to drop/duplicate frames.

I would try to use the videorate element:

https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-videorate.html

It looks like it only accepts raw frames, so you might need to do a full transcode to duplicate frames.

So I would try something like this (I put my changes in red):


"gst-launch-1.0 rtspsrc do-timestamp=true is_live=true
location=<a class="moz-txt-link-freetext" href="rtsp://admin:admin12345@192.168.1.64:554/h264/ch33/main/av_stream">rtsp://admin:admin12345@192.168.1.64:554/h264/ch33/main/av_stream
latency=0 ! tee name=t ! queue ! application/x-rtp,
media=video,framerate=25,encoding-name=H264 ! rtph264depay ! decodebin ! videorate ! x264enc ! h264parse
config-interval=1 ! matroskamux ! filesink location=\"test.mkv\" t. ! queue
! decodebin ! videoconvert ! xvimagesink"


Hope that helps!

Cheers,
Michael.


On 6/3/2017 12:59 AM, sulli_xue wrote:
Now I know how to save video file with correct framerate,the pipeline is as
follow:"gst-launch-1.0 rtspsrc do-timestamp=true is_live=true
location=<a class="moz-txt-link-freetext" href="rtsp://admin:admin12345@192.168.1.64:554/h264/ch33/main/av_stream">rtsp://admin:admin12345@192.168.1.64:554/h264/ch33/main/av_stream
latency=0 ! tee name=t ! queue ! application/x-rtp,
media=video,framerate=25,encoding-name=H264 ! rtph264depay ! h264parse
config-interval=1 ! matroskamux ! filesink location=\"test.mkv\" t. ! queue
! decodebin ! videoconvert ! xvimagesink"
Just replace "mpegtmux" with "matroskamux" can get correct framerate number
25 by cvGetCaptureProperty(capture,CV_CAP_PROP_FPS).However
cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_COUNT) still get wrong number
and cvSetCaptureProperty(capture,CV_CAP_PROP_POS_FRAMES) cannot goto correct
position.Could someone help me?Please~




--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-to-save-rtsp-video-stream-with-correct-framerate-tp4683176p4683188.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to save rtsp video stream with correct framerate

sulli_xue
Hi Michael MacIntosh!Thank you for your kind reply! I've tried your pipeline and unfortunately the result was not good,xvimage's window was frozen with only one static picture and the test.mkv was black with no pictures.Is there something wrong?


------------------ Original ------------------
From: "Michael MacIntosh [via GStreamer-devel]";
Date: Tuesday, Jun 6, 2017 2:51 AM
To: "θ–›ι™θΏœ"<[hidden email]>;
Subject: Re: How to save rtsp video stream with correct framerate

Hey,

I'm not sure what framerate you are getting and what you are expecting, but I am going to assume because it is an RTP source, and they can be unreliable, porbably need to drop/duplicate frames.

I would try to use the videorate element:

https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-videorate.html

It looks like it only accepts raw frames, so you might need to do a full transcode to duplicate frames.

So I would try something like this (I put my changes in red):


"gst-launch-1.0 rtspsrc do-timestamp=true is_live=true
location=<a class="moz-txt-link-freetext" href="rtsp://admin:admin12345@192.168.1.64:554/h264/ch33/main/av_stream">rtsp://admin:admin12345@192.168.1.64:554/h264/ch33/main/av_stream
latency=0 ! tee name=t ! queue ! application/x-rtp,
media=video,framerate=25,encoding-name=H264 ! rtph264depay ! decodebin ! videorate ! x264enc ! h264parse
config-interval=1 ! matroskamux ! filesink location=\"test.mkv\" t. ! queue
! decodebin ! videoconvert ! xvimagesink"


Hope that helps!

Cheers,
Michael.


On 6/3/2017 12:59 AM, sulli_xue wrote:
Now I know how to save video file with correct framerate,the pipeline is as
follow:"gst-launch-1.0 rtspsrc do-timestamp=true is_live=true
location=<a class="moz-txt-link-freetext" href="rtsp://admin:admin12345@192.168.1.64:554/h264/ch33/main/av_stream">rtsp://admin:admin12345@192.168.1.64:554/h264/ch33/main/av_stream
latency=0 ! tee name=t ! queue ! application/x-rtp,
media=video,framerate=25,encoding-name=H264 ! rtph264depay ! h264parse
config-interval=1 ! matroskamux ! filesink location=\"test.mkv\" t. ! queue
! decodebin ! videoconvert ! xvimagesink"
Just replace "mpegtmux" with "matroskamux" can get correct framerate number
25 by cvGetCaptureProperty(capture,CV_CAP_PROP_FPS).However
cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_COUNT) still get wrong number
and cvSetCaptureProperty(capture,CV_CAP_PROP_POS_FRAMES) cannot goto correct
position.Could someone help me?Please~




--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-to-save-rtsp-video-stream-with-correct-framerate-tp4683176p4683188.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



If you reply to this email, your message will be added to the discussion below:
http://gstreamer-devel.966125.n4.nabble.com/How-to-save-rtsp-video-stream-with-correct-framerate-tp4683176p4683197.html
To unsubscribe from How to save rtsp video stream with correct framerate, click here.
NAML