溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Linux怎么安裝ffmpeg

發(fā)布時(shí)間:2022-02-02 08:26:11 來(lái)源:億速云 閱讀:339 作者:iii 欄目:開(kāi)發(fā)技術(shù)

這篇文章主要介紹“Linux怎么安裝ffmpeg”的相關(guān)知識(shí),小編通過(guò)實(shí)際案例向大家展示操作過(guò)程,操作方法簡(jiǎn)單快捷,實(shí)用性強(qiáng),希望這篇“Linux怎么安裝ffmpeg”文章能幫助大家解決問(wèn)題。

Fmpeg 是領(lǐng)先的多媒體框架,能夠解碼、編碼、轉(zhuǎn)碼、混合、解密、流媒體、過(guò)濾和播放人類和機(jī)器創(chuàng)造的幾乎所有東西。它支持最晦澀的古老格式,直到最尖端的格式。

Linux怎么安裝ffmpeg

  • 1.Linux下安裝ffmpeg
 官網(wǎng)下載:http://ffmpeg.org/download.html
  • 2.下載之后上傳至Linux準(zhǔn)備安裝,首先解壓安裝包
 tar -xjvf ffmpeg-4.1.tar.bz2` `cd ffmpeg-4.1/
  • 3.如果現(xiàn)在執(zhí)行configure配置的話,可能會(huì)報(bào)如下的錯(cuò)誤:
     [root@slave ffmpeg-4.1]# ./configure gcc is unable to create an executable file. If gcc is a cross-compiler, use the --enable-cross-compile option. Only do this if you know what cross compiling means. C compiler test failed. 
     If you think configure made a mistake, make sure you are using the latest version from Git.  If the latest version fails, report the problem to the ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net. Include the log file "ffbuild/config.log" produced by configure as this will   help solve the problem.

    錯(cuò)誤的意思是 yasm/nasm 包不存在或者很舊,可以使用–disable-yasm禁用這個(gè)選項(xiàng)編譯,yasm是一款匯編器,并且是完全重寫(xiě)了nasm的匯編環(huán)境,接收nasm和gas語(yǔ)法,支持x86和amd64指令集,所以這里安裝一下yasm即可

  • 4.Linux下安裝yasm
 官網(wǎng)下載:http://yasm.tortall.net/Download.html
  • 5.下載之后上傳至Linux準(zhǔn)備安裝,解壓、安裝
 tar -xvzf yasm-1.3.0.tar.gz` `cd yasm-1.3.0/` `./configure` `make` `make install
  • 6.安裝成功之后繼續(xù)回到ffmpeg解壓后的目錄,執(zhí)行下面命令編譯并安裝
 ./configure --enable-shared --prefix=/opt/ffmpeg` `make`:編譯過(guò)程有點(diǎn)長(zhǎng) `make install
  • 7.make install會(huì)把ffmpeg相關(guān)執(zhí)行程序、頭文件、lib庫(kù)安裝在/opt/ffmpeg/

耐心等待完成之后執(zhí)行 cd /opt/ffmpeg/ 進(jìn)入安裝目錄,查看一下發(fā)現(xiàn)有bin,include,lib,share這4個(gè)目錄 bin是ffmpeg主程序二進(jìn)制目錄 include是C/C++頭文件目錄 lib是編譯好的庫(kù)文件目錄 share是文檔目錄

  • 8.然后進(jìn)入bin目錄,執(zhí)行

./ffmpeg -version 查看當(dāng)前版本的詳細(xì)信息,默認(rèn)情況下一般會(huì)報(bào)

 libavdevice.so.57: cannot open shared object file: No such file or directory

原因是lib目錄未加載到鏈接到系統(tǒng)庫(kù)中 系統(tǒng)ld目錄列表在/etc/ld.so.conf中,打開(kāi)文件會(huì)發(fā)現(xiàn), 里面引用了/etc/ld.so.conf.d/下面所有的.conf文件,比如mariadb-x86_64.conf

  • 9.創(chuàng)建一個(gè)文件并寫(xiě)入lib路徑即可

執(zhí)行命令:vim /etc/ld.so.conf.d/ffmpeg.conf 然后添加一行內(nèi)容:/opt/ffmpeg/lib 之后保存并退出,然后執(zhí)行 ldconfig使配置生效, 現(xiàn)在再次執(zhí)行./ffmpeg -version 顯示就正常了

 [root@slave ffmpeg-4.1]#  ffmpeg -ersion ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-28) configuration: --enable-shared --prefix=/opt/ffmpeg-4 libavutil      56. 22.100 / 56. 22.100 libavcodec     58. 35.100 / 58. 35.100 libavformat    58. 20.100 / 58. 20.100 libavdevice    58.  5.100 / 58.  5.100 libavfilter     7. 40.101 /  7. 40.101 libswscale      5.  3.100 /  5.  3.100 libswresample   3.  3.100 /  3.  3.100
  • 10.配置環(huán)境變量

vim /etc/profile:編輯寫(xiě)入↓ PATH=/opt/python364/bin/:/opt/ffmpeg-4/bin/:$PATH source /etc/profile:重新讀取文件使其生效

  • 11.檢測(cè)使用
    • which ffmpeg或者↓直接輸入

    • ffmpeg或者↓使用文件進(jìn)行測(cè)試(文件自備)

    • ffmpeg -y -i a.wav -acodec pcm_s16le -f s16le -ac 1 -ar 16000 b.wav.pcm

關(guān)于“Linux怎么安裝ffmpeg”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí),可以關(guān)注億速云行業(yè)資訊頻道,小編每天都會(huì)為大家更新不同的知識(shí)點(diǎn)。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI