Corrupted video frames when streaming H264 over RTSP - raspberry-pi

When I stream H264 video over RTSP and use VLC to view the video feed, the video feed is corrupted (partly green but moving objects are still detected). However, if I stop the VLC and restart it again, the video feed is no longer corrupted. Why is it so, and how can I remedy this issue? Thanks!
The H264 is coming natively from a USB camera into a Raspberry Pi. Below is the code within the crontab of the Pi for launching the g-streamer and RTSP server.
#reboot bash /home/pi/gst-rtsp-server/examples/test-launch '( v4l2src device=/dev/video1 ! video/x-h264, width=320, height=240, framerate=20/1 ! h264parse ! rtph264pay name=pay0 pt=98 config-interval=10 )'
The Raspberry Pi is connected over a network. I am using VLC on another computer to view the video feed.
vlc rtsp://10.146.0.57:8554/test
If I reboot the Pi, the video feed on the VLC will be corrupted. I can still see moving objects in the video feed but there will be green and purple pixels all over.
However, if I close the VLC and start VLC again, the issue is gone. The video feed is clean.
The output of VLC:
[0000557c34211570] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
Created new TCP socket 35 for connection
libEGL warning: DRI2: failed to authenticate
libEGL warning: DRI2: failed to authenticate
[00007fd9b800df20] main decoder error: buffer deadlock prevented

Please elaborate - you restart the Pi but keep the VLC connection running? Doesn't it disconnect because the RTSP server goes away? VLC should reconnect after the Pi restarts. If it does not do this this may be a problem.
If a new H.264 bitstream is initiated by the Pi it is logically different from what it previously has send. If the VLC does not restart but just continues decoding this stream it may get "confused" resulting in decoding error (relying on wrong reference pictures).
H.264 has a temporal dependency for frames. MJPEG does not have this - each frame can be decoded by it self. Therefore you will not see the issue to be present here.

Related

Receive a live video stream from a raspberry pi cam on a flutter application

I have a gstreamer server that streams a flux video from a raspberry pi with the command:
raspivid -t 0 -w 1920 -h 1080 -fps 30 -b 2000000 -awb fluorescent -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=0.0.0.0 port=5000
I am trying to use vlc as a client to get the stream,but i can't get it to work even with an sdp file. I want to get it to work with vlc because flutter have a vlc pluginn. If i can get it with vlc, i can get it on my flutter mobile application with th vlc plugin. I am a beginner with gstreamer and flutter. So can you help me to get the stream with vlc ? If no, can you help me to find another way to get it on my flutter application? I think this stream is RTP over TCP. I want to confirm it because i am confusing the terms rtp rtsp rtcp ? Can someone help me to understand them a little more? If i use the url tcp:#x.x.x.x:5000 with vlc i don't get an error,but i have a blank screen?
Best regards,
Safouane

Raspberry Pi: Sound Replay works with HDMI and omxplayer but not with Chrome Browser for youtube Videos

The audio via HDMI for Youtube.com videos (played via the chrome browser) was working on my raspberry pi 4/raspbian until I started experimenting with a microphone for zoom meetings. (This USB microphone seems to be working now.).
Now, however, I can no longer hear any audio when playing youtube videos.
We can hear sound via the HDMI with this command:
sudo aplay /usr/share/sounds/alsa/Front_Center.wav
I also discovered that I can record and playback sound (via HDMI) with audacity and omxplayer. This works:
omxplayer -o hdmi hello.wav
I tried making HDMI the default:
amixer cset numid=3 2
This did not seem to help.
I was surprised I did not see my audio output. Should numbid=3 be the 'Mic Capture Volume'? I was expecting it to be the control for my HDMI audio.
amixer controls | sort
numid=1,iface=PCM,name='Capture Channel Map'
numid=2,iface=MIXER,name='Mic Capture Switch'
numid=3,iface=MIXER,name='Mic Capture Volume'
numid=4,iface=MIXER,name='Auto Gain Control'
numid=5,iface=CARD,name='Keep Interface'
uname -a says:
Linux raspberrypi 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux
Can anyone help me play you tube vidoes (with audio!) again via my HDMI port?
Thank you
Siegfried
Problem was mostly solved by re-installing raspberian OS.
HDMI Speakers and USB Microphone work for audacity sound editor.
HDMI speakers work with Chrome for YouTube.
USB Microphone still does not work for Zoom meetings. Has anyone got this working?
Thanks
Siegfried

System error 111 (connection refused) , Failed to connect

