源地址:http://lukasz.cepowski.com/devlog/30,iphone-m3u8-segmenter-from-ffmpeg-for-video-streaming

Recent versions of ffmpeg contains a m3u8 segmenter feature which can be used for remuxing video files for streaming over http and watching video on iphone. 

Segmenter feature usage for iphone

Let's say that there is some .ts media file encoded with mpegts codec and we want to segment it for streaming over http. Segmenting is a process where one media container is being converted into set of smaller files with different quality to adjust the current quality to the bandwidth between streaming server and the display, iphone in this case. Segmenter will produce a set of smaller .ts files and a "playlist" .m3u8 which contains urls of the .ts files.

To process media by ffmpeg builtin segmenter run:

  1.  
  2. ffmpeg -re -i source.ts -codec copy -map 0 -f segment -segment_list foo.m3u8 -segment_list_flags +live -segment_time 10 out%03d.ts
  3.  

It will produce .m3u8 playlist and .ts files with segments.
Note that this command will not transcode the video, it will just split data. Source .ts file should be encoded with mpegts codec in order to play it on iphone.

Compile static version of ffmpeg

Following steps are required to build stable static version of ffmpeg-1.0. Tested on debian i386 and amd64.
Based on https://github.com/stvs/ffmpeg-static

Install compiler and essential packages

  1.  
  2. apt-get -y install build-essential pkg-config bzip2
  3.  

Create build and target directories

  1.  
  2. BUILD_DIR="/home/user/build"; export BUILD_DIR
  3. TARGET_DIR="/home/user/target"; export TARGET_DIR
  4. mkdir -p $BUILD_DIR
  5. mkdir -p $TARGET_DIR
  6.  

yasm

  1.  
  2. cd $BUILD_DIR
  3. wget "http://mirror.hellworx.com/yasm/yasm-1.2.0.tar.gz"
  4. tar zxvf yasm-1.2.0.tar.gz
  5. cd yasm-1.2.0
  6. ./configure --prefix=$TARGET_DIR
  7. make -j 4
  8. make install
  9.  

zlib

  1.  
  2. cd $BUILD_DIR
  3. wget "http://mirror.hellworx.com/zlib/zlib-1.2.7.tar.bz2"
  4. tar jxvf zlib-1.2.7.tar.bz2
  5. cd zlib-1.2.7
  6. ./configure --prefix=$TARGET_DIR
  7. make -j 4
  8. make install
  9.  

bzip2

  1.  
  2. cd $BUILD_DIR
  3. wget "http://mirror.hellworx.com/bzip2/bzip2-1.0.6.tar.gz"
  4. tar zxvf bzip2-1.0.6.tar.gz
  5. cd bzip2-1.0.6
  6. make
  7. make install PREFIX=$TARGET_DIR
  8.  

libpng

  1.  
  2. cd $BUILD_DIR
  3. wget "http://mirror.hellworx.com/libpng/libpng-1.2.50.tar.gz"
  4. tar zxvf libpng-1.2.50.tar.gz
  5. cd libpng-1.2.50
  6. CFLAGS="-I$TARGET_DIR/include" LDFLAGS="-L$TARGET_DIR/lib -lm" ./configure --prefix=$TARGET_DIR --enable-static --disable-shared
  7. make -j 4
  8. make install
  9.  

make -j 4
make install

libogg

  1.  
  2. cd $BUILD_DIR
  3. wget "http://mirror.hellworx.com/libogg/libogg-1.3.0.tar.gz"
  4. tar zxvf libogg-1.3.0.tar.gz
  5. cd libogg-1.3.0
  6. CFLAGS="-I$TARGET_DIR/include" LDFLAGS="-L$TARGET_DIR/lib -lm" ./configure --prefix=$TARGET_DIR --enable-static --disable-shared
  7. make -j 4
  8. make install
  9.  

libvorbis

  1.  
  2. cd $BUILD_DIR
  3. wget "http://mirror.hellworx.com/libvorbis/libvorbis-1.3.3.tar.gz"
  4. tar zxvf libvorbis-1.3.3.tar.gz
  5. cd libvorbis-1.3.3
  6. CFLAGS="-I$TARGET_DIR/include" LDFLAGS="-L$TARGET_DIR/lib -lm" ./configure --prefix=$TARGET_DIR --enable-static --disable-shared
  7. make -j 4
  8. make install
  9.  

libtheora

  1.  
  2. cd $BUILD_DIR
  3. wget "http://mirror.hellworx.com/libtheora/libtheora-1.1.1.tar.bz2"
  4. tar jxvf libtheora-1.1.1.tar.bz2
  5. cd libtheora-1.1.1
  6. CFLAGS="-I$TARGET_DIR/include" LDFLAGS="-L$TARGET_DIR/lib -lm" ./configure --prefix=$TARGET_DIR --enable-static --disable-shared
  7. make -j 4
  8. make install
  9.  

