健康一贴灵,专注医药行业管理信息化

centos7 安装 ffmpeg踩坑后纪

从网上看了一篇在LINUX上安装FFMPEG作为流媒体服务器的文章后,不知深浅的照着教程来学,一个坑接一个坑。

1、我看的教程原文,写的非常好,;

https://www.jianshu.com/p/b1680d3ecd4f

2、修路填坑之旅(小白的电脑什么都没有装 );

  首先, 先要安装 gcc,再要安装x264,还要装 yasm 

  •  错误1,遇到 cannot load libcuba.so.1错误,加入
  •  错误2 : libx264.c 文件中, 头文件大小写引起的错误,要将x264_bit_depth 替换成 X264_BIT_DEPTH
  •  错误3: ffmpeg: error while loading shared libraries: libavdevice.so.57: cannot open shared object file: No such file or director

 

 附1:乱七八遭的安装代码

   1  echo "source /opt/rh/devtoolset-11/enable" >>/etc/profile
    2  gcc --version
    3  reboot
    4  ls
    5  yum list installed | grep openssh-server
    6  yum list installed | grep openssh
    7  ls
    8  cd /
    9  ls 
   10  cd usr
   11  ls
   12  cd local
   13  wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
   14  yum install wget
   15  wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
   16  tar -xvf yasm-1.3.0.tar.gz 
   17  cd yasm-1.3.0
   18  ./configure && make && make install
   19  cat conifg.log
   20  yum install -y centos-release-scl centos-release-scl-rh
   21  vi /etc/yum.repos.d/CentOS-Base.repo
   22  mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
   23  curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
   24  yum clean all 
   25  yum makecache
   26  yum list updates
   27  yum -y update
   28  gcc --version
   29  yum -y install centos-release-scl
   30  yum -y install devtools-11-gcc 
   31  yum -y install devtoolset-11-gcc devtoolset-11-gcc-c++ devtoolset-11-binutils
   32  scl enable devtoolset-11 bash
   33  gcc --ver
   34  gcc --version
   35  ls 
   36  cd /usr/local
   37  ls
   38  cd yasm-1.3.0
   39  ls
   40  ./configure && make && make install
   41  cd ..
   42  ls
   43  wget http://wwww.ffmpeg.org/releases/ffmpeg-3.4.tar.gz
   44  wget http://www.ffmpeg.org/releases/ffmpeg-3.4.tar.gz
   45  tar -xvf ffmpeg-3.4.tar.gz 
   46  cd ffmpeg-3.4
   47  ./configure && make && make install
   48  ls
   49  ffmpeg -ver
   50  ffmpeg -version
   51  cd ..
   52  yum install nginx
   53  find / -name nginx
   54  rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
   55  cd /etc/yum.repos.d
   56  ls
   57  yum install -y nginx
   58  nginx
   59  systemctl stop firewalld
   60  systemctl status firewalld
   61  ngnix
   62  nginx
   63  systemctl enable nginx
   64  cd /usr/share/nginx
   65  cd html
   66  ls
   67  ffmpeg -version
   68  ffmpeg -i test.mp4 -hls_time 10 -hls_list_size 0 -hls_segment_filename ./hls/test_%05d.ts ./hls/test.m3u8
   69  find / -name libcuda.so.1
   70  find / -name libcuda.so
   71  find / -name libcuda
   72  cd /home
   73  cd /usr
   74  ls
   75  cd local
   76  git clone http://git.videolan.org/git/x264.git
   77  yum install git
   78  git clone http://git.videolan.org/git/x264.git
   79  ls
   80  cd x264
   81  ./configure --enable-shared --disable-asm
   82  make
   83  make install
   84  cd /
   85  cd /usr
   86  ls
   87  cd local
   88  ls
   89  cd ffmpeg-3.4
   90  ls
   91   ./configure --enable-shared --disable-yasm --enable-libx264  --enable-gpl  --prefix=/usr/local/
   92   ./configure --enable-shared --enable-x86asm / --disable-x86asm  --enable-libx264  --enable-gpl  --prefix=/usr/local/
   93   ./configure --enable-shared --enable-x86asm  --disable-x86asm  --enable-libx264  --enable-gpl  --prefix=/usr/local/
   94   ./configure --enable-sharedm  --disable-x86asm  --enable-libx264  --enable-gpl  --prefix=/usr/local/
   95   ./configure --enable-shared   --disable-x86asm  --enable-libx264  --enable-gpl  --prefix=/usr/local/
   96  export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
   97  echo $PKG_CONFIG_PATH
   98  ./configure --disable-yasm --enable-libx264 --enable-swscale --enable-avresample --enable-gpl --enable-sharedsudo make && make install
   99   ./configure --disable-yasm --enable-libx264 --enable-swscale --enable-avresample --enable-gpl --enable-shared
  100   ./configure --enable-shared   --disable-x86asm  --enable-libx264  --enable-gpl  --prefix=/usr/local/
  101  make && make install 
  102  find / libx264.c
  103  find / -name libx264.c
  104  cd libvcodec
  105  cd libavcodec
  106  vi x264_config.h
  107  find / -name x264_config.h
  108  cd ..
  109  find / -name x264_config.h
  110  vi x264_config.h
  111  cat /usr/local/include/x264_config.h
  112  cd libavcodec
  113  cat libx264.c
  114  vi libx264.c
  115  cd ..
  116  make && make install
  117  make clean
  118  make
  119  make install
  120  cd /usr/share/nginx/html
  121  ls
  122  ffmpeg -i test.mp4 -hls_time 10 -hls_list_size 0 -hls_segment_filename ./hls/test_%05d.ts ./hls/test.m3u8
  123  find / -name libcuda.so.*
  124  find / -name libcuda.so
  125  cd /home
  126  ls
  127  cd /home
  128  cd /
  129  cd usr
  130  ls
  131  cd local
  132  cd x264
  133  ls
  134  ./configure --enable-shared --disable-asm
  135  make 
  136  make install
  137  install -d /usr/local/bin
  138  install x264 /usr/local/bin
  139  make install
  140  find / -name pkgconfig
  141  echo $ PKG_CONIG_PATH
  142  export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
  143  echo $ PKG_CONIG_PATH
  144  cd ..
  145  ls
  146  cd ffmpeg-3.4
  147  ls
  148  ./configure --disable-yasm --enable-libx264 --enable-swscale --enable-avresample --enable-gpl --enable-shared
  149  make 
  150  make install
  151  cd /usr/local/share/nginx/html
  152  ls
  153  cd /
  154  cd usr
  155  cd local
  156  cd nginx
  157  ls
  158  cd ..
  159  ls
  160  cd share
  161  ls
  162  cd nginx
  163  ls
  164  cd html
  165  ffmpeg -i test.mp4 -hls_time 10 -hls_list_size 0 -hls_segment_filename ./hls/test_%05d.ts ./hls/test.m3u8
  166  cd ..
  167  cd loacl
  168  ls
  169  cd local
  170  ls
  171  echo "/usr/local/lib" >> /etc/ld.so.conf
  172  ldconfig
  173  ls
  174  cd .,
  175  ls
  176  cd ..
  177  ls
  178  cd share
  179  cd nginx
  180  cd html
  181  ffmpeg -i test.mp4 -hls_time 10 -hls_list_size 0 -hls_segment_filename ./hls/test_%05d.ts ./hls/test.m3u8
  182  mkdir hls
  183  ffmpeg -i test.mp4 -hls_time 10 -hls_list_size 0 -hls_segment_filename ./hls/test_%05d.ts ./hls/test.m3u8
  184  ls
  185  cd hls
  186  ls
  187  history
