Should I send video and audio separately when streaming with gstreamer? Can't I send video and audio as an one thing(like mp4 or avi)?
You can stream audio/video together for example with mpegtsmux and send it via udp.. you can do this with any container.. also with for example mkv but you must catch the beginning of stream on the client side because there are the metadata necessary to begin the playback..
So the idea is - encode, mux, chop/merge (..payload), stream via udp/tcp ..
gst-launch-1.0 audiotestsrc ! voaacenc ! mpegtsmux name=mux videotestsrc ! x264enc ! h264parse ! mux. mux. ! rtpmp2tpay ! udpsink host=127.0.0.1 port=6666
You can open in vlc as stream udp://#:6666
There is also HLS (avmux_hls) and other protocols suitable for streaming - though I never used them..
Related
Hardware & Software: Raspberry Pi 4, IP camera, Raspbian Buster, Gstreamer 1.14.1 (from repository). Raspberry and camera are on the local network.
I'm trying to run the RTSP video stream with the following pipeline:
gst-launch-1.0 rtspsrc location='rtsp://web_camera_ip' ! rtph264depay ! h264parse ! v4l2h264dec ! autovideosink
Within one minute, the playback stops.
Log:
0:00:00.681624278 1491 0xb4810980 FIXME default gstutils.c:3981:gst_pad_create_stream_id_internal:<fakesrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
Progress of execution: (request) Sent PLAY request
0:00:01.155264612 1491 0xb1507fb0 WARN v4l2 gstv4l2object.c:4186:gst_v4l2_object_probe_caps:<v4l2h264dec0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: An inadmissible argument
0:00:01.166871436 1491 0xb1507fb0 WARN v4l2 gstv4l2object.c:4186:gst_v4l2_object_probe_caps:<v4l2h264dec0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: An inadmissible argument
0:00:01.170107746 1491 0xb1507fb0 FIXME basesink gstbasesink.c:3145:gst_base_sink_default_event:<autovideosink0-actual-sink-xvimage> stream-start event without group-id. Consider implementing group-id handling in the upstream elements
0:00:01.174576265 1491 0xb1507fb0 WARN v4l2videodec gstv4l2videodec.c:808:gst_v4l2_video_dec_decide_allocation:<v4l2h264dec0> Duration invalid, not setting latency
0:00:01.211967620 1491 0xb48105b0 WARN v4l2bufferpool gstv4l2bufferpool.c:1189:gst_v4l2_buffer_pool_dqbuf:<v4l2h264dec0:pool:src> Driver should never set v4l2_buffer.field to ANY
This line appears at the moment of stopping:
0:00:13.102438914 1491 0xb48105b0 WARN v4l2allocator gstv4l2allocator.c:1349:gst_v4l2_allocator_dqbuf:<v4l2h264dec0:pool:src:allocator> V4L2 provided buffer has bytesused 0 which is too small to include data_offset 0
What I tried (it didn't help solve the problem):
Replacing autovideosink with fakesink
Replacing v4l2h264dec with avdec_h264_mmal
Various rtspsrc parameters
Playback with playbin
Error does not appear if decoder is replaced with fakesink:
gst-launch-1.0 rtspsrc location='rtsp://web_camera_ip' ! rtph264depay ! h264parse ! fakesink
Additional information:
My camera displays the time (hours, minutes, seconds) above the image. Playback is always stopped at a certain value of seconds. When the camera restarts, this value changes randomly - 17, 32, 55... Changing the time in the camera does not solve the problem.
VLC player on Raspberry plays stream from this camera without any problems
Gstreamer plays local h264 files without any problems
Gstreamer plays RSTP TV channel broadcasting from the Internet without any problems.
I also tried to play substream (low resolution) from IP camera and RTSP stream from smartphone (IP Webcam application). The same problem appears.
When running this project (on SD card) on Raspberry 3 , the problem remains.
On Raspberry 3 with Raspbian Stretch and Gstreamer 1.10 from repository there was no problem.
Thank you for the answers!
The problem was in my local network. RTSP stream from any device is periodically interrupted for a split second. When using VLC player it is not visible, because it instantly restarts the broadcast. In this case Gstreamer interrupts stream and generates an error message.
I've connected my IP camera directly to Raspberry over ethernet, everything works fine.
Broadcast over the Internet is also stable.
I was having this exact same issue. Luckily it appears fixed with gstreamer 1.16.2. I built using a variation of the script at
https://github.com/PietroAvolio/Building-Gstreamer-Raspberry-Pi-With-SRT-Support/blob/master/gstreamer-build.sh
Using 1.16.2 it just keeps on going and doesn't hang.
I am a beginner in Gstreamer.
My objective is to record a video at 1080p resolution at 30 fps in H264 format from my Raspberry pi camera using Gstreamer following pipeline:
gst-launch-1.0 -v v4l2src device=/dev/video0 ! capsfilter
caps="video/x-raw, width=1920,height=1080,framerate=30/1" ! videoflip
method=rotate-180 ! gst-debug ! videoconvert ! videorate ! x264enc! avimux
! filesink location=test_video.h264
After I ran the above pipeline,
I did not get any kind of error and recorded video shows 1080p and 30fps but frames are dropping heavily.
Is this right pipelining or not?
Am I missing any elements in this pipeline?
x264enc is a software encoder and uses a lot of CPU power. Raspberry pi has an OpenMax hardware h264 encoder which can be accessed with gstreamers gst-omx bindings. You can use the hardware encoder with inserting an omxh264enc element instead of x264enc element.
I am using the omxh264enc to encode USB camera source on raspberry pi and stream the video, I would like to control the keyframe interval, but could not figure out how to, I currently
using the following bash script :
gst-launch-1.0 v4l2src ! 'video/x-raw, width=640 ,hight=480 ,framerate=30/1' ! videoconvert ! omxh264enc target-bitrate=400000 control-rate=variable ! fdsink
The idea is to mimic the raspivid function but with USB camera source instead
Thanks :)
Does the omxh264enc element has the iframeinterval property? I thought it did - or something very similar. However I believe OMX is just an API, the hardware may not fully support all features that are exposed.
I have a C# code developed to stream a video file encoded to raw H264 and stream using UDP protocol when I receive that stream using omxplayer it played about 30s and then stopped and display 'have a nice day'. But I can receive that stream using ffplay and vlc player (in windows) without any problem.
Then i tried to stream using vlc player. And also i got same issue. Stream stopped and displayed 'have a nice day'.If any one can help me to figure this out, it is very grateful.
code used to receive stream in omxplayer
omxplayer udp://224.1.1.1:1234
I have given a screen shot of omxplayer when receiving the stream. According to this the buffer size of the omxplayer becomes 0 after playing some time. I tried changing the url of the stream as given below.
omxplayer -s udp://224.1.1.1:1234?overrun_nonfatal=1
Then that problem was alright. But the stream was not smoothly running. Can you suggest any better solution for this problem.
Thank You!
I am developing a live video streaming application on Nokia N97. I have video and audio buffer in H.263 and AMR format respectively (from live camera source) and want to stream these to some sever that can broadcast it with RTSP. That RTSP broadcast server will be on internet. I need to know which RTSP servers can do this job that can receive audio and video streams in some format (like RTP) as input and broadcast it with RTSP.
Thanks for any idea and suggestions.
Jawad
Darwin can easily do it.
http://dss.macosforge.org/