Page 1 of 1

How do I stop buffering on the transmit end when streaming?

Posted: 10 Nov 2017 20:53
by NewtownGuy
I'm trying to encode a h.264 960x540 @ 10 fps stream into rtsp. It constantly buffers on both the transmit end and the receive end. The stream usually only stays up for less than a minute on VLC Media Player on a PC. I set caching on the PC to 15000 mS, but it does not seem to help. Both transmitter and receiver are on the same wired LAN. I'm encoding on a RaspberryPi B+, which is about 95% idle.

Here's the command I'm using:

Code: Select all

cvlc </home/vout1 -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264
What should I be using ?

Note: My source is 10 fps. Do I need to account for it ?

On a related note, is there a way to make VLC Media Player automatically reconnect when the stream drops out ?

Thank you.

Re: How do I stop buffering on the transmit end when streaming?

Posted: 14 Nov 2017 21:46
by NewtownGuy
I found an answer for my own question, but I have a new question -- how do I use http tunneling for the stream to avoid the multiple ports problem of rtsp ?

First, to specify the input frame rate to stop, or at least greatly reduce, endless buffering on both ends of the connection, add this to the end of the command line above:

Code: Select all

:h264-fps=<frame rate>
Without the < and >.

New and related question: How do I modify the command line in my original post to use http to carry the rtsp stream so I only need to open a single port on my router so users on the Internet can access the stream ?

Thank you.

Re: How do I stop buffering on the transmit end when streaming?

Posted: 14 Nov 2017 23:31
by NewtownGuy
I took another stab at it, but no luck. Taking into account all of the above, and a number of posts, I now have this command line:

Code: Select all

cvlc </home/vout1 -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264 :h264-fps=10 :rtsp-tcp
As before, I can view the video when viewer and camera are on the same LAN, but I can't access it via the Internet. I mapped port 8554 (udp+tcp) and an assumed, port 80 for http access, through the router to the camera, but no luck.

When I watch the console log for CVLC in the camera, and a PC to open rtsp://<my Internet address>:8554/ in VLC Media Player > Open Network Stream, I see that CVLC opens a pair of ports, such as 59770 and 59771, or 50946 and 50947, or a different pair for each attempt, but I can't connect to the video. That makes sense because those ports are not accessible on the Internet. Nothing happens if I use http:// instead of rtsp:// in Open Network Stream.

How do I fix this ? What URL do I use in VLC Media Player > Open Network Stream to use http ? How do I change the http port used by CVLC ?

Thank you.

Re: How do I stop buffering on the transmit end when streaming?

Posted: 17 Nov 2017 01:57
by NewtownGuy
I've tried this command to get rtsp over an http tunnel, but no luck:

Code: Select all

cvlc </home/vout1 -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' --demux=h264 --h264-fps=10 --rtsp-http --rtsp-http-port=8080
My source is 10 fps, so I match it with -h264-fps=<>

I'm not clear on what parameters go in the sout { } group.

I changed :<option> to --<option> but it did not make any difference.

