Linux_x86_64流媒体环境:nginx + EasyDarwin-master

客户端播放器:VLC media player

下载windows下的ffmepg二进制版本,请进网站http://ffmpeg.zeranoe.com/builds/win32/shared|static 最新版本,无需自己编译。

下载完解压后,需要配置ffmepg的path环境变量。Path=%Path%;E:\ffmpeg-20151117-git-e9aea6d-win64-static\ffmpeg-20151117-git-e9aea6d-win64-static\bin

下面流转换和切片的方式:

ffmpeg -ss 01:00:00 -i input_file_h264.mp4 -vcodec copy -acodec copy -t 00:06:00 output_file.mp4

------------------------------

利用ffmpeg将已有的视频文件转换成ts文件

  ffmpeg -y -i <in file> -vcodec copy -acodec copy -vbsf h264_mp4toannexb <output file>

其中in file为待转换的视频文件,比如input.mov,output file为转换后的文件,要命名为output.ts

利用segmenter将转换好的ts文件切割成多个ts片,并生成.m3u8的索引文件

  ./segmenter -i out.ts -n 10 -p segmenter_test -m test.m3u8 -u #需要安装segmenter包

i表示输入文件,n表示切割10秒,p表示切割文件的前缀。m表示生成的m3u8文件名,u表示这些切割后的文件处于web server的哪个目录下

PS:实践过程中发现一个问题,就是切片之后,最后一段ts不管是不是10s,同样会按10s去切,导致切好后的视频最后一段会加上去几秒的黑段来补足10s,原因是segmenter.c中的程序写的还有缺陷,修正方法如下:

---------------------------
ffmepg把ts文件转m3u8并切片:
ffmpeg -i xx.ts -c copy -map 0 -f segment -segment_list playlist.m3u8 -segment_time 10 output%03d.ts

大家都说HLS代表future,rtsp已经是过去式了。

怎么分割并转换为h264编码呢?
先把ts流中的格式转换对,可以用以下命令试试:
ffmpeg -i your.ts -acodec copy -vcodec libx264 new.h264.ts

-----------------------------

ffmpeg -i xxxxx.ts -hls_time 10 -hls_list_size 10 -f hls xxxx.m3u8

-----------------------------

以下是笔者的方法:

ffmpeg -y -i bs.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb bs2.ts

ffmpeg -i bs2.ts -c copy -map 0 -f segment -segment_list playlist.m3u8 -segment_time 3 output%03d.ts

ffmpeg把ts文件转m3u8并切片的更多相关文章

  1. ffmpeg转MP4文件为m3u8格式

    第一种转换命令 #转mp4为ts ffmpeg -y -i D:\videos\BgFCWkn00qPBmWVzIEf0eQjaekx0oRjlk9VY2PcR.mp4 -vcodec copy -a ...

  2. 网络视频m3u8解密及ts文件合并

    网络视频m3u8解密及ts文件合并 参考了两篇博客: https://blog.csdn.net/weixin_41624645/article/details/95939510 https://bl ...

  3. ffmpeg文件生成m3u8文件及ts切片程序(一)

    ffmpeg文件生成m3u8文件及ts切片程序(一) 实现目标:输入本地文件,实现m3u8切片,功能点请看注释,注意:注释很重要. 参考: http://www.cnblogs.com/mystory ...

  4. ffmpeg 视频ts切片生成m3u8

    下面几种转换方式是不同版本和方法 新版本ffmpeg转视频直接可以切边并生成 m3u8(目前用的方式,也可以用选项 segment ): ffmpeg -i '源文件.mp4' -c:v h264 - ...

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

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

  6. 加密的m3u8、ts文件合并

    加密后的ts文件不能直接合并或播放,需要使用key对每个ts文件进行解密. 分为两种情况: (1).如果ts文件已经全部下载好,则可以直接在本地通过ffmpeg快速解密合并. (2).如果ts文件没有 ...

  7. 关于m3u8文件, ts文件解密, hls 解密. 一些记录

    使用openssl 解密 openssl aes-128-cbc -d -in 原.ts -out 解密后.ts -nosalt -iv 偏移量 -K key16进制 其中 iv 偏移量和 key 一 ...

  8. 指定一个M3U8文件,判断它包含的TS文件是不是都存在。指定一个Office生成的Swf文件,判断它包含的Swf文件是不是完整都存在。

    static void Main(string[] args) { //检查M3u8文件 var fiPath = @"D:\Work\CloudPlatformUtil\CloudPlat ...

  9. Python3 根据m3u8下载视频,批量下载ts文件并且合并

    Python3 根据m3u8下载视频,批量下载ts文件并且合并 m3u8是苹果公司推出一种视频播放标准,是一种文件检索格式,将视频切割成一小段一小段的ts格式的视频文件,然后存在服务器中(现在为了减少 ...

随机推荐

  1. 对象序列化为何要定义serialVersionUID的来龙去脉

    在很多应用中,需要对某些对象进行序列化,让它们离开内存空间,入住物理硬盘,以便长期保存.比如最常见的是Web服务器中的Session对象,当有10万用户并发访问,就有可能出现10万个Session对象 ...

  2. iOS five years[转]

    原文链接:http://blog.ayaka.me/post/127980091987/5-years This morning, I got a push notification from Tim ...

  3. html超链接,锚点以及特殊字符

    超链接 <a></a>中不加东西是显示不了的. href:跳转的地址 target:_self(本页面打开,默认选项),_blank(新页面打开) title:文本提示 空链接 ...

  4. Extjs4.x MVC开发模式,效率提高的两大秘诀

    最近做MVC开发的,遇到一个蛋疼的问题,每次加载模块都需要耗时3~4秒钟,才可以显示出完整的页面,通过监控,发现主要还是在Controller里慢,加载js文件等都是非常快的,但一到controlle ...

  5. mysql查看不同级别的字符集

    库的字符集: SELECT default_character_set_name FROM information_schema.SCHEMATA SWHERE schema_name = 'test ...

  6. 多线程三:Task

    Task是.NET 3.0中推出的,是基于ThreadPool封装的,里面的线程都是来自于ThreadPool. 1.使用Run()方法启动线程 F12查看Run()方法的定义: 发现Run()方法的 ...

  7. Spring Cloud / Spring Boot There was an unexpected error (type=Unauthorized, status=401). Full authentication is required to access this resource.

    访问EndPoint时会出现没有权限   There was an unexpected error (type=Unauthorized, status=401). Full authenticat ...

  8. PCL点云特征描述与提取(4)

    如何从一个深度图像(range image)中提取NARF特征 代码解析narf_feature_extraction.cpp #include <iostream> #include & ...

  9. R语言 data.frame 大全

    A data frame is used for storing data tables. It is a list of vectors of equal length. For example, ...

  10. 数据框排序 data.frame order

    # sorting examples using the mtcars datasetattach(mtcars) # sort by mpgnewdata <- mtcars[order(mp ...