Broadcasting two separate transport streams

About encoding, codec settings, muxers and filter usage
Moriquendi
Blank Cone
Blank Cone
Posts: 74
Joined: 31 May 2011 16:22

Broadcasting two separate transport streams

Postby Moriquendi » 02 Jun 2011 14:03

Hello there,

I am working on a project where I need to broadcast live streams to multiple clients when requested. On the client side, the available codecs are g.711 and h.264 for audio and video respectively. Now, I can stream both audio and media using "mp4a" codec for audio however, after transcoding it, it becomes MPEG-2 format which the client side doesn't support this function (for MPEG-2 formats, it can only decode video parts properly but audio is lost in the process). Here's my sample code (btw I am working on VC 2008):

Code: Select all

CString path1 = "mms://95.0.159.138/TV1"; CString str="#transcode{vcodec=h264,vb=800,vfilter=canvas{width=320,height=240,aspect=4:3},scale=1,acodec=mp4a,ab=16,channels=2,samplerate=8000}:duplicate{dst=rtp{dst=192.168.128.154,port=5060,mux=ts},dst=display}"; libvlc_vlm_add_broadcast(vlcInstance, "test", path1, str, 0, NULL, TRUE, 0); libvlc_vlm_play_media(vlcInstance, "test");
When acodec=mp4a, it is transcoded as MPEG-2 stream, however, when i make it acodec = alaw (I assume this stands for g.711 codec), then there is no audio but video only. I've tried to stream only audio which worked just fine. For some reason, I wasn't able to broadcast to separate transport streams. Any help would be appreciated.

P.S: On the client side, I listen to 5060 rtp port, do I need to listen to two different ports for audio and video streams?

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

Re: Broadcasting two separate transport streams

Postby Rémi Denis-Courmont » 02 Jun 2011 17:09

You get MPEG2-TS because of the mux=ts stanza. And yeah, if you don't mux, you'll need separate RTP sessions for audio and video.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

Moriquendi
Blank Cone
Blank Cone
Posts: 74
Joined: 31 May 2011 16:22

Re: Broadcasting two separate transport streams

Postby Moriquendi » 03 Jun 2011 14:54

yea, I figured. I just couldnt find a way to encode the video input stream(mms/file)to raw h264 by using rtp. The only way i can transport rtp video streams encoded as h264 is when they are encapsulated in mpeg2 streams (which does no good). An rtp stream with no mux type simply displays nothing for me (I couldnt observe any packages in Wireshark as well). Anyway, I checked for some solutions and ffmpeg and live555 seemed like a good way to start with, however, i failed compiling projects due to conversion issues in VS 2010. So, I am kinda stucked about what to do next atm, can you at least point me to a direction. I am not asking for codes or anything, just a little hint for where to look at.

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

Re: Broadcasting two separate transport streams

Postby Rémi Denis-Courmont » 03 Jun 2011 16:27

You're most probably not looking at the correct port number. port= cannot work if mux= is not used since multiple ports are needed.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

Moriquendi
Blank Cone
Blank Cone
Posts: 74
Joined: 31 May 2011 16:22

Re: Broadcasting two separate transport streams

Postby Moriquendi » 08 Jun 2011 16:43

Quick update: I finally managed to stream audio and video packages with rtp(no mux), check the code below:

Code: Select all

libvlc_instance_t *vlcInstance; char *vlcOptions[] = {""}; vlcInstance = libvlc_new(1, vlcOptions); CString path1 = "mms://95.0.159.138/TV1"; //link for a local TV CString strA = "#transcode{vcodec=h264,vb=800,acodec=alaw,samplerate=8000,audio-sync}:duplicate{dst=rtp{dst=192.168.128.154,port-video=8004,port-audio=9004},dst=display}"; libvlc_vlm_add_broadcast(vlcInstance, "test", path1, strA, 0, NULL, TRUE, 0); libvlc_vlm_play_media(vlcInstance, "test");
Don't forget to open two different listening ports for audio and video, i.e. rtp://@:8004 and rtp://@:9004. However, without using a SIP interface or some sorta handshaking process, i couldnt find a way to view the video (possibly there is an easy setup that i dont know). Nevertheless, if you want to watch and listen stream without using mux, you can use sdp/rtsp. To make it work, you need to modify strA in the code above as:

Code: Select all

CString strA = "#transcode{vcodec=h264,vb=800,acodec=alaw,samplerate=8000,audio-sync}:duplicate{dst=rtp{dst=192.168.128.154,port=8004,sdp=rtsp://192.168.170.126/mySDP.sdp},dst=display}";
first IP is the client IP, second one is server IP addr. To listen this stream, on the client side, open network stream as "rtsp://192.168.170.126/mySDP.sdp".


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 17 guests