Streaming via Tomcat webserver

About encoding, codec settings, muxers and filter usage
bobbyucsd006
New Cone
New Cone
Posts: 9
Joined: 02 Aug 2011 02:54

Streaming via Tomcat webserver

Postby bobbyucsd006 » 02 Aug 2011 03:02

I have a Tomcat webserver that I want to use as an interface for streaming video via RTSP. My plan right now is to just use the command-line interface for VLC. When the user requests the servlet for a video, the servlet will simply run vlc.exe with the proper arguments to stream to the user's IP address, and the servlet will then respond with the rtsp url of the streaming video.

The server command will look something like this:

vlc “C:\myvideo.avi” :sout=#transcode{vcodec=h264,vb=0,scale=0,acodec=mp4a,ab=128,channels=2,samplerate=44100}:rtp{sdp=rtsp://” + INSERT_USER_IP_ADDRESS + “:5544/myvideo} :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep

And then the servlet will send the following link to the client:

vlc rtsp://localhost:5544/myvideo

I'm wondering though if this is the best approach, or if there is something backwards that I'm doing. I'm sorta new to this so any suggestions would be greatly appreciated.
Thanks!

Rémi Denis-Courmont
Developer
Developer
Posts: 15335
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Streaming via Tomcat webserver

Postby Rémi Denis-Courmont » 02 Aug 2011 09:52

I don't really understand how the server can spawn a VLC with the IP address of the user...
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

bobbyucsd006
New Cone
New Cone
Posts: 9
Joined: 02 Aug 2011 02:54

Re: Streaming via Tomcat webserver

Postby bobbyucsd006 » 02 Aug 2011 19:02

I just want to stream video from a server to a client using rtsp, how can I do it with the VLC commandline?

bobbyucsd006
New Cone
New Cone
Posts: 9
Joined: 02 Aug 2011 02:54

Re: Streaming via Tomcat webserver

Postby bobbyucsd006 » 03 Aug 2011 00:27

Ok so I was wrong about the IP addresses, right now I have the following commands:

On the server:
vlc C:\myvideo.avi --loop :sout=#gather:transcode{vcodec=h264,vb=0,scale=0,acodec=mp4a,ab=128,channels=2,samplerate=44100}:rtp{sdp=rtsp://:5544/test} :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep

On the client:
vlc rtsp://SERVER_IP_ADDRESS:5544/test --loop

And that seems to be when the server and client are both my local machine, but when I try to do it with the server on the internet I get nothing =( I've opened port 5544 on both sides but still no avail

Also, it seems that I can only stream one video at a time, ideally I would like to be able to stream multiple videos to different users, how can I set that up?

Any help greatly appreciated, thanks!

Rémi Denis-Courmont
Developer
Developer
Posts: 15335
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Streaming via Tomcat webserver

Postby Rémi Denis-Courmont » 03 Aug 2011 09:27

RTSP uses UDP on pseudo-random ports for actual media payload.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

bobbyucsd006
New Cone
New Cone
Posts: 9
Joined: 02 Aug 2011 02:54

Re: Streaming via Tomcat webserver

Postby bobbyucsd006 » 03 Aug 2011 20:01

Hmm so how do I open the right ports to allow the connection?
I've opened all TCP and UDP ports on both sides using the windows firewall manager

Also, this is the what I'm getting in the message log when I try to play the video on my localmachine, where the server on the internet is streaming rtsp (I've replaced the server ip address with just my_server_ip)

At one point it says no data received in 10s, so I'm guessing it still has something to do with the network blocking the connection.

