LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Using VLC to stream from the camera - Help needed

Sat May 18, 2013 9:10 pm

gotdatwmd wrote:I tried your revised command and when I opened up http://ipofpi:8090 in a web browser (safari on a mac) it just tried to endlessly download the stream like it was a file. tried it in firefox as well to no effect. What am I doing wrong here?
Sorry missed this earlier.

Currently you need to view the stream using VLC or some other video streaming player. A web browser doesn't know how to play the video and instead just downloads the stream to disk.

ProgDrums
Posts: 10
Joined: Wed Apr 10, 2013 10:36 am

Re: Using VLC to stream from the camera - Help needed

Sat May 18, 2013 9:11 pm

What would be the benefit, if any, of HLS?

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Using VLC to stream from the camera - Help needed

Sat May 18, 2013 9:13 pm

usmcguy wrote:
LeoWhite wrote:Hiya,

After much searching I managed to get this working using

raspivid -o - -t 99999 |cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8090}' :demux=h264


its the ':demux=h264' that seemed to get things sorted.

This now lets me stream directly from the camera, over the network and to my PC running VLC!

Hope it works for you!

Now I just need to reduce the buffering to make it a bit more real time..

Leo

Did you compile cvlc? Or did you get it from a disto repo?

Its part of the vlc package and can be downloaded as normal (sudo apt-get install vlc)

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Using VLC to stream from the camera - Help needed

Sat May 18, 2013 9:17 pm

ProgDrums wrote:What would be the benefit, if any, of HLS?
Most people were talking about it in relation to streaming to iOS devices.

In theory it may allow more clients to connect and view the stream at the same time (As at that point the web server is just providing the files as normal, instead of VLC being involved), however I haven't done much testing.

At the moment its maxing out the CPU on the raspberry PI and I think I'm the only one connected! its possible VLC is still doing extra transcoding, or the act of writing the files to the SD card to then stream out is slowing things down. Something to investigate another day!

Leo

ProgDrums
Posts: 10
Joined: Wed Apr 10, 2013 10:36 am

Re: Using VLC to stream from the camera - Help needed

Sat May 18, 2013 9:21 pm

Thanks. RTSP is probably best for my needs in that case.

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Using VLC to stream from the camera - Help needed

Sat May 18, 2013 9:24 pm

ProgDrums wrote:Thanks. RTSP is probably best for my needs in that case.
That's probably what I'll end up using myself, at least when only streaming on a local network!

momentum
Posts: 4
Joined: Sat May 18, 2013 7:54 pm

Re: Using VLC to stream from the camera - Help needed

Sat May 18, 2013 11:11 pm

Update: I switched to my 512 RPi and it worked instantly. Something is foul with my 256.
Update 2: I switched my 5m power cable with a short 1m power cable and it now works fine on both the 512 and 256 RPi. I still have the "Packet with too strange dts ... "

It streams fine local and external.

I do however receive many "packet with too strange dts ... " msg's. These seem to appear more during dynamic movements of the camera.

Anyone know how to fix this?

UglyMike
Posts: 30
Joined: Fri Feb 10, 2012 2:45 pm
Contact: Website

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 7:53 am

Nice garden scene with overcast sky at LeoWhite.... Beats looking at Lego figures...
Works great on my iPad.

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 7:57 am

momentum wrote:Update: I switched to my 512 RPi and it worked instantly. Something is foul with my 256.
Update 2: I switched my 5m power cable with a short 1m power cable and it now works fine on both the 512 and 256 RPi. I still have the "Packet with too strange dts ... "
I ran into issues like that when getting a USB Web Camera to work. The power lead was dropping enough voltage that the RPi was reading 4.75v across the test points. A shorter power lead made the problem go away.

The V2 boards seem much better in this regards, using the original power lead my Model A reported exactly 5V.
momentum wrote: It streams fine local and external.

I do however receive many "packet with too strange dts ... " msg's. These seem to appear more during dynamic movements of the camera.

