streaming flv using ffserver

3

I'm running Debian for my home-server, which is a machine that lives under the telly in the living room and stores the family's photo's, videos, music, etc. I'm using all the usual services to serve these up to whoever deserves them, and it all works. So far so good.

Can't get my kids to use things like ftp or even email, to them "the internetz" means a web browser. Firefox usually. So i'm using apache2 to serve cgi pages generated from code compiled by me written in C. And that all works.

So I want to be able to stream the music, films, television recordings, etc. to web browsers, and despite the emergence of the media tag in html5, flash is still really the only practical solution that actually works.

I've been able to get a cgi program to convert mp3's, avi's and suchlike to flash as flv files using ffmpeg, on demand from the user, stored in a temporary file under DOCUMENT_ROOT and the browser will play them, and that works. e.g:

ffmpeg -i "/home/media/Audio/Music Videos/Kylie Minogue - Come Into My World.mpg" -sameq -ab 32k -ar 22050 -ac 2 -s 320x240 -f flv -y ../tmp/file9ltYxj.flv

Okay, so there's no accounting for taste - look i'm heavy metal but this vid is a work of genius! :-) But it's not ideal, for one thing it takes up space creating all these tmp files and for another calling ffmpeg to perform the conversion causes the page load to hang while it completes the task. Which is okay for a five minute music video, but i doubt firefox will wait for a two hour movie to convert using this method.

So i want to stream them instead using ffstream. I'm executing this line (as root):

ffserver -d -f /etc/ffserver.conf &

and the cgi executes this:

ffmpeg -i "/home/media/Audio/Music Videos/Kylie Minogue - Come Into My World.mpg" -sameq -ab 32k -ar 22050 -ac 2 -s 320x240 -f flv -y http://localhost:8090/feed1.flv

and this is where i'm running into trouble. The page loads, the flash embeds but fails to show anything. ffserver reports:

Mon Apr 15 09:29:38 2013 New connection: GET /feed1.flv
Mon Apr 15 09:29:38 2013 192.168.0.33 - - [GET] "/feed1.flv HTTP/1.1" 404 149

I'm getting 404's, but before I was getting 200's before, not sure why that's changed. But whether 404 or 200, the page is the same; Loaded, but no video stream.

I could really do with somebody to ask me further questions (not sure what to add) and hopefully get me up and running with this, because i've not much hair left and my wife wants me to paint the dining room.

Can anyone please advise where I might be going wrong?

Lee

Posted 2013-04-15T08:58:47.970

Reputation: 31

Hi, Lee. Anything in a home setting is unfortunately off-topic for ServerFault but would be more suited to SuperUser. You could either edit out the references to "home", re-ask the question on SuperUser, or wait for it to be migrated. – tombull89 – 2013-04-15T09:02:18.450

Oh, sorry. I'm new and didn't know there was a distinction. When i was taught networking, a server is anything that serves a client. My machine, by that definition, falls into that category. But i'm not gonna argue - migrate me please :-) – None – 2013-04-15T09:09:41.537

Answers

2

In your case FFmpeg must provide the output file as a stream file, since otherwise your file isn't ready yet for streaming. This is usually done using the FFM format:

ffmpeg -i "/home/media/Audio/Music Videos/Kylie Minogue - Come Into My World.mpg" -ab 32k -ar 22050 -ac 2 -s 320x240 -y http://localhost:8090/feed1.ffm

Then in your server.conf file you can stream the FFM feed to an FLV:

<Feed feed1.ffm>
    File /feed1.ffm
</Feed>

<Stream feed1.flv>
    Feed feed1.ffm
    ...
</Stream>

Nick van Tilborg

Posted 2013-04-15T08:58:47.970

Reputation: 775

1-sameq does not mean 'same quality' (and you shouldn't use it) – evilsoup – 2013-04-15T13:21:15.090

Thanks for paying attention evilsoup, I didn't mention it since it was not important for the answer of the question, but I edited it. – Nick van Tilborg – 2013-04-15T13:40:23.363

Now that you've corected that, +1! – evilsoup – 2013-04-15T13:44:57.010

Thanks, evilsoup. In my defense, i had read somewhere that it /did/ mean "same quality" and had no reason to assume otherwise. I've read the link and understood. I shan't use it anymore. – Lee – 2013-04-15T13:56:37.390

Nick van Tilborg - thankyou also, I feel that's made some progress. I'm getting 200's now, which is obviously better. Unfortunately, i'm still not seeing anything on the page though. Just the flash player (OSplayer) "Loading" and revolving dots. Got any idea where i shoudl look next? – Lee – 2013-04-15T13:58:21.550

Code 200 seems ok. I never worked with OSplayer, but you can try to open the stream with something like VLC. Also take a look at Streaming media with FFserver. If you then can't get out you can ask a new question, containing at least your server.conf file and the FFmpeg output.

– Nick van Tilborg – 2013-04-15T14:07:02.457