I'm trying to stream video via RTSP in my ubuntu PC.
The video file to be streamed big_buck_bunny_h264.mov is located in following location of my PC :home/user/Downloads/
I'm using gstreamer to stream the video.
Below is the gstreamer command I'm trying :
gst-launch-1.0 rtsprc
location=rtsp://127.0.0.1:9000/home/user/Downloads/big_buck_bunny_h264.mov
latency=0 ! decodebin ! autovideosink
But I'm getting following error on terminal:
System error 111 (connection refused) , Failed to connect
Also I tried streaming via RTSP using VLC player . (open VLC -> Media -> Open Network Streaming -> Enter the url -> Play )
Im getting following error message:
Connection Failed, VLC could not connect to 127.0.0.1:9000. VLC is unable to open the URL.
From the above 2 scenarios (Gstreamer and VLC) , I assume there is something issue with the networking/network interface.
The Current OS I'm using is guest OS Ubuntu 14.04. (I'm acessing ubuntu via VMware Player from windows PC). Network is bridged between windows and ubuntu.
So is this the reason , why RTSP streaming is not working fine in my case ?
Is there any alternative ?
Also kindly tell me , whether I'm using the correct command and file path to stream the video via RTSP.
Do I need to setup LIVE555 streaming server to start streaming video at transmitter ?
Sorry but you have that all wrong..
To use rtspsrc does not mean you are streaming.. it means you are opening an existing stream(as client), as Florian mentioned you have to have running rtsp server which is serving the files to clients..
Clients can be - as you already tried - a vlc or gstreamer pipe with rtspsrc element, or some other players like mplayer(smplayer has also nice user interface for that imho) etc..
There are various options for rtsp servers: gstreamer rtsp server (mentioned here ), crtmpserver, also vlc (but not the way you used it, check this ) and you will find more..
You can also read this nice article about rt*p family of protocols.
Yes you can use live555 as rtsp server at Ubuntu VM and access it from your windows with vlc as you already tried..
Also keep in mind that you usualy do not use full system path (home/etc/etc) to access rtsp files but rather rtsp access point. That means dedicated folder which contains your media files you will access it for example like rtsp://192.168.1.123/vod/file.mp4 where vod is this access folder (or whatever it is called).
HTH

How to capture microphone input in VLC?

I'm trying to capture microphone input in VLC media player via the http interface and stream this but so far I have arrived at nothing. Is this actually possible?
Which platform? I'm on Mac so i know for sure this is possible with VLC 2.0 for the other platforms this should work as well.
Haven't tested those commands though.
Mac: Use VLC 2.0.0 or later and utilize the qtsound module:
vlc -vvv qtsound://
Win: Use sth like:
vlc dshow:// :dshow-vdev="None" :dshow-adev="Your Audio Device"
Linux: Use sth like:
vlc alsa://plughw:0,0
On Linux if you need to stream also video remember to separate all the options with ":" . In this case I am streaming the usb cam with the default alsa microphone.
cvlc v4l2:///dev/video0 :v4l2-standard=ALL :input-slave=alsa://hw:0,0 :live-caching=300 ':sout=#transcode{vcodec=mp4v,vb=3500,width=1920,height=1080,acodec=mp3,ab=192,channels=2,samplerate=44100}:http{mux=ts,dst=:8080/}'
Just my input on Linux. This works across the Internet as well
Get the mic device id
arecord -l
Streams to port 8080. Just remember on your router to put a port forward to this server
vlc alsa://plughw:1,0 --sout='#transcode{vcodec=none,acodec=mp3,ab=256,channels=2,samplerate=44100,scodec=none}:http{mux=mp3,dst=:8080/}' --no-sout-all --sout-keep

HTTP Live Streaming using Apple mediastreamsegmenter

I would like to implement HTTP live streaming for iPhone/iPad. I am following the apple standards and tools for same.
As of now my video source is one giving me live video from rtsp://123.123.123.123:554/mpeg4 (sample IP). but as HTTP live streaming and mediastreamsegmenter required to pass source over UDP network so i have twisted way bit.
So that i have used VLC player and first stream RTSP to UDP.
For example, i have stream video source from rtsp://123.123.123.554/mpeg4 and redirected it to
udp://#123.123.123.17:1234 (sample ip). i have tested this with two instance of VLC on same machine to check whether live streaming is played or not. it is working fine on VLC.
now I am user MAC OS 10.6.x (Snow leopard). and use latest tools (downloaded from Apple) fro HTTP Live Streaming
I am executing the following command from terminal
mediastreamsegmenter -b http://demo.dummy.com/stream -s 3 -D -f /Desktop/StreamParts 123.123.123.17:1234
here
http://demo.dummy.com/stream - server
/Desktop/StreamParts - Local Folder for saving .ts files
123.123.123.17:1234 - UDP url (from where live streaming is done)
But the problem is when i execute this command. it is giving me error like
no start access unit
error in pid 44(video) -- cc value should be 9 is 10, 1 is 2, 5 is 6, etc.
any idea? what is going wrong here? and what this error message is showing?
My hunch would be that the transport is incompatible. Apple's tools (i.e. mediastreamsegmenter) are expecting an MPEG2 transport stream over UDP, not just RTSP sent over UDP. The problem I have, which I'm afraid will be your next question, is how to correctly generate a MPEG2 transport stream.