编译安装hls协议切片工具 m3u8-segmenter

操作系统:Ubuntu16.04.4 amd64

安装http://m3u8-segmenter.inodes.org/方式安装m3u8-segmenter报错,于是有了这篇文章

apt install aptitude
apt-add-repository ppa:johnf-inodes/m3u8-segmenter
aptitude update
apt-get install m3u8-segmenter

其中在更新下载源的过程中报错:

root@ubuntu:/home/tomcat# aptitude update
Hit http://mirrors.aliyun.com/ubuntu xenial InRelease
Hit http://mirrors.aliyun.com/ubuntu xenial-updates InRelease                                                                                                                                                  
Hit http://mirrors.aliyun.com/ubuntu xenial-backports InRelease                                                                                                                                                 
Hit http://mirrors.aliyun.com/ubuntu xenial-security InRelease                                                                                       
Hit http://archive.ubuntu.com/ubuntu xenial InRelease                
Ign http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial InRelease
Hit http://archive.canonical.com/ubuntu xenial InRelease                                          
Hit http://ppa.launchpad.net/linuxuprising/java/ubuntu xenial InRelease
Ign http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial Release
Err http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial/main amd64 Packages
  404  Not Found [IP: 91.189.95.83 80]
Ign http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial/main i386 Packages
Ign http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial/main all Packages
Ign http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial/main Translation-en_US
Ign http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial/main Translation-en
W: The repository 'http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial Release' does not have a Release file.
W: Failed to fetch http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu/dists/xenial/main/binary-amd64/Packages: 404  Not Found [IP: 91.189.95.83 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.

root@ubuntu:/home/tomcat# aptitude update
Hit http://mirrors.aliyun.com/ubuntu xenial InRelease
Hit http://mirrors.aliyun.com/ubuntu xenial-updates InRelease                                                                                               
Hit http://mirrors.aliyun.com/ubuntu xenial-backports InRelease                                                                                                                                                                        
Hit http://mirrors.aliyun.com/ubuntu xenial-security InRelease                                                                                                                      
Hit http://archive.ubuntu.com/ubuntu xenial InRelease                                                                                                                                
Hit http://archive.canonical.com/ubuntu xenial InRelease
Ign http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial InRelease
Hit http://ppa.launchpad.net/linuxuprising/java/ubuntu xenial InRelease
Ign http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial Release
Err http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial/main amd64 Packages
  404  Not Found [IP: 91.189.95.83 80]
Ign http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial/main i386 Packages
Ign http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial/main all Packages
Ign http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial/main Translation-en_US
Ign http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial/main Translation-en
W: The repository 'http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu xenial Release' does not have a Release file.
W: Failed to fetch http://ppa.launchpad.net/johnf-inodes/m3u8-segmenter/ubuntu/dists/xenial/main/binary-amd64/Packages: 404  Not Found [IP: 91.189.95.83 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.

root@ubuntu:/home/tomcat# apt-get install m3u8-segmenter
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package m3u8-segmenter

笔者的安装方法:

apt install curl build-essential automake automake1.11 libavformat-dev pkg-config ffmpeg
cd /usr/src
curl https://codeload.github.com/m3u8-segmenter/m3u8-segmenter/tar.gz/v1.0.2 -o m3u8-segmenter.v1.0.2.tar.gz
 tar -zxvf m3u8-segmenter.v1.0.2.tar.gz     
#安装m3u8-segmenter
aclocal
autoreconf
automake -ac
./configure
make
sudo make install

安装截图

 

 centos7安装命令:

yum install  gcc make nasm pkgconfig wget curl curl-devel zlib-devel openssl-devel perl cpio expat-devel gettext-devel libtool mhash.x86_64 perl-Digest-SHA1.x86_64  pcre.i386 pcre.x86_64 pcre-devel.i386 pcre-devel.x86_64
curl https://codeload.github.com/m3u8-segmenter/m3u8-segmenter/tar.gz/v1.0.2  -o m3u8-segmenter.v1.0.2.tar.gz
    

 tar -zxvf m3u8-segmenter.v1.0.2.tar.gz
     
#安装m3u8-segmenter
aclocal
automake -ac
./configure
make
sudo make install

 windows版本

https://github.com/godka/m3u8-segmenter-for-Windows

 可供测试下载视频:http://media.speech.zone/video/Speech_Processing_synthesis-TDPSOLA-21m37s.mp4

使用方法:

# -ar采样率 audio sampling rate
#  -ab 比特率
#  -vn disable video


#1、视频分片

ffmpeg -i Spring_Insight-Milestone_3-Screencast.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb | m3u8-segmenter -i - -n 10 -p screencast -m playlist.m3u8 --u http://example.org/video/

ffmpeg -i Spring_Insight-Milestone_3-Screencast.mp4 -vbsf mpegts | m3u8-segmenter -i - -n 10  -p /tmp/big_buck_bunny -m /tmp/big_buck.m3u8 -u http://inodes.org/bigbuck/

  ffmpeg -loglevel quiet  -i Spring_Insight-Milestone_3-Screencast.mp4 -f mpegts - | \
  m3u8-segmenter -i - -d 20 -p /tmp/big_buck_bunny -m /tmp/big_buck.m3u8 -u http://inodes.org/bigbuck/

ffmpeg -er 4 -i input.mp3 -f mpegts -acodec libmp3lame -ar 22050 -ab 32k -vn - | \
  m3u8-segmenter -i - -d 10 -p outputdir/prefix -m outputdir/output.m3u8 -u http://domain.com/

#2、音频分片

ffmpeg -er 4 -i output.wav -f mpegts -acodec pcm_s16le -ar 22050 -ab 256k -vn - | \
  m3u8-segmenter -i - -d 10 -p /tmp/outputdir/prefix -m /tmp/outputdir/output_wav.m3u8 -u http://domain.com/
  
  ffmpeg -er 4 -i output.wav -f mpegts -acodec pcm_s16le -ar 22050 -ab 256k -vn - | \
  m3u8-segmenter -i - -d 10 -p outputdir/prefix -m outputdir/output_wav.m3u8 -u http://domain.com/
  
  ffmpeg -er 4 -i output.wav -f mpegts -acodec pcm_s16le -ar 22050 -ab 256k -vn - | m3u8-segmenter -i - -d 10 -p outputdir/prefix -m outputdir/output_wav.m3u8 -u http://domain.com/
  
  ffmpeg -i output.wav -f mpegts -acodec pcm_s16le -ar 22050 -ab 256k -vn - | \
  m3u8-segmenter -i - -d 10 -p outputdir/prefix -m outputdir/output.m3u8 -u http://domain.com/

以上代码来自网络,由于过去时间太久,记不起来源。版权归原作者所有

猜你喜欢

转载自www.cnblogs.com/passedbylove/p/11850846.html
今日推荐