libvpx

  1.  
  2. cd $BUILD_DIR
  3. wget "http://mirror.hellworx.com/libvpx/libvpx-v1.0.0.tar.bz2"
  4. tar jxvf libvpx-v1.0.0.tar.bz2
  5. cd libvpx-v1.0.0
  6. PATH="$TARGET_DIR/bin:$PATH" CFLAGS="-I$TARGET_DIR/include" LDFLAGS="-L$TARGET_DIR/lib -lm" ./configure --prefix=$TARGET_DIR --enable-static --disable-shared
  7. PATH="$TARGET_DIR/bin:$PATH" make -j 4
  8. PATH="$TARGET_DIR/bin:$PATH" make install
  9.  

faac

  1.  
  2. cd $BUILD_DIR
  3. wget "http://mirror.hellworx.com/faac/faac-1.28.tar.bz2"
  4. tar jxvf faac-1.28.tar.bz2
  5. cd faac-1.28
  6. CFLAGS="-I$TARGET_DIR/include" LDFLAGS="-L$TARGET_DIR/lib -lm" ./configure --prefix=$TARGET_DIR --enable-static --disable-shared
  7. sed -i -e "s|^char \*strcasestr.*|//\0|" common/mp4v2/mpeg4ip.h
  8. make -j 4
  9. make install
  10.  

x264

  1.  
  2. cd $BUILD_DIR
  3. wget "http://mirror.hellworx.com/x264/x264-snapshot-20120425-2245.tar.bz2"
  4. tar jxvf x264-snapshot-20120425-2245.tar.bz2
  5. cd x264-snapshot-20120425-2245
  6. PATH="$TARGET_DIR/bin:$PATH" CFLAGS="-I$TARGET_DIR/include" LDFLAGS="-L$TARGET_DIR/lib -lm" ./configure --prefix=$TARGET_DIR --enable-static
  7. PATH="$TARGET_DIR/bin:$PATH" make -j 4
  8. PATH="$TARGET_DIR/bin:$PATH" make install
  9.  

xvidcore

  1.  
  2. cd $BUILD_DIR
  3. wget "http://mirror.hellworx.com/xvidcore/xvidcore-1.3.2.tar.gz"
  4. tar zxvf xvidcore-1.3.2.tar.gz
  5. cd xvidcore/build/generic
  6. CFLAGS="-I$TARGET_DIR/include" LDFLAGS="-L$TARGET_DIR/lib -lm" ./configure --prefix=$TARGET_DIR --enable-static --disable-shared
  7. make -j 4
  8. make install
  9.  

lame

  1.  
  2. cd $BUILD_DIR
  3. wget "http://mirror.hellworx.com/lame/lame-3.99.5.tar.gz"
  4. tar zxvf lame-3.99.5.tar.gz
  5. cd lame-3.99.5
  6. CFLAGS="-I$TARGET_DIR/include" LDFLAGS="-L$TARGET_DIR/lib -lm" ./configure --prefix=$TARGET_DIR --enable-static --disable-shared
  7. make -j 4
  8. make install
  9.  

remove shared objects

  1.  
  2. cd $TARGET_DIR/lib
  3. rm -f *.dylib*
  4. rm -f *.so*
  5.  

ffmpeg

  1.  
  2. cd $BUILD_DIR
  3. wget "http://mirror.hellworx.com/ffmpeg/ffmpeg-1.0.tar.gz"
  4. tar zxvf ffmpeg-1.0.tar.gz
  5. cd ffmpeg-1.0
  6. PATH="$TARGET_DIR/bin:$PATH" CFLAGS="-I$TARGET_DIR/include" LDFLAGS="-L$TARGET_DIR/lib -lm" ./configure --prefix=$TARGET_DIR --extra-version=static --disable-debug --disable-shared --enable-static --extra-cflags=--static --disable-ffplay --disable-ffserver --disable-doc --enable-gpl --enable-pthreads --enable-postproc --enable-gray --enable-runtime-cpudetect --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-bzlib --enable-zlib --enable-nonfree --enable-version3 --enable-libvpx --disable-devices
  7. PATH="$TARGET_DIR/bin:$PATH" make -j 4
  8. PATH="$TARGET_DIR/bin:$PATH" make install
  9.  

Download static ffmpeg

You can download static builds of ffmpeg from here:
debian6-i386: http://mirror.hellworx.com/ffmpeg/ffmpeg-static/i386/ffmpeg.bin
debian6-amd64: http://mirror.hellworx.com/ffmpeg/ffmpeg-static/amd64/ffmpeg.bin

