Streaming Nokia N900 Camera to VLC
I recently had need to look at the back of my own head, and using the camera on my phone seemed like the easiest way to do it. I found a guide on the Maemo wiki, but it was for the N800 and I didn’t have the hantro4200 encoder it was trying to use. After learning more than I ever wanted to about gstreamer and sdp files, I came up with a way that works for me.
In my setup, my computer is 192.168.0.100 and the phone is 192.168.0.200. You will have to replace them with your own IP addresses.
Here is the command to start gstreamer on the phone. You will probably want to put it in a script:
gst-launch v4l2camsrc device=/dev/video0 ! \
dsph264enc ! \
rtph264pay ! \
udpsink host=192.168.0.100 port=5434
If gst-launch is not found, you probably need to install the gstreamer-tools package:
apt-get install gstreamer-tools
To use the camera on the front of the phone, you can change the device to /dev/video1.
Here is the minimal sdp file I was able to use with VLC to get it to play. Using the “Open Network” dialog to try and play an RTP stream did not work.
v=0
m=video 5434 RTP/AVP 96
c=IN IP4 192.168.0.200
a=rtpmap:96 H264/90000
The second line (m=) contains the port, the third (c=) contains the IP address of the phone, and the fourth (a=) specifies the codec.
To use MP4 instead of H264, you can just change h264 to mp4v everywhere. In the SDP file, it should be MP4V-ES, as in: a=rtpmap:96 MP4V-ES/90000
. If you get errors in VLC like:
avcodec warning: cannot decode one frame (14922 bytes)
Then add send-config=true
to the rtpmp4v part of the gstreamer pipeline, and make sure you start VLC before you start streaming:
gst-launch v4l2camsrc device=/dev/video0 ! \
dspmp4venc ! \
rtpmp4vpay send-config=true ! \
udpsink host=192.168.0.100 port=5434
For H263, you can try dsph263enc, rtph263pay and H263-1998 or H263-2000, but I couldn’t get it to work.
I don’t know if there’s a way to control the focus, white balance, etc, but I was able to use the flashlight-applet to turn on the camera LEDs while streaming after I downgraded to 0.2-0:
apt-get install flashlight-applet=0.2-0
File->Open from VLC should work.
How do you open the sdp file?
This works for me if I type the commands in trough ssh or terminal manually, but I can’t manage to get a script working. The script seems to start fine and it outputs the exact same thing in the terminal window. But VLC doesn’t find anything if I start from script. Could you please paste a script that would work?
I pasted this (with the right IP) in an executable file called “vlc-stream”: #!/bin/sh gst-launch v4l2camsrc device=/dev/video0 ! \ dsph264enc ! \ rtph264pay ! \ udpsink host=192.168.0.100 port=5434
Make sure you have no characters (space, tab) after the back slashes ( / ). Just press enter at the end of each of those lines. By the way, the mechanism on this page worked for me.
Doh… this “" is a back slash ;)
Excellent Stuff!!!!!!!
I tried both the primary and secondary camera and both worked amazingly fast.
Thank You
Everything works gr8 except the video has yellowish green layer on it. Any idea ?
hi,
how do you make vlc work stand by, as your video starts streaming, you don’t need to invoke the script again, but it is done automatic?
thanks a bunch
How to make the .sdp file?
Grtz Alvin
Just use a text editor.
Hi
I use to stream video from the n900 with gstreamer (gst-launch) and it works very fine. from terminal to terminal and from terminal to vlc. like this:
n900
gst-launch v4l2src \ ! videoscale ! video/x-raw-yuv,width=320,height=240,framerate=30/1 ! dsph264enc ! rtph264pay ! udpsink host=192.168.2.11 port=5000
vlc.sdp
v=0 m=video 5000 RTP/AVP 96 c=in IP4 192.168.2.10 a=rtpmap:96 H264/90000
now i want to stream audio from the internal mircophone to vlc or gst-launch but i could not find out a working code for both, n900 and vlc/gst-launch. i tried several times with different codes but no success.
for example:
n900
gst-launch pulsesrc ! audio/x-raw-int,channels=1,rate=8000 ! mulawenc ! tcpserversink host=192.168.2.10 port=5001
desktop
gst-launch tcpclientsrc host=192.168.2.11 port=5001 ! mulawdec
i dont know much about gstreamer and the documentation is hard to understand for noobs.
did someone here know a working codeline for the n900 to stream audio from the internal microphone with gst-launch?
and on the other side a working vlc .sdp or gst-launch code ?
best regards
I have some delay, about 6 sec… any ideas?
Hallo pclewis,
can you give me any pointer where sdp file syntax is described? My vlc (1.01) under debian linux doesn’t recognize the stream fom gstreamer wether it is h264 nor mp4v.
vlc –list gives: h264 H264 video demuxer packetizer_h264 H.264 video packetizer
mux_mp4 MP4/MOV muxer mp4 MP4 stream demuxer
rtp Real-Time Protocol (RTP) input stream_out_rtp RTP stream output
This is awesome!
Now I’d like to set up a webradio from my N900, so that I can play that stream from my HTPC that runs Ubuntu. I’ve got it to work with the internal microphone, but I can’t really say that I get a party going from that. Now, I’d like to be able to stream either directly from the media player, or maybe from the system sound. I’ve tried some gstreamer commands but all I can get to stream is the test sine sound or the internal microphone, not the system sound. Any one got ideas?
I have got this to work between my N900 and windows pc using the vlc player. My question is will this work over the internet. will it get through a nat. any advice would be great.
Thank you very much for this howto! Works great!
“I don’t know if there’s a way to control the focus, white balance, etc,”-OP
Open the camera app (just slide the door open) before you start gst-launch. This will enable the camera auto focus, white balance, etc. while you stream.
Great blog, Thanks! I saved everything in n900stram.vlc and it working fine with VLC player.
- slide open camera + launch the camera app first
- adjust zoom and focus
- keeping camera app open, launch streaming script
- camera app should now automatically close (‘operation failed’), and you should now be streaming without green-yellow tinge.
how to make n900 commands set a executable script file? copied the commands on notebook app saved to n900 MyDocs via ssh, changed permissions to 755 even 777 and ran with “./file name” in file directory, still permission denied! where am i wrong?
got it working, used sh command before the filename! Thank you for sharing these brilliant scripts and helping linux newbies like me! God bless you.
hi,
can some 1 help me to guide from 1st step until the last… like where to go and where to edit this command… i don’t understand where to start…
if some guide me, it’ll be a great help…
thanks in advance…
Would this work on a Nokia 6210 Navigator?
Another thing…when you say script…is it an .html file?
From all the codecs which would be the best quality. I cannot manage to get mp4v working. Only the h264.
How you can put the streaming to /dev/video output on the PC? This would be veary usefull to use with skype, for example.
Hi,
Can we run VLC on Nokia n900 for music files? I mean VLC music player be installed on Nokia n900?
Thanks