View RTMP Stream on Raspberry Pi
Intro: View RTMP Stream on Raspberry Pi
Here's a simple and straightforward technique to view RTMP streams on the Raspberry Pi.
For this, you will need the following installed on your R-Pi
- omxplayer (installed by default)
- mkfifo (installed by default)
- rtmpdump (not installed by default)
You can install rtmpdump by issuing the command 'sudo apt-get install rtmpdump' from any terminal window on the R-Pi.
First, create a named pipe. A named pipe is essentially a FIFO buffer memory which is referenced by a name. This named pipe will be used for dumping and viewing your stream. You can create a named pipe using the command ' mkfifo name_of_pipe '
Now, use rtmpdump to read the live stream and dump it on to the named pipe you created earlier. Simultaneously, use omxplayer to play the content dumped on to the named pipe. This can be done with the following command:
rtmpdump -r rtmp://url_of_rtmp_stream --live -o name_of_pipe | omxplayer name_of_pipe
At a Glance:
- Install rtmpdump
sudo apt-get install rtmpdump
- Create Named Pipe
mkfifo /tmp/livevideo
-Play RTMP stream
rtmpdump -r rtmp://url_of_stream/ --live -o /tmp/livevideo | omxplayer /tmp/livevideo
Watch a video demonstration of this on the YouTube video linked here. http://www.youtube.com/watch?v=HXA_w8Hkjeo
For this, you will need the following installed on your R-Pi
- omxplayer (installed by default)
- mkfifo (installed by default)
- rtmpdump (not installed by default)
You can install rtmpdump by issuing the command 'sudo apt-get install rtmpdump' from any terminal window on the R-Pi.
First, create a named pipe. A named pipe is essentially a FIFO buffer memory which is referenced by a name. This named pipe will be used for dumping and viewing your stream. You can create a named pipe using the command ' mkfifo name_of_pipe '
Now, use rtmpdump to read the live stream and dump it on to the named pipe you created earlier. Simultaneously, use omxplayer to play the content dumped on to the named pipe. This can be done with the following command:
rtmpdump -r rtmp://url_of_rtmp_stream --live -o name_of_pipe | omxplayer name_of_pipe
At a Glance:
- Install rtmpdump
sudo apt-get install rtmpdump
- Create Named Pipe
mkfifo /tmp/livevideo
-Play RTMP stream
rtmpdump -r rtmp://url_of_stream/ --live -o /tmp/livevideo | omxplayer /tmp/livevideo
Watch a video demonstration of this on the YouTube video linked here. http://www.youtube.com/watch?v=HXA_w8Hkjeo
18 Comments
kanenas3kanenas 2 years ago
It works fine, but it stops after 106 seconds (each time!).
Any idea why?
and how to fix it to last (way) more?
MuzammilT 4 years ago
hysamrashed 4 years ago
simspace 7 years ago
Not sure when the change was made, but with the latest omxplayer, you can now pass the rtmp stream path as a parameter. From the Raspian command line: omxplayer rtmp://ip.address:port/stream-name
Example:
omxplayer rtmp://10.11.123.100:1935/live/mystream
I believe the default rtmp port is 1935.
BobT79 7 years ago
I tried this and it does not seem to work for me. I also tried the method recommended in the link http://www.youtube.com/watch?v=HXA_w8Hkjeo and it did not work either.
I am able to run omxplayer with video files such as:
omxplayer test01.mpg
or
omxplayer FILE2713.MOV
I use vMix running on a PC to create my streams. I have installed mistserver on my RaspBerry Pi and I am able to view that stream through the mistserver API interface - so I know the vMix can successfully send an rtmp stream to the PI.
But what I need to do is use the vMix on the PC to create a stream which I can view on the PI's composite video output.
I keep getting this error:
Connecting ...
ERROR: RTMP_Connect0, failed to connect socket. 110 (Connection timed out)
bob@Bob-RPI-Ubuntu:~$
I have the following version of omxplayer
bob@Bob-RPI-Ubuntu:~$ omxplayer --version
omxplayer - Commandline multimedia player for the Raspberry Pi
Build date: Fri, 23 Sep 2016 00:56:49 +0000
Version : dfea8c9 [master]
Repository: https://github.com/popcornmix/omxplayer.git
Hoping for some help with this. Thanks.
JOSEM459 7 years ago
Hello,
If i want to take a saved video file from raspberry pi and play it live on my PC, how can I do that?
TonyK94 7 years ago
I am getting
"Invalid framerate 1000, using forced 25fps and just trust timestamps" then "Have a nice day"
kniac 9 years ago
I'm run following your command but got this error
ERROR: RTMP_Connect0, failed to connect socket. 111 (Connection refused)
nprasan 9 years ago
hi kniac,
this could probably be because the firewall on your pc is blocking some ports used by RTMP. try turning off the windows firewall and see if it helps.
AmyB81 8 years ago
I turned off my firewall and tried running it again, but it did not work. I got the same error. Any more advice for this?
SaraWest 8 years ago
Worth reading
gianpyc 9 years ago
Hi,
thanks for your guide. I tried with a live stream, it works but omxplayer doesn't show anything in the screen. What I'm missing? I just followed your guide. Cheers
nurettin 9 years ago
how do you show graphics from the command prompt? is this using xfb?
nprasan 9 years ago
no. the graphics was separately captured using a video capture card and was overlay-ed during editing.
jorgegearvill 9 years ago
Hello, I would Like to know if it possible to do the inverse process. What I mean is if it possible to live stream what you see in th Raspberry PI, if so I also would like to know how to use a Easycap DVR to transmit video from the outputs ( the red, white and yellow wires ) to the Raspberry PI and then to my computer, using your process. Thanks a lot !!
SOMETHING LIE THIS WOULD BE WONDERFUL http://www.raspberrypi.org/forums/viewtopic.php?t=45682&p=361303
nprasan 9 years ago
hi jorgegearvill,
thanks for your interest. rtmpdump can only be used to read an rtmp stream. What you are trying to achieve may be possible using some other tools, probably gstreamer. give it a try.
velthune 10 years ago
Nice guide! But how command to stream the video?
Is this correct?
avconv -re -i video.mov -f sap sap://224.1.1.1:1234?same_port=1
(to share a video and not a cam stream)
nprasan 10 years ago