简体   繁体   English

HTTP Live Streaming,FFMPEG和FFSERVER以及iPhone OS 3

[英]HTTP Live Streaming, FFMPEG & FFSERVER, and iPhone OS 3

In iPhone OS 3, Apple has introduced HTTP Live Streaming which should allow live streaming of video from the internet. 在iPhone OS 3中,Apple推出了HTTP Live Streaming ,它允许从互联网直播视频。 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. 我目前正在操作一个网络摄像头,它将输入到我的服务器中,然后由ffmpeg转换为flv流,然后使用ffserver进行流式传输。 Does anyone know how to setup a video stream the iPhone can use using ffmpeg and ffserver? 有谁知道如何使用ffmpeg和ffserver设置iPhone可以使用的视频流? I should be able to re-encode into just about any format on the fly. 我应该能够动态地重新编码成任何格式。

You'll need to build a copy of ffmpeg with a version >= e109a29d6ddb02b2dd58c6c385ebec27f2d23b58 (git) or 18793 (svn). 您需要使用版本> = e109a29d6ddb02b2dd58c6c385ebec27f2d23b58(git)或18793(svn)构建ffmpeg的副本。 Make sure you also specify the --enable-libx264 flag when you're building. 确保在构建时也指定--enable-libx264标志。 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/

ie Bring an input file or stream into ffmpeg and pipe an H.264 video with MP3 audio into Apple's segmenter. 即将输入文件或流输入ffmpeg并将带有MP3音频的H.264视频传输到Apple的分段器中。 The segmenter spits out segmented video files and M3U playlists pointing to the segmented files. 分段器吐出分段视频文件和指向分段文件的M3U播放列表。 You'd serve the segmented files and playlists via a web server like Apache. 您可以通过Apache等Web服务器为分段文件和播放列表提供服务。

Obviously you'll want to tweak the ffmpeg and segmenter options substantially to get the results you're after. 显然你会想要大幅调整ffmpeg和segmenter选项以获得你想要的结果。

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. 对于那些感兴趣的人,我已经捆绑了一个开源分段器,其脚本可以让你使用ffmpeg来实现这一点,看看我在iphone项目上的分段流 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. 它可以为输入流做多比特段,并通过scp,ftp甚至高达aws s3将流段传输到可配置的目的地。

This is quite an old topic, but HLS support, a seemingly new feature of FFmpeg might be useful to someone. 这是一个相当古老的主题,但HLS支持,FFmpeg的一个看似新的功能可能对某人有用。

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). -hls_list_size参数限制播放列表中的文件数, -hls-wrap参数限制文件总数,一旦到达该点,将包装文件名(例如:test0.ts,test1.ts ... test7 .ts,test0.ts,test1.ts ...当换行时为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. 请注意,上面的示例使用-an标记-an音频,因为我个人从不需要它。

What's wrong with using QuickTime to convert movies to "iPhone" format? 使用QuickTime将电影转换为“iPhone”格式有什么问题? You just do File > Export > iPhone format... Am I missing something? 你只需要文件>导出> iPhone格式...我错过了什么?

After converting to iPhone format, I chop it up with mediafilesegmenter (found at Apple Developer Connection, Http Live Streaming Tools ): 在转换为iPhone格式之后,我将其与mediafilesegmenter(在Apple Developer Connection,Http Live Streaming Tools中找到 )进行切割:

mediafilesegmenter -t 10 -f folderName/ nameOfInputFile.m4v

(Note: the folderName/ folder must exist) (注意:folderName /文件夹必须存在)

Then point your iPhone to a website with 然后将您的iPhone指向一个网站

<video src='folderName/prog_index.m3u8' height=45 width=70 
       controls='on'>Your browser does not support the video tag</video>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM