Gstreamer: how to ouput mp4 video into /dev/video0? - gstreamer

I found that for .avi files
gst-launch-1.0 -v filesrc location=test.avi ! avidemux ! decodebin !
videoconvert ! "video/x-raw,format=YUY2" ! v4l2sink device=/dev/video0
and this one ouptput screen into /dev/video0 :
gst-launch-1.0 -v ximagesrc startx=1 starty=1 endx=320 endy=240 !
videoconvert ! "video/x-raw,format=YUY2" ! v4l2sink device=/dev/video0
Any idea on how to use Gstreamer to input a .mp4 file instead of .avi file ?

gst-launch-1.0 -v filesrc location=test.mp4 ! qtdemux ! decodebin ! videoconvert ! "video/x-raw,format=YUY2" ! v4l2sink device=/dev/video0
Since MP4 files do not have a concept of a fixed frame rate you have to add a video rate element and set a desired frame rate (may depend on the output device).
gst-launch-1.0 -v filesrc location=test.mp4 ! qtdemux ! decodebin ! videorate ! videoconvert ! "video/x-raw,format=YUY2,framerate=30/1" ! v4l2sink device=/dev/video0

Related

Gstreamer rtsp to HLS, set EXT-X-PROGRAM-DATE-TIME tag in m3u8 playlist file

I'm using Gstreamer to convert an rtsp stream to HLS. I want to set the EXT-X-PROGRAM-DATE-TIME tag in the m3u8 playlist file. Is this possible? I'm using this terminal command but ideally I want to write a c program which does the same thing.
gst-launch-1.0 -v -e rtspsrc protocols=tcp \
location=rtsp://rtspadress \
do-timestamp=true ! queue ! rtph264depay ! h264parse config-interval=-1 ! mpegtsmux \
! hlssink location="%06d.ts" target-duration=5

No element "ffmpegcolorspace" in GStreamer

While executing the following command,
gst-launch-1.0 filesrc location=Wildlife.wmv ! decodebin ! queue ! ffmpegcolorspace ! autovideosink dec. ! queue ! audioconvert ! audioresample ! autoaudiosink
I Get the error as follows.
ERROR GST_PIPELINE grammar.y:716:priv_gst_parse_yyparse: no element "ffmpegcolorspace"
ERROR GST_PIPELINE grammar.y:801:priv_gst_parse_yyparse: link has no sink [source=#0000000003066F90]
ERROR GST_PIPELINE grammar.y:801:priv_gst_parse_yyparse: link has no source [sink=#000000000306B060]
ERROR GST_PIPELINE grammar.y:1138:priv_gst_parse_launch: No src-element named "dec" - omitting link
WARNING: erroneous pipeline: no element "ffmpegcolorspace"
What is the problem here?
A few things:
In gstreamer-1.0, ffmpegcolorspace was renamed to videoconvert.
You need to give your decodebin the name you want to refer to it later. Add name=dec to be able to refer to it when linking the audio branch.
Also, you might want to consider just using playbin if you just need playback. It will assemble the pipeline for you and will support multiple formats automatically.

Playing mpeg2ts with Gstreamer-1.0

I am trying to play a .ts file with Gstreamer-1.0 as well as gst-omx have been successfully installed .
Try to play ts video using below command line format but failed to play.
test#test-Gardenia:~/Videos$ gst-launch-1.0 -v filesrc location= mpeg2.ts ! tsdemux ! mpegvideoparse ! omxmpeg2dec ! videoconvert ! ximagesink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstTSDemux:tsdemux0: Internal data stream error.
Additional debug info:
mpegtsbase.c(1347): mpegts_base_loop (): /GstPipeline:pipeline0/GstTSDemux:tsdemux0:
stream stopped, reason not-linked
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
/GstPipeline:pipeline0/GstTSDemux:tsdemux0.GstPad:audio_0044: caps = "NULL"
Freeing pipeline ...
Tried below command also but not did not work.
test#test:~/Videos$ gst-launch-1.0 filesrc location= mpeg2.ts ! tsdemux ! tsparse ! omxmpeg2dec ! videoconvert ! ximagesink
WARNING: erroneous pipeline: could not link mpegtsparse2-0 to omxmpeg2videodec-omxmpeg2dec0
Can any one help me how to play .ts file with mpeg2 codec format using gstreamer

Problems streaming webcam over UDP with gstreamer as MJPEG stream

First, I have read the following thread, but I want to harness the webcam hardware JPEG compression as opposed to software h264 compression.
Second, I tested the following pipeline and it works:
gst-launch-1.0 -v v4l2src device=/dev/video1 ! 'image/jpeg,width=640,height=480,videorate=8/1' ! jpegdec ! xvimagesink
Then I tried similar pipeline but with udpsink at the end:
gst-launch-1.0 -v v4l2src device=/dev/video1 ! 'image/jpeg,width=640,height=480,videorate=8/1' ! rtpjpegpay ! udpsink host=127.0.0.1 port=1234
Then I tried to play this stream:
gst-launch-1.0 -v udpsrc port=1234 ! "application/x-rtp, payload=96" ! rtpjpegdepay ! jpegdec ! xvimagesink
And it failed with the following errors:
/GstPipeline:pipeline0/GstJpegDec:jpegdec0.GstPad:sink: caps =
image/jpeg, framerate=(fraction)0/1, width=(int)640, height=(int)480
** (gst-launch-1.0:10761): CRITICAL **: gst_adapter_push: assertion 'GST_IS_BUFFER (buf)' failed
** (gst-launch-1.0:10761): CRITICAL **: gst_jpeg_dec_fill_input_buffer: assertion 'dec->current_frame_map.data
!= NULL' failed
Any suggestions?

What is the reason for giving "internal data flow error" message in gstreamer?

When i tried this command:
**gst-launch-0.10 -v rtspsrc location=rtsp://127.0.0.1:8554/test
caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,
encoding-name=(string)H264" ! rtpmp2tdepay ! mpegtsdemux ! ffdec_h264 ! autovideosink**
I got error as:
**ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc0:
Internal data flow error.**
What is the main reason for giving error as "Internal data flow error" in gstreamer ?
There are many potential reasons for internal data flow error. To encounter the problematic place, just connect a fakesink element step by step and try.
gst-launch-0.10 -v rtspsrc location=rtsp://127.0.0.1:8554/test caps="application/x-rtp,media=(string)video,clock-rate=(int)90000, encoding-name=(string)H264" ! fakesink
gst-launch-0.10 -v rtspsrc location=rtsp://127.0.0.1:8554/test caps="application/x-rtp,media=(string)video,clock-rate=(int)90000, encoding-name=(string)H264" ! rtpmp2tdepay ! fakesink
gst-launch-0.10 -v rtspsrc location=rtsp://127.0.0.1:8554/test caps="application/x-rtp,media=(string)video,clock-rate=(int)90000, encoding-name=(string)H264" ! rtpmp2tdepay ! mpegtsdemux ! fakesink
...
It is the unfortunate case of something did not work. Rerun the command with the environment variable GST_DEBUG="*:2" to see all warnings.