Tuesday, 7 June 2011

FFMpeg and H.264 over RTP

As some people trying my previous "ffmpeg RTP" recipe might have noticed, there might be problems when streaming H.264 over RTP and using "out-of-band" PPS and SPS (AKA global headers).

More practically, something like
ffmpeg -re -i file.mp4 -vcodec copy -an -f rtp rtp://127.0.0.1:10000
(with file.mp4 containing H.264 video) will not work.

I have a very elegant patch to address such issue, but the margin of this blog is too small to contain it... Seriously, I'll post it as soon as I learn how to attach patches to a blog entry.

Monday, 15 November 2010

Working day

A day at work:
  • I arrive around 8AM... Today, I only need to read and comment two papers, prepare a lesson, and give it
  • 8:10: I need to read the two papers... Ok, let's print them. Unfortunately, the printer is out of paper.
  • 8:11: search for some paper...
  • 8:40: after a long quest, found some paper
  • 8:45: the papers are printed. Start to read them
  • 9:05: "you got mail"... Some problems with a web server not working. But the admins say it's working, and all the issues are just imagination. I need to reproduce the issues to give the admins some evidence.
  • 9:50: looks like the web server admins are already aware of the issues... But they keep saying that using a web server for distributing something via http is an improper usage of the server, and so the server might fail. For example, the objects to be distributed are in the "public_html" directory, and the user can delete them... So, the server is supposed to fail. Ok, I need some coffee to understand what the hell they are talking about.
  • 10:00: got some coffee, restart to read the sysadmins emails
  • 10:30: I need another coffee. Now the problem seems to be related to the network unreliability.
  • 10:40: Ok, got it: everything is supposed to fail, by design. I can restart reading my papers
  • 10:50: department report. Everyone is supposed to have 5 papers mentioned in the report; I do not care, so I did not recommend any paper for inclusion. But now they somehow have a list of 10 of my papers, candidate for inclusion. And I can have only 5 papers in the report... So, someone comes to my office asking for an advice. I do not even know where this list of 10 paper is coming from, so I do not know what to say...
  • 11:00: after wasting some time discussing about these 10 papers which should be 5 but I do not care so they can be 0 but they have a list of 10, I realise that it will take some time... So, let's discuss. Maybe I can even have some fun with this stuff... So, my co-worker in the next office also has some papers; let's ask his opinion too...
  • 11:05: the cell phone rings. Small problems at home, nothing really serious
  • 11:10: I leave to other people the discussion about the department report and the 5 papers to be cited... wasted 20 minutes, but had some fun
  • 11:15: try to return to the famous 2 papers... But new emails are coming.
  • 11:20: need to discuss via email some trivial details about software design
  • 11:55: the discussion resulted to be longer than expected... Not finished yet, but now I need another coffee
  • 12:05: lunch
  • 12:35: return to the discussion (erm... Delirium) about software design. Other wasted time
  • 12:50: really need to prepare the lesson
  • 13:50: go to the lesson
  • 16:00: end of the lesson
  • 16:05: now, I have to go and talk with the people experiencing the (in)famous web server problem. Need to explain that the problem is just imagination. Or to find a testcase that can be reliably reproduced.
  • 16:30: I give up. Time to go home
  • 17:20: At home. Still thinking about web services, department reports, software design... I would need another coffee, but that wouldn't be too healthy. Go for jogging instead.
  • 18:10: Back from jogging
  • 18:25: After a shower, more relaxed... Now, I'd like to do something useful... Maybe some research... I still have those 2 papers to read.
  • 19:30: Dinner
  • 20:00: I finally finish to read the two damned papers!

Thursday, 4 November 2010

What happened?

So, I've been silent since about April...
If anyone is reading this blog, they might wonder what happened... It happened that I am a happy man, now (well, I was happy in the past, too... But now I am happier).
This consumed almost all of my summer (and some of my autumn... :), but I really think it was worth it!

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!

Sunday, 8 March 2009

It's only work...

Thanks to some recent happenings, I realised that I was giving too much importance to my job. Of course, working is part of my life (and I like my job), but it is not the most important part: I have other dreams, hopes, problems, expectations, joys, etc... in my life, and working is not part of them.

The fact that some of my dreams were about my job is scary... Hopefully, I fixed this before it became a real problem. And I am enjoying real life!

Thursday, 5 March 2009

I had a dream...

I had a dream... A dream about a university where students can actually learn something, where professors care about the students and about the quality of the courses, where doing research can still be fun... A place where you can enjoy working, where the grass is green and girls are pretty (wops... Sorry, this is a different song :).

And now, reality check: in real world, only money, politics and similar things are important. So, I just had a dream. I stopped dreaming, and back to reality. No problems: I am pretty sure I'll manage to survive.

Wednesday, 18 February 2009

Broken ski binding




Last Sunday the weather was good, so I decided to go skiing...
Unfortunately, something went terribly wrong; I am ok, but I cannot say the same about the ski binding (as you can see from the picture).

Tuesday, 17 February 2009

Confusion about technology

I think in these days there is some confusion about technology:
  • it is not uncommon to hear people saying things like "I want to take a picture... Can you give me your cell phone?"
  • on the other hand, there are people that turn on the computer and use skype to make a phone call
  • finally, I have to pay a "tv tax" (canone rai) because I own a computer...
Now, I hope to see someone using a photo camera to watch tv, so that the circle is closed...

Friday, 13 February 2009

Starting to blog

Ok; sometimes I feel bored and I decide to try something new...
Let's try blogging and let's see how it goes