main debug: processing request item rtsp://my_server_ip:5544/test node Playlist skip 0
main debug: resyncing on rtsp://my_server_ip:5544/test
main debug: rtsp://my_server_ip:5544/test is at 3
main debug: starting new item
main debug: creating new input thread
main debug: Creating an input for 'rtsp://my_server_ip:5544/test'
main debug: thread started
main debug: thread (input) created at priority 1 (../.././src/input/input.c:214)
main debug: using timeshift granularity of 50 MiB
main debug: using timeshift path 'C:\Users\RPARDR~1\AppData\Local\Temp'
main debug: `rtsp://my_server_ip:5544/test' gives access `rtsp' demux `' path `my_server_ip:5544/test'
main debug: creating demux: access='rtsp' demux='' path='emy_server_ip:5544/test'
main debug: looking for access_demux module: 1 candidate
qt4 debug: IM: Setting an input
live555 debug: RTP subsession 'audio/MPEG4-GENERIC'
main debug: selecting program id=0
live555 debug: RTP subsession 'video/H264'
live555 debug: setup start: 0.000000 stop:0.000000
live555 debug: We have a timeout of 60 seconds
live555 debug: spawned timeout thread
live555 debug: play start: 0.000000 stop:0.000000
main debug: using access_demux module "live555"
main debug: TIMER module_need() : 1143.000 ms - Total 1143.000 ms / 1 intvls (Avg 1143.000 ms)
main debug: looking for decoder module: 34 candidates
main debug: using decoder module "faad"
main debug: TIMER module_need() : 1.000 ms - Total 1.000 ms / 1 intvls (Avg 1.000 ms)
main debug: thread started
main debug: thread (decoder) created at priority 2 (../.././src/input/decoder.c:301)
main debug: looking for decoder module: 34 candidates
avcodec debug: libavcodec already initialized
avcodec debug: trying to use direct rendering
avcodec debug: ffmpeg codec (H264 - MPEG-4 AVC (part 10)) started
main debug: using decoder module "avcodec"
main debug: TIMER module_need() : 1.000 ms - Total 1.000 ms / 1 intvls (Avg 1.000 ms)
main debug: looking for packetizer module: 21 candidates
packetizer_h264 debug: found NAL_SPS (sps_id=0)
packetizer_h264 debug: found NAL_PPS (pps_id=0 sps_id=0)
main debug: using packetizer module "packetizer_h264"
main debug: TIMER module_need() : 0.000 ms - Total 0.000 ms / 1 intvls (Avg 0.000 ms)
main debug: thread started
main debug: thread (decoder) created at priority 0 (../.././src/input/decoder.c:301)
main debug: looking for meta reader module: 2 candidates
lua debug: Trying Lua scripts in C:\Users\rpardridge\AppData\Roaming\vlc\lua\meta\reader
lua debug: Trying Lua scripts in C:\Program Files (x86)\VideoLAN\VLC\lua\meta\reader
lua debug: Trying Lua playlist script C:\Program Files (x86)\VideoLAN\VLC\lua\meta\reader\filename.lua
main debug: no meta reader module matching "any" could be loaded
main debug: TIMER module_need() : 1.000 ms - Total 1.000 ms / 1 intvls (Avg 1.000 ms)
main debug: `rtsp://my_server_ip:5544/test' successfully opened
live555 warning: no data received in 10s. Switching to TCP
main debug: thread times: real 0m10.670066s, kernel 0m0.000000s, user 0m0.000000s
main debug: removing module "faad"
main debug: killing decoder fourcc `mp4a', 0 PES in FIFO
main debug: thread times: real 0m10.669066s, kernel 0m0.015600s, user 0m0.000000s
avcodec debug: ffmpeg codec (H264 - MPEG-4 AVC (part 10)) stopped
main debug: removing module "avcodec"
main debug: killing decoder fourcc `h264', 0 PES in FIFO
main debug: removing module "packetizer_h264"
main debug: Program doesn't contain anymore ES
live555 debug: RTP subsession 'audio/MPEG4-GENERIC'
live555 error: SETUP of'audio/MPEG4-GENERIC' failed 461 Unsupported transport
live555 debug: RTP subsession 'video/H264'
live555 error: SETUP of'video/H264' failed 461 Unsupported transport
live555 debug: setup start: 0.000000 stop:0.000000
live555 error: Nothing to play for rtsp://my_server_ip:5544/test
live555 error: TCP rollover failed, aborting
main debug: EOF reached
main debug: finished input
main debug: removing module "live555"
main debug: thread ended
main debug: dead input
main debug: thread times: real 0m13.204320s, kernel 0m0.000000s, user 0m0.062400s
main debug: changing item without a request (current 3/4)
main debug: nothing to play
qt4 debug: IM: Deleting the input
main debug: TIMER input launching for 'rtsp://my_server_ip:5544/test' : 1148.000 ms - Total 1148.000 ms / 1 intvls (Avg 1148.000 ms)

