Monday, 26 April 2010

RTP streaming with ffmpeg

Since I often receive private emails asking details about RTP streaming with ffmpeg, I decided to write down some notes about it.
So, first of all, yes, ffmpeg can stream audio and video over RTP. And, as far as I know, there are no major issues with this feature... You just need to know how to do it.

Let's see... The simplest command line you can use to generate an RTP session composed by an audio stream and a video stream is:

ffmpeg -re -i input.mpg -vcodec copy -an -f rtp rtp://224.10.20.30:20000 -vn -acodec copy -f rtp rtp://224.10.20.30:30000 -newaudio
Analysing this command line:
  • "-re" is needed to stream the audio and the video at the correct rate (instead of streaming as fast as possible)
  • "input.mpg" is the input file, to be streamed
  • this example just streams the audio and the video tracks without re-encoding them... Hence, "-vcodec copy" and "-acodec copy"
  • we need one output for the video, and one for the audio. Hence, the first output has "-an" (no audio), the second output has "-vn" (no video), and there is a "-newaudio" at the end (add the audio track to the second output)
  • the output format has to be RTP. Hence, "-f rtp"
  • the output protocol, has to be RPT, hence, the output file names are "rtp://:"

If you want to re-encode the audio or the video, you can change "-vcodec copy" and "-acodec copy" with whatever you prefer (for example, "-vcodec mpeg4", or similar).

After you start the ffmpeg program, it will print something like

[...]
Stream #0.1 -> #1.0
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
t=0 0
a=tool:libavformat 52.61.0
m=video 20000 RTP/AVP 32
c=IN IP4 224.10.20.30
b=AS:104857
m=audio 30000 RTP/AVP 14
c=IN IP4 224.10.20.30
b=AS:64
[...]


You need to copy the SDP description (starting with "v=0") in a .sdp file, that you will use to play the stream with vlc, ffplay, mplayer, or your favorite video player.

That's it!!!

More details will probably come in the future...

Friday, 23 October 2009

Am I a slacker?

According to a funny minister of the italian republic, I am a slacker.
However, according to an even more funny minister of the same government, I work for too many hours.
Now, can the two ministers please find an agreement between them and decide if I am working too much, or not enough???
Or, maybe, they are the slackers...

Sunday, 5 July 2009

Thanks for working on this

Once upon a time, when I was a PhD student, I remember this person... When I (or some other student) sent him a report, or a draft of document, or something similar, he used to start his reply with "Thanks for working on this!".
After this good start, he basically destroyed every single part of the document by (rightfully) criticizing a lot of aspects, etc...
So, his emails looked like this:
Hi Luca;
thanks for working on this!
And, BTW, this is wrong ... that should be explained in a different way ... this you did not understand... Please rewrite that...

and so on... And the frustrating thing is that he was right 99% of the time. I always suspected that he used the "thanks for working on this" thing for making all his critics more acceptable.

Now, the scary thing is that few days ago I found myself writing "thanks for working on this" to someone... Does this mean that I crossed the line?

Tuesday, 19 May 2009

Back from vacations

I've been in vacations for about 2 weeks (well, technically, I've been in vacations for 8 days, and then I went to attend a conference), but now I am back.
I'll hopefully post some pictures of my vacations soon.

Thursday, 23 April 2009

A new idea of democracy

I recently discovered that the concept of democracy is rapidly evolving... I was under the impression that democracy consists in discussing various ideas, voting, and deciding according to the results of the vote. But now I discover that today democracy seems to be something like "If I cannot win, I refuse to discuss and to vote".
To me, this looks like a modern reimplementation of the old "I don't play unless I am sure I will win" idea.

Tuesday, 21 April 2009

Internet traffic

According to some reliable data (that I obviously forget to reference in details),
  • 70% of the internet traffic is due to video downloading/streaming/something;
  • 60% of the internet traffic is P2P
  • 30% of the internet traffic is due to spam
  • 20% of the internet traffic is generated by people trying to understand how many cups of tea they can boil with a google query
  • 15% of the internet traffic is generated by people boiling a cup of tea
  • 30% of the internet traffic is generated by people trying to brew some coffee... But for some reason google only works with tea (the ICFM - Internet Coffee Freedom Movement - is working on this)
  • 5% of the internet traffic is generated by people who wanted to microwave some food by pressed the wrong button
  • 3% of the internet traffic does not have an opinion (do not know if this is relevant here, but "does not have an opinion" always sounds good in all kinds of statistics)
Well, I hope there will be at least a small percentage of the internet traffic which is generated by people actually doing some interesting work... Anyway, I guess a good 2% of the internet traffic is generated by people guessing why the sum of the percentages mentioned above is not 100.

Sunday, 12 April 2009

Happy Easter!

Rejoice: Christ is risen.
Have a happy Easter!