Anyone know how to fix this?
Streaming via RTP/RTSP seems to avoid those messages, but then its hard to stream outside your local network. Not sure if its down to VLC having more work to do when HTTP streaming and occasionally drops bytes from the camera stream...

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 7:58 am

UglyMike wrote:Nice garden scene with overcast sky at LeoWhite.... Beats looking at Lego figures...
Works great on my iPad.
Well the Lego Figures came into use when it got too dark outside to see! Now its back to watching trains go by!

Goss1982
Posts: 13
Joined: Mon Jul 16, 2012 4:52 pm

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 12:27 pm

Hi

I have managed to get the stream to VLC working but its seems to stop working after a few minutes with the log below. Anyone have any idea why this is happening and how to sustain the feed?

Thanks

[0x87e220] main input debug: EOF reached
[0x876050] main playlist debug: finished input
[0x7a3c18] main access debug: waitpipe: object killed
[0x7a8030] main decoder debug: removing module "packetizer_h264"
[0x7a8030] main decoder debug: killing decoder fourcc `h264', 0 PES in FIFO
[0x7a2e80] main stream output debug: removing a sout input (sout_input:0x7b3178)
[0x7a4018] main demux debug: removing module "h264"
[0x7a4398] main demux packetizer debug: removing module "packetizer_h264"
[0x7a3ee0] main stream debug: removing module "stream_filter_record"
[0x7a3c18] main access debug: removing module "filesystem"
[0x87e220] main input debug: Program doesn't contain anymore ES
[0x876050] main playlist debug: dead input
[0x7a2e80] main stream output debug: destroying useless sout
[0x7a3068] main stream out debug: destroying chain... (name=rtp)
[0x7a3068] main stream out debug: removing module "stream_out_rtp"
[0x7a5e98] main http host debug: waitpipe: object killed
[0x7a5e98] main http host debug: HTTP host removed
[0x7a5e98] main http host warning: client still connected
[0x7a3068] main stream out debug: destroying chain done
[0x87e220] main input debug: TIMER input launching for 'stdin' : 104.120 ms - Total 104.120 ms / 1 intvls (Avg 104.120 ms)
[0x876050] main playlist debug: changing item without a request (current 0/1)
[0x876050] main playlist debug: nothing to play
^C[0x7188f0] main libvlc debug: deactivating the playlist
[0x876050] main playlist debug: deactivating the playlist
[0x7a5570] main playlist export debug: saving Media Library to file /home/andy/.local/share/vlc/ml.xspf
[0x7a5570] main playlist export debug: looking for playlist export module: 1 candidate
[0x7a5570] main playlist export debug: using playlist export module "export"
[0x7a5570] main playlist export debug: TIMER module_need() : 5.073 ms - Total 5.073 ms / 1 intvls (Avg 5.073 ms)
[0x7a5570] main playlist export debug: removing module "export"
[0x876050] main playlist debug: playlist correctly deactivated
[0x7188f0] main libvlc debug: removing all services discovery tasks
[0x7188f0] main libvlc debug: removing all interfaces
[0x7188f0] main libvlc debug: exiting
[0x739ad8] main interface debug: removing module "dummy"
[0x874988] main interface debug: removing module "hotkeys"
[0x876050] main playlist debug: destroying
[0x7188f0] main libvlc debug: TIMER ML Load : Total 154.017 ms / 1 intvls (Avg 154.017 ms)
[0x7188f0] main libvlc debug: TIMER Preparse run : Total 9.686 ms / 1 intvls (Avg 9.686 ms)
[0x7188f0] main libvlc debug: TIMER Items array build : Total 9.017 ms / 1 intvls (Avg 9.017 ms)
[0x7188f0] main libvlc debug: TIMER ML Dump : Total 12.090 ms / 1 intvls (Avg 12.090 ms)
[0x7188f0] main libvlc debug: removing stats
[0x7188f0] main libvlc debug: removing module "memcpy"

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 1:30 pm

Goss1982 wrote:Hi

I have managed to get the stream to VLC working but its seems to stop working after a few minutes with the log below. Anyone have any idea why this is happening and how to sustain the feed?

Thanks

[0x87e220] main input debug: EOF reached
[0x876050] main playlist debug: finished input
Looks like it stopped receiving input from raspivid. Its probably just the camera reaching the end of the timeout. Try adding a few more 9s to the timeout value.

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 3:13 pm

Started documenting some of the methods mentioned in this this thread on my web site at http://www.mybigideas.co.uk/RPi/RPiCamera/

Currently covers RTSP, HTTP and HLS

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 3:38 pm

LeoWhite wrote:Well I've now gotten HLS working! So my new stream is at http://109.145.254.207:8091/streaming/stream.m3u8
If I click that link Chrome downloads a file called 'stream.m3u8' with the contents:

Code: Select all

#EXTM3U
#EXT-X-TARGETDURATION:5
#EXT-X-MEDIA-SEQUENCE:9601
#EXTINF:5,
http://109.145.254.207:8091/streaming/stream-00009601.ts
#EXTINF:5,
http://109.145.254.207:8091/streaming/stream-00009602.ts
#EXTINF:5,
http://109.145.254.207:8091/streaming/stream-00009603.ts
#EXTINF:5,
http://109.145.254.207:8091/streaming/stream-00009604.ts
#EXTINF:5,
http://109.145.254.207:8091/streaming/stream-00009605.ts

ProgDrums
Posts: 10
Joined: Wed Apr 10, 2013 10:36 am

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 3:41 pm

poing wrote:
LeoWhite wrote:Well I've now gotten HLS working! So my new stream is at http://109.145.254.207:8091/streaming/stream.m3u8
If I click that link Chrome downloads a file called 'stream.m3u8'
You need to open the stream in something like VLC.

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 3:50 pm

Creating an HLS stream using ffmpeg is surprisingly low CPU intense. ffmpeg only uses low one digit CPU.

Dunno why people are so in love with VLC.

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 3:54 pm

Facepalm! It works rather nicely. A bit missing frames now and then (using a 60mbit download subscription).

Cool!

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 3:57 pm

Watching that stream my i5 3570K Ivy Bridge CPU overclocked to 4.5GHz uses around 26% :shock:

dpguest
Posts: 28
Joined: Wed Feb 06, 2013 4:17 pm

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 4:25 pm

how do you use ffmpeg with the pi camera ... to view on a laptop on same network?

thanks for an example to try ...

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 4:36 pm

towolf wrote:Creating an HLS stream using ffmpeg is surprisingly low CPU intense. ffmpeg only uses low one digit CPU.
I'm guessing VLC is doing some additional processing that isn't really required (Also Apache pulls quite a bit of CPU time when actually serving the files. If I wasn't trying this quickly I'd have probably gone for one of the lighter weight web servers for running on the Pi).

Just doing the normal rtsp or http streaming is much more efficient in VLC, only looked at HLS to try and get video playing in a browser (Without needing an extra plugin).
towolf wrote:Dunno why people are so in love with VLC.
Didn't realize ffmpeg could do video streaming. I've only ever used it for decoding video for playback or offline transcoding of video formats.

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 4:38 pm

poing wrote:Watching that stream my i5 3570K Ivy Bridge CPU overclocked to 4.5GHz uses around 26% :shock:
Uses about 15% here on a 2.6 GHz i7.

texy
Forum Moderator
Forum Moderator
Posts: 5156
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 4:59 pm

LeoWhite wrote:Well I've now gotten HLS working! So my new stream is at http://109.145.254.207:8091/streaming/stream.m3u8

and I launched it using

Code: Select all

raspivid -o -  -w 920 -h 540 -t 9999999 |  vlc -v -I "dummy" stream:///dev/stdin  :sout="#std{access=livehttp{seglen=10,delsegs=true,numsegs=5, index=/var/www/streaming/stream.m3u8, index-url=http://109.145.254.207/streaming/stream-########.ts}, mux=ts{use-key-frames}, dst=/var/www/streaming/stream-########.ts}" :demux=h264
Which is based on some examples found on the web and previously mentioned in these forums.

This does seem to consume a lot more CPU time than the raw HTTP/RTSP stream tho..

Leo
I can't seem to get this working :(
Does the (very long) raspivid command actually generate the stream as a file on the pi at /var/www/streaming/ ? Or do you need to create something there before runnig the command? Because I only have the default index.html file there generated by apache. I have an no-ip.org website that I can see fine from my laptop, so should this command work :

Code: Select all

/opt/vc/bin/raspivid -o -  -w 920 -h 540 -t 9999999 |  vlc -v -I "dummy" stream:///dev/stdin  :sout="#std{access=livehttp{seglen=10,delsegs=true,numsegs=5, index=/var/www/streaming/stream.m3u8, index-url=http://texyuk.no-ip.org/streaming/stream-########.ts}, mux=ts{use-key-frames}, dst=/var/www/streaming/stream-########.ts}" :demux=h264
Cheers,
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 6:11 pm

texy wrote: I can't seem to get this working :(
Does the (very long) raspivid command actually generate the stream as a file on the pi at /var/www/streaming/ ? Or do you need to create something there before runnig the command? Because I only have the default index.html file there generated by apache. I have an no-ip.org website that I can see fine from my laptop, so should this command work :

Code: Select all

/opt/vc/bin/raspivid -o -  -w 920 -h 540 -t 9999999 |  vlc -v -I "dummy" stream:///dev/stdin  :sout="#std{access=livehttp{seglen=10,delsegs=true,numsegs=5, index=/var/www/streaming/stream.m3u8, index-url=http://texyuk.no-ip.org/streaming/stream-########.ts}, mux=ts{use-key-frames}, dst=/var/www/streaming/stream-########.ts}" :demux=h264
It should generate multiple .ts files in /var/www/streaming as well as a .m3u8 playlist file that it will update as more .ts files are generated.

Things you may need to do is manually create the /var/www/streaming directory, and you may need to give your user write access to them (I took the lazy way out and did a 'chmod -R a+rw /var/www' so everyone can add to it). cvlc should have complained if it couldn't access the output directory. Did you get any error output?

At some point I was going to retry this from a fresh OS install to make sure I had all the steps covered.

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 6:33 pm

LeoWhite wrote:Didn't realize ffmpeg could do video streaming. I've only ever used it for decoding video for playback or offline transcoding of video formats.
FFmpeg does as much streaming as VLC.

Code: Select all

top - 20:34:18 up 21:20,  2 users,  load average: 0.32, 0.32, 0.32
Tasks:  74 total,   1 running,  73 sleeping,   0 stopped,   0 zombie
%Cpu(s):  5.5 us,  6.9 sy,  0.0 ni, 84.8 id,  0.0 wa,  0.3 hi,  2.4 si,  0.0 st
KiB Mem:    380148 total,   369884 used,    10264 free,    17764 buffers
KiB Swap:        0 total,        0 used,        0 free,   311072 cached

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND              
 1339 root      20   0   41204   7864   4464 S 5.902 2.069   1:32.66 ffmpeg               
  259 http      20   0    7564   1564    840 S 1.967 0.411   1:05.78 nginx                
 1338 root      20   0    1512    356    248 S 1.967 0.094   0:32.74 psips                
 1337 root      20   0   60876   1128    772 S 1.639 0.297   0:27.33 raspivid             
   47 root      20   0       0      0      0 D 1.312 0.000   3:43.21 mmcqd/0  
See this thread: http://www.raspberrypi.org/phpBB3/viewt ... 38&t=44104

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Using VLC to stream from the camera - Help needed

Sun May 19, 2013 6:41 pm

towolf wrote:
LeoWhite wrote:Didn't realize ffmpeg could do video streaming. I've only ever used it for decoding video for playback or offline transcoding of video formats.
FFmpeg does as much streaming as VLC.

See this thread: http://www.raspberrypi.org/phpBB3/viewt ... 38&t=44104
Hmm, looks like I need to finish building ffmpeg before I can try that out.

Return to “Camera board”