Rémi Denis-Courmont
Developer
Developer
Posts: 15335
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Streaming via Tomcat webserver

Postby Rémi Denis-Courmont » 03 Aug 2011 21:13

This typically happens if the client is behind a NAT that does not provide RTSP ALG functionality.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

bobbyucsd006
New Cone
New Cone
Posts: 9
Joined: 02 Aug 2011 02:54

Re: Streaming via Tomcat webserver

Postby bobbyucsd006 » 03 Aug 2011 23:49

Ok I got the firewall stuff worked out, and am able to stream the video, but still having a hard time displaying it. It takes about 30 seconds after opening the video for a picture to appear, and then another 10 seconds for it to change frame, but then stalls again. Rarely does it play any continuous video. I am guessing this is because the connection is really slow? Heres what I'm seeing in the log:

A question I have is when it says (computer too slow ?) What is that refering to? The computer streaming the video or the client? I'm guessing it has to be the server.

main warning: late picture skipped (4335079 > 0)
main warning: late picture skipped (3890741 > -105)
main warning: resampling stopped after 14116000 usec (drift: 103486)
main warning: buffer is 103303 in advance, triggering downsampling
main warning: late picture skipped (288229 > -18)
main warning: late picture skipped (733867 > -82)
main warning: late picture skipped (550920 > -13)
avcodec error: more than 5 seconds of late video -> dropping frame (computer too slow ?)
main warning: late picture skipped (3991069 > -250)
main warning: late picture skipped (3673487 > -58)
main warning: late picture skipped (654118 > -9)
main warning: late picture skipped (517429 > -2)
main warning: resampling stopped after 9380000 usec (drift: -10350)
main warning: late picture skipped (695921 > -187)
main warning: buffer is 67767 in advance, triggering downsampling
avcodec error: more than 5 seconds of late video -> dropping frame (computer too slow ?)
main warning: late picture skipped (4845586 > 0)
main warning: late picture skipped (4703285 > -250)
main warning: late picture skipped (1365774 > -105)
main warning: late picture skipped (1088900 > -13)
main warning: late picture skipped (842260 > -3)
main debug: auto hidding mouse
avcodec error: more than 5 seconds of late video -> dropping frame (computer too slow ?)
main warning: audio drift is too big (-467155), clearing out
main warning: timing screwed, stopping resampling
main warning: mixer start isn't output start (-169347)
main debug: audio output is starving (380011), playing silence
main warning: buffer is 77825 late, triggering upsampling
main warning: late picture skipped (3761503 > -250)
main warning: late picture skipped (3325063 > -58)
main warning: late picture skipped (1574832 > -18)
main warning: late picture skipped (1319478 > 0)
main warning: late picture skipped (1152516 > 0)
avcodec error: more than 5 seconds of late video -> dropping frame (computer too slow ?)
main warning: resampling stopped after 7822000 usec (drift: 70560)
main warning: buffer is 70378 in advance, triggering downsampling

bobbyucsd006
New Cone
New Cone
Posts: 9
Joined: 02 Aug 2011 02:54

Re: Streaming via Tomcat webserver

Postby bobbyucsd006 » 04 Aug 2011 01:30

So I switched to a faster machine for the server and now it's working decent. Thanks for the help!


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 14 guests