views:

951

answers:

2

This is related to my another question

Here I'd like to ask if it is in theory (according to video file formats and codecs, etc) possible to have such scenario:

1) Client on iPhone has a reference to video in flv format. It sends http request to converting "proxy" like http://convproxy.com?source=url_of_original_video.flv by just clicking such link in Safari

2) Converting proxy starts downloading that flv file and converting it to mp4 (which iphone understands) on the fly, returning converted portion as http response, so iPhone can immediately start playing it, before entire flv is downloaded and converted.

I was playing with ffmpeg trying to do such thing, and it indeed converts flv and produces mp4 file, however that mp4 file can not be played until convertion is finished or ffmpeg is stopped. If I just kill ffmpeg process the mp4 file can not be played. If I let it finish or press ctrl-c to stop it, the part that was downloaded and converted can be played. Seems like ffmpeg does some job after it receives stop signal. Is that a necessary part of mp4 format or it can be done differently? I see that iPhone can stream video, by starting playing before the entire file is downloaded to it, so in general it seems like possible scenario for me.

I short words, I can convert flv file to mp4 file, and the question is if I can convert flv stream to mp4 stream.

+1  A: 

According to wikipedia, the MP4 container format requires a separate "hint track" to enable streaming. I assume ffmpeg writes this at the end of the conversion. If the iPhone OS requires this track to stream, I don't see a way to stream live video outside of using a different format and having a custom decoder on the iPhone side similar to how the Orb client for iPhone does it.

rpetrich
Thanks for pointing this out, I missed it somehow. Anyway, if I kill ffmpeg process, the result mp4 file can not be played at all, not only by iphone. So looks like ffmped adds something even more necessary than hint track.
Pavel Feldman
And if I let ffmpeg finish its work or stop it instead of terminating, produced mp4 can be streamed.
Pavel Feldman
Sounds like some basic header information that gets written at the end of the conversion or when aborted gracefully. Perhaps some of this can be pregenerated (frame count, length, etc) and some faked (file size, bitrate information, etc)? I think you'd have to hack the ffmpeg/x264 sources to do this. You might also want to try VideoLAN as it was built for streaming right from the get-go.
rpetrich
A: 

Hi I would like to ask if we have FLv files , how can we make its segments? Do we have to first convert it to .Mp4 and then make its segments?

Saibi Rocker