1

I'm trying to teach myself a bit about video streaming and transcoding, with some Roku app development on the side. I have a number of video files (mostly in FLV format (H.264/AAC)) that I would like to stream to a client, which in this case is a Roku box (that accepts MP4 (H.264/AAC) and HTTP Live Streaming (HLS)). I'm wondering if it is possible to transcode/remux the FLV files and stream them to the client on the fly, perhaps over HLS?

I have tried using ffmpeg to remux the files and serve them immediately during the transcoding process, but they are unplayable until the write process is complete. I can get the Roku to play my completed MP4 files just fine via Apache/Rails.

But I'm wondering... is it possible to set up a server to transcode/remux a file and immediately have the output file (from ffmpeg/whatever tool I'm using) streamed to the client? If so, what tools are required to accomplish this? Is it possible to use a media file segmenter to chop up a file as it's being transcoded or remuxed?

I'm well aware that the transcoding process is CPU intensive, but I'm not so much worried about the practicality of transcoding and streaming on the fly since this is simply a personal education project (and I have an idle system that is capable if handling this).

Apologies if I'm way off base here, just trying to hack my way through this.

Thanks!

Threeve
  • 63
  • 6
  • If you haven't seen it already, the [FFmpeg docs on streaming MOV/MP4](http://ffmpeg.org/ffmpeg.html#MOV_002fMP4_002fISMV) are good reading for some background on this sort of problem. – blahdiblah Jul 31 '12 at 02:15

1 Answers1

1

The trick to getting HLS served immediately that a TS segment has been completed is getting the playlist to dynamically update as the data arrives on disk.

What you are trying to do is essentially stream a Live event over HLS, which absolutely can be done, it just takes co-ordination between tools.

The opensource segmenter is able to do this, the trick is to have ffmpeg write out a single MPEG-TS stream (Unsegmented) and write this to a named pipe (Or equivalent for your OS), then have segmenter read from this named pipe and write the files to a directory within your shared webspace.

The segmenter repeatedly updates the M3U8 file on disk while processing so it can be used as a "Live" stream until the task is finished.

When ffmpeg closes its output the segmenter puts the end tag in the M3U8 and the file becomes "VOD".

The segmenter can be downloaded here

Haqa
  • 476
  • 3
  • 14