HTTP Live Streaming, FFMPEG & FFSERVER, and iPhone OS 3
Asked Answered
T

4

19

In iPhone OS 3, Apple has introduced HTTP Live Streaming which should allow live streaming of video from the internet. I am currently operating a webcam, which feeds into my server, and is then converted into a flv stream by ffmpeg, and streamed back out using ffserver. Does anyone know how to setup a video stream the iPhone can use using ffmpeg and ffserver? I should be able to re-encode into just about any format on the fly.

Tiruchirapalli answered 7/7, 2009 at 17:29 Comment(0)
A
22

You'll need to build a copy of ffmpeg with a version >= e109a29d6ddb02b2dd58c6c385ebec27f2d23b58 (git) or 18793 (svn). Make sure you also specify the --enable-libx264 flag when you're building. Once you've got that up and running, you can do roughly the following:

ffmpeg -i <input video> -acodec libmp3lame -ac 1 -vcodec libx264 -s 320x240 \
       -level 30 -f mpegts - | \
segmenter - 10 test test.m3u8 http://example.com/path/to/your/files/

i.e. Bring an input file or stream into ffmpeg and pipe an H.264 video with MP3 audio into Apple's segmenter. The segmenter spits out segmented video files and M3U playlists pointing to the segmented files. You'd serve the segmented files and playlists via a web server like Apache.

Obviously you'll want to tweak the ffmpeg and segmenter options substantially to get the results you're after.

Amplitude answered 8/7, 2009 at 13:52 Comment(4)
Any windows server solutions?Brittbritta
Anyone got this actually working with a live stream from a dv source yet? I've been trying and keep getting errors from the segmenter...Bendigo
I found that FFmpeg version SVN-r21627 works with the open source segmenter code.google.com/p/httpsegmenter Does anyone have an idea about what changed since that version?Inheritable
How to set some duration or size to ffmpeg/ffserver, that purge creating file, and making it again from 0 size/time and purge it again if size/time is bigger that X and build it again and again and ...?Gallia
S
12

For those who are interested I've bundled an open source segmenter with a script that will let you use ffmpeg to do this, see my segmented streaming on the iphone project. It can do multi-bitrate segments for the input streams and will transfer the stream segments to a configurable destination via scp, ftp and even up to aws s3.

Spinous answered 30/7, 2009 at 13:26 Comment(0)
P
3

This is quite an old topic, but HLS support, a seemingly new feature of FFmpeg might be useful to someone.

An example use would be as follows:

ffmpeg -i <input_file> -c:v libx264 -preset slow -map 0 -an -flags -global_header -f hls -hls_time <segment_length> <m3u8_file>

If you would like to do live streaming, this would be another example:

ffmpeg -i <input_stream> -c:v libx264 -preset ultrafast -map 0 -an -flags -global_header -f hls -hls_time <segment_length> -hls_list_size <playlist_entries> -hls_wrap <wrap> <m3u8_file>

The -hls_list_size argument limits the number of files in the playlist, and the -hls-wrap argument limits the number of files total and will wrap filenames once it gets to that point (ex: test0.ts, test1.ts... test7.ts, test0.ts, test1.ts... when wrap is 8).

For more information, see the documentation. Please note, the above examples strip out audio with the -an flag, as I personally never needed it.

Phosphorus answered 18/5, 2014 at 13:8 Comment(1)
Looks nice, but it seems taht the output format is incorrect for HLS; I get "Missing plugin" when looking at the m3u8 file with Safari?Bushido
S
0

What's wrong with using QuickTime to convert movies to "iPhone" format? You just do File > Export > iPhone format... Am I missing something?

After converting to iPhone format, I chop it up with mediafilesegmenter (found at Apple Developer Connection, Http Live Streaming Tools):

mediafilesegmenter -t 10 -f folderName/ nameOfInputFile.m4v

(Note: the folderName/ folder must exist)

Then point your iPhone to a website with

<video src='folderName/prog_index.m3u8' height=45 width=70 
       controls='on'>Your browser does not support the video tag</video>
Specular answered 23/4, 2010 at 6:56 Comment(1)
@Specular Your link is dead.Displayed

© 2022 - 2024 — McMap. All rights reserved.