Use VLC to fetch SDP file once using RTSP - vlc

Context
Most RTP streams (from e.g. an IP camera) need some information from a SDP to be able to decode them.
SDP is usually fetched just in time, usually from a RTSP URL but other means are possible (e.g. HTTP).
Specific case
We have a situation where an RTP stream (from a camera, UDP sent at all time whether anyone listens or not) will be played using VLC, but providing VLC an RTSP URL to fetch SDP just in time is not an option.
There is a RTSP service yet we need to query it in advance and dump the resulting SDP file to feed it to VLC later. Doing a RTSP query just-in-time is useless anyway since the stream exists at all times.
How to do that with VLC?
Search before you post
Of course I've been searching Google, videolan wiki and StackExchange.
Information is difficult to find because when people talk about streaming, RTSP, RTP, they are generally usig VLC to generate a RTP stream, or output a SDP that VLC generates because it does the encoding, etc.
It's not the case here. The SDP to dump comes from the serveur with a single RTSP query.
Question
Basically, I'm looking for a command-line like:
vlc --sout...something...rtsp://sourceIP:Port/...something...out...myfile.sdp
That would dump the SDP in myfile.sdp.
Then, later, running vlc with the myfile.sdp as argument is expected to play the stream.

We did not find a solution using VLC alone (I even looked a little at the VLC source code). So we used a somehow "brute force" solution but hey, it works.
What we do at configure time is ask VLC to play stream once, while Wireshark captures packets with filter rtsp and sdp. One packet appears containing the SDP data we want. We select it and use "extract selected bytes to ..." and save to a file with name ending with .sdp.
That gives us a file containing the SDP information we want. Job done.

Related

Streaming audio from Twilio media stream to a browser

I'm trying to stream audio from a Twilio call to a browser.
I want to use Twilio Media Streams which send base64 encoded data in 8000 sample rate, audio/x-mulaw (according to this: https://www.twilio.com/docs/voice/twiml/stream)
I tried playing back the audio in a browser using audioContext.decodeAudioData but I am getting an exception:
DOMException: The buffer passed to decodeAudioData contains an unknown content type.
I think I need to resample the data and add a header or something of that sort but I'm unable to figure it out.
Any help would be much appreacited
Twilio developer evangelist here.
I have not tried this myself, so I can only give some pointers. You are right that the audio from Twilio is coming as audio/x-mulaw and that browsers do not support this format.
There is a good set of documentation on MDN about web audio codecs and containers. CanIUse has data on browser support for common formats (e.g. mp3).
So you will need to resample the audio into a supported format before you send it to the browser. I don't have any suggestions for tools for that, particularly as I don't know what you are building your server in.
Alternatively, if you need the audio from a call in a browser, have you considered using Twilio Client to dial into the call?

Synthesize SPS and PPS for incomplete H264 stream for iOS VideoToolbox

I have an AXIS IP camera (M1054) which sends an H264/RTP stream via RTSP.
Unfortunately, they do not send SPS and PPS NALUs at all, they only transfer (fragmented) Codec slices.
I'm trying to decode that stream with the iOS VideoToolbox framework which needs the H264 SPS and PPS tuple to correctly setup the CMFormatDescription.
I wonder how I can synthesize the necessary parameter sets from looking at the actual H264 slices?
Update: I have captured an example session where mplayer manages to display the stream via Wireshark. The capture file is here and you can see the whole RTSP setup as well as a couple of seconds RTP.
RTP consists of 3 sets of flows.
RTP for the media
RTSP for controlling the connection
RTCP for the sender confirmation and timestamps.
Although the SPS/PPS is often in band inside the stream and is transported via RTP - it doesn't need to be there (and may be shouldn't be there). The SPS/PPS is transmitted as part of the setup process (RTSP). I usually recommend running http://www.live555.com/ in the debugger to learn about the details of the process - but http://www.live555.com/ is currently down.
In very rare circumstances you could recreate the SPS/PPS from a well known constrained H.264 stream. But in general you can't. So the SPS/PPS are metadata of the H.264 stream that is not redundantly stored anywhere else.
So if your familiarize yourself with the setup process - RTSP - it will be pretty obvious.