View Code

 附2:播放的html

<!doctype html>
<html>
    <head>
    <meta charset="utf-8">
    <title>nginx+ffmpeg+h5 播放视频</title>
    <link href="videojs/video-js.min.css" rel="stylesheet">
    <style>
body {
    background-color: #191919
}
.m {
    width: 960px;
    height: 400px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 100px;
}
</style>
    </head>

    <body>
    <div class="m">
      <video id="my-video" class="video-js" controls preload="auto" width="960" height="400"
          poster="video/add.jpg" data-setup="{}">
        <source src="http://192.168.91.133/video/test.m3u8" type="application/x-mpegURL">
        <!--
        <source src="http://vjs.zencdn.net/v/oceans.mp4" type="video/mp4">
        <source src="http://vjs.zencdn.net/v/oceans.webm" type="video/webm">
        <source src="http://vjs.zencdn.net/v/oceans.ogv" type="video/ogg">
        -->
        <p class="vjs-no-js"> To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a> </p>
      </video>
      <script src="videojs/video.min.js"></script> 
      <script type="text/javascript">
          //设置中文
          videojs.addLanguage('zh-CN', {
              "Play": "播放",
              "Pause": "暂停",
              "Current Time": "当前时间",
              "Duration": "时长",
              "Remaining Time": "剩余时间",
              "Stream Type": "媒体流类型",
              "LIVE": "直播",
              "Loaded": "加载完毕",
              "Progress": "进度",
              "Fullscreen": "全屏",
              "Non-Fullscreen": "退出全屏",
              "Mute": "静音",
              "Unmute": "取消静音",
              "Playback Rate": "播放速度",
              "Subtitles": "字幕",
              "subtitles off": "关闭字幕",
              "Captions": "内嵌字幕",
              "captions off": "关闭内嵌字幕",
              "Chapters": "节目段落",
              "Close Modal Dialog": "关闭弹窗",
              "Descriptions": "描述",
              "descriptions off": "关闭描述",
              "Audio Track": "音轨",
              "You aborted the media playback": "视频播放被终止",
              "A network error caused the media download to fail part-way.": "网络错误导致视频下载中途失败。",
              "The media could not be loaded, either because the server or network failed or because the format is not supported.": "视频因格式不支持或者服务器或网络的问题无法加载。",
              "The media playback was aborted due to a corruption problem or because the media used features your browser did not support.": "由于视频文件损坏或是该视频使用了你的浏览器不支持的功能,播放终止。",
              "No compatible source was found for this media.": "无法找到此视频兼容的源。",
              "The media is encrypted and we do not have the keys to decrypt it.": "视频已加密,无法解密。",
              "Play Video": "播放视频",
              "Close": "关闭",
              "Modal Window": "弹窗",
              "This is a modal window": "这是一个弹窗",
              "This modal can be closed by pressing the Escape key or activating the close button.": "可以按ESC按键或启用关闭按钮来关闭此弹窗。",
              ", opens captions settings dialog": ", 开启标题设置弹窗",
              ", opens subtitles settings dialog": ", 开启字幕设置弹窗",
              ", opens descriptions settings dialog": ", 开启描述设置弹窗",
              ", selected": ", 选择",
              "captions settings": "字幕设定",
              "Audio Player": "音频播放器",
              "Video Player": "视频播放器",
              "Replay": "重播",
              "Progress Bar": "进度小节",
              "Volume Level": "音量",
              "subtitles settings": "字幕设定",
              "descriptions settings": "描述设定",
              "Text": "文字",
              "White": "",
              "Black": "",
              "Red": "",
              "Green": "绿",
              "Blue": "",
              "Yellow": "",
              "Magenta": "紫红",
              "Cyan": "",
              "Background": "背景",
              "Window": "视窗",
              "Transparent": "透明",
              "Semi-Transparent": "半透明",
              "Opaque": "不透明",
              "Font Size": "字体尺寸",
              "Text Edge Style": "字体边缘样式",
              "None": "",
              "Raised": "浮雕",
              "Depressed": "压低",
              "Uniform": "均匀",
              "Dropshadow": "下阴影",
              "Font Family": "字体库",
              "Proportional Sans-Serif": "比例无细体",
              "Monospace Sans-Serif": "单间隔无细体",
              "Proportional Serif": "比例细体",
              "Monospace Serif": "单间隔细体",
              "Casual": "舒适",
              "Script": "手写体",
              "Small Caps": "小型大写字体",
              "Reset": "重启",
              "restore all settings to the default values": "恢复全部设定至预设值",
              "Done": "完成",
              "Caption Settings Dialog": "字幕设定视窗",
              "Beginning of dialog window. Escape will cancel and close the window.": "开始对话视窗。离开会取消及关闭视窗",
              "End of dialog window.": "结束对话视窗"
            });
          
          
          
          
          
          
            var myPlayer = videojs('my-video');
            videojs("my-video").ready(function(){
                var myPlayer = this;
                myPlayer.play();
            });
              
        </script> 
    </div>
</body>
</html>

附3:目录架构

 

posted @ 2023-11-07 16:05  一贴灵  阅读(268)  评论(0编辑  收藏  举报
学以致用,效率第一