[转]Iphone m3u8 segmenter from ffmpeg for video streaming的更多相关文章

  1. 使用OpenCV和imagezmq通过网络实时传输视频流 | live video streaming over network with opencv and imagezmq

    本文首发于个人博客https://kezunlin.me/post/b8847d9f/,欢迎阅读最新内容! live video streaming over network with opencv ...

  2. ffmpeg+nginx+video实现rtsp流转hls流,通过H5查看监控视频

    一.FFmpeg下载:http://ffmpeg.zeranoe.com/builds/ 下载并解压FFmpeg文件夹,配置环境变量:在“Path”变量原有变量值内容上加上d:\ffmpeg\bin, ...

  3. MRPT笔记——MRPT在VS2013中的配置

    Mobile Robot Programming Toolkit (MRPT)是一个跨平台的.开源的C++库,旨在帮助机器人研究员设计和实现SLAM.机器视觉和运动规划(避障)的算法. MRPT为移动 ...

  4. ffmpeg 频中分离 video audio 截取片断

    1.获取视频的信息    ffmpeg -i video.avi 2,将图片序列分解合成视频    ffmpeg -i src.mpg image%d.jpg ffmpeg -f image2 -i ...

  5. ffmpeg把ts文件转m3u8并切片

    Linux_x86_64流媒体环境:nginx + EasyDarwin-master 客户端播放器:VLC media player 下载windows下的ffmepg二进制版本,请进网站http: ...

  6. ffmpeg下载m3u8流媒体

    安装 编译好的windows可用版本的下载地址(官网中可以连接到这个网站,和官方网站保持同步): http://ffmpeg.zeranoe.com/builds/ 该版本为FFMPEG的Static ...

  7. Linux 下使用 ffmpeg 大批量合并 ts 文件, mp4切割文件为m3u8

    见范例 ffmpeg -i "concat:file001.ts|file002.ts|file003.ts|file004.ts......n.ts" -acodec copy ...

  8. ffmpeg m3u8生成 剪辑及格式转换

    使用 ffmpeg 工具, 生成 m3u8 文件 ffmpeg -re -i 03.ts -c copy -f hls -hls_base_url /Users/admin/Downloads/dow ...

  9. 网页前端video播放m3u8(HLS)

    网页前端video播放m3u8(HLS) HLS (HTTP Live Streaming)是Apple公司研发的流媒体传输技术,包括一个m3u8的索引文件.多个ts分片文件和key加密串文件.这项技 ...

随机推荐

  1. javascript系列之执行上下文

    原文:javascript系列之执行上下文 写在前面:一 直想系统的总结一下学过的javascript知识,喜欢这门语言也热爱这门语言.未来想从事前端方面的工作,提前把自己的知识梳理一下.前面写了些 ...

  2. jquery 访问控制菜单

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaHpqOTExOA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA ...

  3. 经典算法题每日演练——第十六题 Kruskal算法

    原文:经典算法题每日演练--第十六题 Kruskal算法 这篇我们看看第二种生成树的Kruskal算法,这个算法的魅力在于我们可以打一下算法和数据结构的组合拳,很有意思的. 一:思想 若存在M={0, ...

  4. linux通过key区别登陆的人

    key区分登录用户 脚本放 /etc/profile.d,会默认登录的时候执行, 类似于 #!/bin/bash # filename: /etc/profile.d/set_log_file.sh ...

  5. Java 实现装饰(Decorator)模式

    在Java在.io反映非常多类包下是典型的装饰格局,例如: new BufferedOutputStream(OutputStream out) new BufferedInputStream(Inp ...

  6. windows+php5.5+apache2.4+tomcat+mod_jk配置

    原因: 通常情况下apache执行的是80port,比方apache启动后执行localhost:80就能够出现It works页面,这里的80也能够不写,会默认的.而tomcat启动时默认的port ...

  7. Python编写网页爬虫爬取oj上的代码信息

    OJ升级,代码可能会丢失. 所以要事先备份. 一開始傻傻的复制粘贴, 后来实在不能忍, 得益于大潇的启示和聪神的原始代码, 网页爬虫走起! 已经有段时间没看Python, 这次网页爬虫的原始代码是 p ...

  8. .net mvc mssql easyui treegrid 及时 编辑 ,支持拖拽

    这里提到了,1个问题,怎么扩展 Easyui 参见: http://blog.csdn.net/chenkai6529/article/details/17528833 @{ ViewBag.Titl ...

  9. hibernate的orphanRemoval

    在@OneToMany与@OneToOne中使用orphanRemoval = true时候 改动保存时候setXXX org.springframework.orm.hibernate3.Hiber ...

  10. git上自然框架源码

    [自然框架]终于把源码弄到git上吗了 2015-02-02 14:38 by 金色海洋(jyk)阳光男孩, 183 阅读, 6 评论, 收藏, 编辑 好久没写博客了,发现又从左面的排名里掉出去了. ...