How to receive RTP Packets which are Streaming from RTP URL in iOS Device? (e.g. rtp://#225.0.0.0)

I am trying to stream RTP Packets (which is streaming an audio) from RTP URL e.g. rtp://#225.0.0.0
after so much research on the same i have somewhat streamed the URL in my device and playing it with https://github.com/maknapp/vlckitSwiftSample.
This is only playing the Streamed Data but does not have any function to store the data.
From research and other sources i dint find much content and simple information that should be helpful to stream the Packet over RTP and store it in iOS Device.
I have tried with following link.
https://github.com/kewlbear/FFmpeg-iOS-build-script
https://github.com/chrisballinger/FFmpeg-iOS
These two are not even compiling due to POD Issues other projects or guide just giving me reference on RTSP Stream instead of RTP Stream.
If anyone can give us a guidance or any idea that how we can implement such things then it will be appreciated.
First foremost, you need to understand how this works.
The sender i.e. the creator of RTP stream is probably doing the following:
Uses a source for the data: In case of audio, this could be the microphone or audio samples or a file
Encodes the audio using a audio codec such as AAC or Opus.
Uses RTP packetizer to create RTP packets from encoded audio frames
Uses a transport layer such as UDP to send these packets
Protocols such as RTSP provides the necessary signaling information to provide better stream information. Usually RTP itself isn't enough as things such as congestion control, feedback, dynamic bit rate are handled with the help of RTCP.
Anyway, in order to store the incoming stream, you need to do the following:
Use a RTP depacketizer to get the encoded audio frames out of it. You can write your own or use a third party implementation. In fact ffmpeg is a big framework which has all necessary code for most of the codecs and protocols. However for your case, find a simple RTP depacketizer. There could be headers corresponding to a particular codec to make sure you refer to a correct RFC.
Once you have access to encoded frames, you can write the same in a media container such as m4a or ogg depending upon the audio codec used in the stream.
In order to play the stream, you need to do the following:
Use a RTP depacketizer to get the encoded audio frames out of it. You can write your own or use a third party implementation. In fact ffmpeg is a big framework which has all necessary code for most of the codecs and protocols. However for your case, find a simple RTP depacketizer.
Once you have access to encoded frames, use a audio decoder (available as a library) to decode the frames or check if your platform supports that codec directly for playback
Once you have access to decoded frames, in iOS, you can use AVFoundation to play the same.
If you are looking at an easy way to do it, may be use a third party implementation such as http://audiokit.io/

DVB-S streaming from source to media server

i am streaming some FTA channels from
http://www.tbsdtv.com/products/tbs6985-dvb-s2-quad-tuner-pcie-card.html
using mediaportal
http://www.team-mediaportal.com/
and then i get rtsp url from mediaportal of channel i timeshift
and vlc i can send that stream to mediaserver FMS to get HLS, HDS, RTMP, RTSP
i have 3 servers running erlyvideo (flussonic)
so it take care of the delivery.
i want some alternate solution beside that
i have done some methods to work this our
including
VLC
IPTVL
Dvbdream
but the quality is better when i stream some thing as file, only FMLE works good with live stream, but for that we only can use directshow enabled devices like
http://www.viewcast.com/products/osprey-cards
i am doing it on windows.
if some one have any more methods or want to share his version please do so

Relaying RTMP stream from one server to another

There is a WWW page with Flash stream on it. I want to download and forward this stream to another streaming server, when possible - replace audio stream (e.g. translate), but without recompressing video stream. Usual way for this ATM is to capture and broadcast Flash player view from the web page, which is obviously suboptimal because video needs to be recompressed, making the quality notably worse and loading the cpu.
Has someone an idea how to do it? VLC seems to be able making relay, but it also seems not to support RTMP at all.
if you're ready to do this programmatically you can use crtmpserver (C++) or red5 (Java) with any RTMP client, otherwise this question doesn't belong to SO

Resources