ffmpeg 检查版本:ffmpeg -version出现 ffmpeg command not found解决办法

ffmpeg 检查版本:ffmpeg -version出现 ffmpeg command not found解决办法

1. 错误显示


[email protected]:/usr/local/ffmpeg/lib# ffmpeg --help
-bash: ffmpeg: command not found
[email protected]:/usr/local/ffmpeg/lib# /usr/local/ffmpeg/
bin/     include/ lib/     share/
[email protected]:/usr/local/ffmpeg/lib# ffmpeg --version
-bash: ffmpeg: command not found


2. 解决办法

2.1 修改profile文件

在命令行使用:

/usr/local/ffmpeg/installlocation/bin/ffmpeg --version

如果还报错说明:没有设置环境变量
此时需要修改 /etc/profile 文件。
注意要执行 source /etc/profile才能生效!

解决办法如下:


[email protected]:/usr/local/ffmpeg/bin# ll
total 37632
drwxr-xr-x 2 root root     4096 8月  15 05:42 ./
drwxr-xr-x 6 root root     4096 8月  15 05:44 ../
-rwxr-xr-x 1 root root 19311392 8月  15 05:42 ffmpeg*
-rwxr-xr-x 1 root root 19213248 8月  15 05:42 ffprobe*
[email protected]:/usr/local/ffmpeg/bin# ffmpeg --version
-bash: ffmpeg: command not found
[email protected]:/usr/local/ffmpeg/bin# vi /etc/profile
[email protected]:/usr/local/ffmpeg/bin# source /etc/profile

其中设置环境变量细节如下,就是 vi /etc/profile这一步
添加!

#set my ffmpeg environment
PATH=$PATH:/usr/local/ffmpeg/bin
export PATH

profile 文件细节如下:


# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$PS1" ]; then

  if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

#set my ffmpeg environment
export FFMPEG_PATH=/usr/local/ffmpeg
export PATH=$PATH:/usr/local/ffmpeg/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/ffmpeg/lib

~

2.2 修改~/.bashrc文件(这一步可有可无)

vi ~/.bashrc 进入此文件修改PATH

添加ffmpeg路径:/usr/local/ffmpeg/bin:
添加前:

export PATH=/home/uihost/bin:$PATH

添加后:
export PATH=/home/uihost/bin:/usr/local/ffmpeg/bin:$PATH

保存之后一定记得:source ~/.bashrc; 或者重启一下都能生效。

3. 最终结果


[email protected]:/usr/local/ffmpeg/bin# ffmpeg -version
ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.11) 20160609
configuration: --prefix=/usr/local/ffmpeg
libavutil      56. 31.100 / 56. 31.100
libavcodec     58. 54.100 / 58. 54.100
libavformat    58. 29.100 / 58. 29.100
libavdevice    58.  8.100 / 58.  8.100
libavfilter     7. 57.100 /  7. 57.100
libswscale      5.  5.100 /  5.  5.100
libswresample   3.  5.100 /  3.  5.100


[email protected]:/home/wang# ffmpeg -version
ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.11) 20160609
configuration: --prefix=/usr/local/ffmpeg --enable-shared --enable-pic
libavutil      56. 31.100 / 56. 31.100
libavcodec     58. 54.100 / 58. 54.100
libavformat    58. 29.100 / 58. 29.100
libavdevice    58.  8.100 / 58.  8.100
libavfilter     7. 57.100 /  7. 57.100
libswscale      5.  5.100 /  5.  5.100
libswresample   3.  5.100 /  3.  5.100

备注: 这里挺有意思的,ffmpeg --version会报错。。。换成 ffmpeg -version 就可以了。

参考链接

  1. https://blog.csdn.net/mmLxfz/article/details/81156688
发布了90 篇原创文章 · 获赞 149 · 访问量 25万+

猜你喜欢

转载自blog.csdn.net/sinat_36458870/article/details/99719071