Here's the console log, where there are errors, such as a socket error, and I'm concerned about sps and pps being 0:
  • [0x171b8f0] main libvlc debug: searching plug-in modules
    [0x171b8f0] main libvlc debug: loading plugins cache file /usr/lib/vlc/plugins/plugins.dat
    [0x171b8f0] main libvlc debug: recursively browsing `/usr/lib/vlc/plugins'
    [0x171b8f0] main libvlc debug: saving plugins cache /usr/lib/vlc/plugins/plugins.dat
    [0x171b8f0] main libvlc debug: plug-ins loaded: 410 modules
    [0x171b8f0] main libvlc debug: opening config file (/home/pi/.config/vlc/vlcrc)
    [0x171b8f0] main libvlc debug: translation test: code is "en_GB"
    [0x171b8f0] main libvlc debug: CPU has capabilities FPU
    [0x171b8f0] main libvlc debug: looking for memcpy module: 1 candidate
    [0x171b8f0] main libvlc debug: using memcpy module "memcpy"
    [0x172ab48] main input debug: Creating an input for 'Media Library'
    [0x172ab48] main input debug: Input is a meta file: disabling unneeded options
    [0x172ab48] main input debug: using timeshift granularity of 50 MiB, in path '/tmp'
    [0x172ab48] main input debug: `file/xspf-open:///home/pi/.local/share/vlc/ml.xspf' gives access `file' demux `xspf-open' path `/home/pi/.local/share/vlc/ml.xspf'
    [0x172ab48] main input debug: creating demux: access='file' demux='xspf-open' location='/home/pi/.local/share/vlc/ml.xspf' file='/home/pi/.local/share/vlc/ml.xspf'
    [0x172b550] main demux debug: looking for access_demux module: 3 candidates
    [0x172b550] main demux debug: no access_demux module matching "file" could be loaded
    [0x172b550] main demux debug: TIMER module_need() : 4.048 ms - Total 4.048 ms / 1 intvls (Avg 4.048 ms)
    [0x172ab48] main input debug: creating access 'file' location='/home/pi/.local/share/vlc/ml.xspf', path='/home/pi/.local/share/vlc/ml.xspf'
    [0x172d4c0] main access debug: looking for access module: 2 candidates
    [0x172d4c0] filesystem access debug: opening file `/home/pi/.local/share/vlc/ml.xspf'
    [0x172d4c0] main access debug: using access module "filesystem"
    [0x172d4c0] main access debug: TIMER module_need() : 2.059 ms - Total 2.059 ms / 1 intvls (Avg 2.059 ms)
    [0x172e358] main stream debug: Using stream method for AStream*
    [0x172e358] main stream debug: starting pre-buffering
    [0x172e358] main stream debug: received first data after 0 ms
    [0x172e358] main stream debug: pre-buffering done 296 bytes in 0s - 1806 KiB/s
    [0x172dbd8] main stream debug: looking for stream_filter module: 7 candidates
    [0x172dbd8] main stream debug: no stream_filter module matching "any" could be loaded
    [0x172dbd8] main stream debug: TIMER module_need() : 4.584 ms - Total 4.584 ms / 1 intvls (Avg 4.584 ms)
    [0x172dbd8] main stream debug: looking for stream_filter module: 1 candidate
    [0x172dbd8] main stream debug: using stream_filter module "stream_filter_record"
    [0x172dbd8] main stream debug: TIMER module_need() : 1.170 ms - Total 1.170 ms / 1 intvls (Avg 1.170 ms)
    [0x172ab48] main input debug: creating demux: access='file' demux='xspf-open' location='/home/pi/.local/share/vlc/ml.xspf' file='/home/pi/.local/share/vlc/ml.xspf'
    [0x172e0e8] main demux debug: looking for demux module: 1 candidate
    [0x172e0e8] playlist demux debug: using XSPF playlist reader
    [0x172e0e8] main demux debug: using demux module "playlist"
    [0x172e0e8] main demux debug: TIMER module_need() : 3.593 ms - Total 3.593 ms / 1 intvls (Avg 3.593 ms)
    [0x172e9c8] main demux meta debug: looking for meta reader module: 2 candidates
    [0x172e9c8] lua demux meta debug: Trying Lua scripts in /home/pi/.local/share/vlc/lua/meta/reader
    [0x172e9c8] lua demux meta debug: Trying Lua scripts in /usr/lib/vlc/lua/meta/reader
    [0x172e9c8] lua demux meta debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/reader/filename.luac
    [0x172e9c8] lua demux meta debug: Trying Lua scripts in /usr/share/vlc/lua/meta/reader
    [0x172e9c8] main demux meta debug: no meta reader module matching "any" could be loaded
    [0x172e9c8] main demux meta debug: TIMER module_need() : 15.005 ms - Total 15.005 ms / 1 intvls (Avg 15.005 ms)
    [0x172ab48] main input debug: `file/xspf-open:///home/pi/.local/share/vlc/ml.xspf' successfully opened
    [0x17b4868] main xml reader debug: looking for xml reader module: 1 candidate
    [0x17b4868] main xml reader debug: using xml reader module "xml"
    [0x17b4868] main xml reader debug: TIMER module_need() : 3.470 ms - Total 3.470 ms / 1 intvls (Avg 3.470 ms)
    [0x172e0e8] playlist demux debug: parsed 0 tracks successfully
    [0x172ab48] main input debug: EOF reached
    [0x172e0e8] main demux debug: removing module "playlist"
    [0x172dbd8] main stream debug: removing module "stream_filter_record"
    [0x172d4c0] main access debug: removing module "filesystem"
    [0x172ab48] main input debug: TIMER input launching for 'Media Library' : 36.544 ms - Total 36.544 ms / 1 intvls (Avg 36.544 ms)
    [0x172e358] main interface debug: looking for interface module: 1 candidate
    [0x172e358] main interface debug: using interface module "hotkeys"
    [0x172e358] main interface debug: TIMER module_need() : 1.032 ms - Total 1.032 ms / 1 intvls (Avg 1.032 ms)
    [0x172ab48] main interface debug: looking for interface module: 1 candidate
    [0x172ab48] inhibit interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
    [0x172ab48] main interface debug: no interface module matching "inhibit,none" could be loaded
    [0x172ab48] main interface debug: TIMER module_need() : 0.926 ms - Total 0.926 ms / 1 intvls (Avg 0.926 ms)
    [0x172ab48] main interface error: no suitable interface module
    [0x188d5a0] main playlist debug: playlist threads correctly activated
    [0x188d5a0] main playlist debug: rebuilding array of current - root Playlist
    [0x188d5a0] main playlist debug: rebuild done - 0 items, index -1
    [0x188d5a0] main playlist debug: adding item `stdin' ( stream:///dev/stdin )
    [0x1891280] main input debug: Creating an input for 'stdin'
    [0x188d5a0] main playlist debug: no fetch required for (null) (art currently (null))
    [0x74f00590] main interface debug: looking for interface module: 1 candidate
    [0x74f00590] main interface debug: no interface module matching "globalhotkeys,none" could be loaded
    [0x74f00590] main interface debug: TIMER module_need() : 1.428 ms - Total 1.428 ms / 1 intvls (Avg 1.428 ms)
    [0x74f00590] main interface error: no suitable interface module
    [0x171b8f0] main libvlc error: interface "globalhotkeys,none" initialization failed
    [0x172d4c0] main interface debug: looking for interface module: 1 candidate
    [0x172d4c0] dummy interface: using the dummy interface module...
    [0x172d4c0] main interface debug: using interface module "dummy"
    [0x172d4c0] main interface debug: TIMER module_need() : 0.873 ms - Total 0.873 ms / 1 intvls (Avg 0.873 ms)
    [0x188d5a0] main playlist debug: processing request item: null, node: Playlist, skip: 0
    [0x188d5a0] main playlist debug: rebuilding array of current - root Playlist
    [0x188d5a0] main playlist debug: rebuild done - 1 items, index -1
    [0x188d5a0] main playlist debug: starting playback of the new playlist item
    [0x188d5a0] main playlist debug: resyncing on stdin
    [0x188d5a0] main playlist debug: stdin is at 0
    [0x188d5a0] main playlist debug: creating new input thread
    [0x1891120] main input debug: Creating an input for 'stdin'
    [0x17b3fd0] main stream output debug: using sout chain=`rtp{sdp=rtsp://:8554/}'
    [0x17b3fd0] main stream output debug: stream=`rtp'
    [0x17b41a0] main stream out debug: looking for sout stream module: 1 candidate
    [0x17b41a0] main stream out debug: set config option: sout-rtp-sdp to rtsp://:8554/
    [0x17b41a0] stream_out_rtp stream out debug: RTSP stream at /
    [0x17b41a0] main stream out debug: net: listening to * port 8554
    [0x17b41a0] main stream out debug: socket error: Address family not supported by protocol
    [0x17b41a0] main stream out debug: using sout stream module "stream_out_rtp"
    [0x17b41a0] main stream out debug: TIMER module_need() : 11.866 ms - Total 11.866 ms / 1 intvls (Avg 11.866 ms)
    [0x1891120] main input debug: using timeshift granularity of 50 MiB, in path '/tmp'
    [0x1891120] main input debug: `stream:///dev/stdin' gives access `stream' demux `' path `/dev/stdin'
    [0x1891120] main input debug: enforced demux ` h264'
    [0x1891120] main input debug: creating demux: access='stream' demux='h264' location='/dev/stdin' file='/dev/stdin'
    [0x17b6ad0] main demux debug: looking for access_demux module: 0 candidates
    [0x17b6ad0] main demux debug: no access_demux module matched "stream"
    [0x17b6ad0] main demux debug: TIMER module_need() : 0.410 ms - Total 0.410 ms / 1 intvls (Avg 0.410 ms)
    [0x1891120] main input debug: creating access 'stream' location='/dev/stdin', path='/dev/stdin'
    [0x17b6ad0] main access debug: looking for access module: 1 candidate
    [0x17b6ad0] filesystem access debug: opening file `/dev/stdin'
    [0x17b6ad0] main access debug: using access module "filesystem"
    [0x17b6ad0] main access debug: TIMER module_need() : 0.438 ms - Total 0.438 ms / 1 intvls (Avg 0.438 ms)
    [0x17b6bb8] main stream debug: Using stream method for AStream*
    [0x17b6bb8] main stream debug: starting pre-buffering
    [0x17b6bb8] main stream debug: received first data after 0 ms
    [0x17b6bb8] main stream debug: pre-buffering done 702 bytes in 0s - 7371 KiB/s
    [0x17b6d98] main stream debug: looking for stream_filter module: 7 candidates
    [0x17b6d98] main stream debug: no stream_filter module matching "any" could be loaded
    [0x17b6d98] main stream debug: TIMER module_need() : 1213.700 ms - Total 1213.700 ms / 1 intvls (Avg 1213.700 ms)
    [0x17b6d98] main stream debug: looking for stream_filter module: 1 candidate
    [0x17b6d98] main stream debug: using stream_filter module "stream_filter_record"
    [0x17b6d98] main stream debug: TIMER module_need() : 0.422 ms - Total 0.422 ms / 1 intvls (Avg 0.422 ms)
    [0x1891120] main input debug: creating demux: access='stream' demux='h264' location='/dev/stdin' file='/dev/stdin'
    [0x17b6ed0] main demux debug: looking for demux module: 1 candidate
    [0x17b6ed0] h264 demux debug: using 5.00 fps
    [0x17b4eb8] main demux packetizer debug: looking for packetizer module: 21 candidates
    [0x17b4eb8] main demux packetizer debug: using packetizer module "packetizer_h264"
    [0x17b4eb8] main demux packetizer debug: TIMER module_need() : 5.888 ms - Total 5.888 ms / 1 intvls (Avg 5.888 ms)
    [0x17b6ed0] main demux debug: using demux module "h264"
    [0x17b6ed0] main demux debug: TIMER module_need() : 6.913 ms - Total 6.913 ms / 1 intvls (Avg 6.913 ms)
    [0x1891120] main input debug: starting in async mode
    [0x17a5f80] main demux meta debug: looking for meta reader module: 2 candidates
    [0x17a5f80] lua demux meta debug: Trying Lua scripts in /home/pi/.local/share/vlc/lua/meta/reader
    [0x17a5f80] lua demux meta debug: Trying Lua scripts in /usr/lib/vlc/lua/meta/reader
    [0x17a5f80] lua demux meta debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/reader/filename.luac
    [0x17a5f80] lua demux meta debug: Trying Lua scripts in /usr/share/vlc/lua/meta/reader
    [0x17a5f80] main demux meta debug: no meta reader module matching "any" could be loaded
    [0x17a5f80] main demux meta debug: TIMER module_need() : 2.051 ms - Total 2.051 ms / 1 intvls (Avg 2.051 ms)
    [0x1891120] main input debug: `stream:///dev/stdin' successfully opened
    [0x17b4eb8] packetizer_h264 demux packetizer debug: found NAL_SPS (sps_id=0)
    [0x17b4eb8] packetizer_h264 demux packetizer debug: found NAL_PPS (pps_id=0 sps_id=0)
    [0x1891120] main input debug: selecting program id=0
    [0x17a6e98] main decoder debug: looking for packetizer module: 21 candidates
    [0x17a6e98] main decoder debug: using packetizer module "packetizer_h264"
    [0x17a6e98] main decoder debug: TIMER module_need() : 0.462 ms - Total 0.462 ms / 1 intvls (Avg 0.462 ms)
    [0x1891120] main input error: Invalid PCR value in ES_OUT_SET_(GROUP_)PCR !
    [0x1891120] main input debug: switching to sync mode
    [0x17a6e98] packetizer_h264 decoder debug: found NAL_SPS (sps_id=0)
    [0x17a6e98] packetizer_h264 decoder debug: found NAL_PPS (pps_id=0 sps_id=0)
    [0x1891120] main input debug: Buffering 0%
    [0x1891120] main input debug: Buffering 66%
    [0x1891120] main input debug: Stream buffering done (400 ms in 0 ms)
    [0x17b3fd0] main stream output debug: adding a new sout input (sout_input:0x17ae6a0)
    [0x17b41a0] stream_out_rtp stream out debug: maximum RTP packet size: 1400 bytes
    [0x17b41a0] stream_out_rtp stream out debug: RTSP: adding /trackID=0
    [0x17b41a0] stream_out_rtp stream out debug: sdp=

Re: How do I stop buffering on the transmit end when streaming?

Posted: 19 Nov 2017 14:54
by Jean-Baptiste Kempf
I am not sure the RTSP/HTTP is implemented in VLC server side. Which is why you have issues.

Re: How do I stop buffering on the transmit end when streaming?

Posted: 19 Nov 2017 16:50
by NewtownGuy
Thank you for your reply.

Since VLC Media Player is widely admired as the Swiss Army Knife of video software, is there any chance RTSP/HTTP on the CVLC server side could be implemented soon ?

Re: How do I stop buffering on the transmit end when streaming?

Posted: 28 Nov 2017 13:56
by Jean-Baptiste Kempf
Soon, I doubt. But doable, yes.

Re: How do I stop buffering on the transmit end when streaming?

Posted: 28 Nov 2017 16:25
by NewtownGuy
Thank you for your reply.

I understand from your Documentation:Streaming HowTo/Command Line Examples that there is livehttp capability. Does it do Apple HLS -- HTTP Live Streaming ??? If so, I would be tickled pink (happy) !

Is this the correct usage, where the video source (/home/vout1) and the apache server are on the same machine:

Code: Select all

cvlc < /home/vout1 -vvv stream:///dev/stdin --sout '#standard{access=livehttp{seglen=5,delsegs=true,numsegs=5,index=:8000/stream.m3u8,index-url=http://:8000/livestream-#######.ts},mux=ts{use-key-frames},dst=:8000/livestream-#######.ts}}' --h264-fps=<framerate> --demux=h264
What do seglen, delsegs, numsegs, index and index-url do ? What do the # characters do ? Are the #'s typed exactly as shown or do they represent variables ? What are the ts files ? Do I need them ? How do I make them ? Other than web pages that point to the stream, are there any files that I must create manually and place in my apache server ? How does one access this stream in VLC media player ?

Thank you.

Re: How do I stop buffering on the transmit end when streaming?

Posted: 29 Nov 2017 14:43
by Jean-Baptiste Kempf
Yes, it is HLS, but it is not really tested....