最近想用ffmpeg转个视频,忽然发现电脑上的ffmpeg欠好用了。应该是误删了什么库,报错:

bogon:~ yocn$ ffmpeg
dyld: Library not loaded: /usr/local/opt/fdk-aac/lib/libfdk-aac.1.dylib
  Referenced from: /usr/local/bin/ffmpeg
  Reason: image not found
Abort trap: 6

榜首主意,最简略的思路删掉重装:

brew uninstall ffmpeg
brew install ffmpeg

卸载没问题,很顺畅,安装的时分报错:

bogon:~ yocn$ brew install ffmpeg
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
contentful-cli       deployer             grafana              jvgrep               rgbds
couchdb              gitmoji              helmfile             kubernetes-helm      sispmctl
dav1d                goreleaser           hub                  python-yq            squid
==> Downloading https://homebrew.bintray.com/bottles/ffmpeg-4.2.1_2.mojave.bottle.tar.gz
Already downloaded: /Users/yocn/Library/Caches/Homebrew/downloads/ed6a355bc7efc0d5db6d6697d4713988dc91cde314bcba8169562182cfc4df62--ffmpeg-4.2.1_2.mojave.bottle.tar.gz
==> Pouring ffmpeg-4.2.1_2.mojave.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/ffmpeg
Target /usr/local/bin/ffmpeg
already exists. You may want to remove it:
  rm '/usr/local/bin/ffmpeg'
To force the link and overwrite all conflicting files:
  brew link --overwrite ffmpeg
To list all files that would be deleted:
  brew link --overwrite --dry-run ffmpeg
Possible conflicting files are:
/usr/local/bin/ffmpeg
/usr/local/bin/ffprobe
/usr/local/share/doc/ffmpeg/developer.html
/usr/local/share/doc/ffmpeg/faq.html
/usr/local/share/doc/ffmpeg/fate.html
/usr/local/share/doc/ffmpeg/ffmpeg-all.html
/usr/local/share/doc/ffmpeg/ffmpeg-bitstream-filters.html
/usr/local/share/doc/ffmpeg/ffmpeg-codecs.html
/usr/local/share/doc/ffmpeg/ffmpeg-devices.html
/usr/local/share/doc/ffmpeg/ffmpeg-filters.html
/usr/local/share/doc/ffmpeg/ffmpeg-formats.html
/usr/local/share/doc/ffmpeg/ffmpeg-protocols.html
/usr/local/share/doc/ffmpeg/ffmpeg-resampler.html
/usr/local/share/doc/ffmpeg/ffmpeg-scaler.html
/usr/local/share/doc/ffmpeg/ffmpeg-utils.html
/usr/local/share/doc/ffmpeg/ffmpeg.html
/usr/local/share/doc/ffmpeg/ffprobe-all.html
/usr/local/share/doc/ffmpeg/ffprobe.html
/usr/local/share/doc/ffmpeg/general.html
/usr/local/share/doc/ffmpeg/git-howto.html
/usr/local/share/doc/ffmpeg/libavcodec.html
/usr/local/share/doc/ffmpeg/libavdevice.html
/usr/local/share/doc/ffmpeg/libavfilter.html
/usr/local/share/doc/ffmpeg/libavformat.html
/usr/local/share/doc/ffmpeg/libavutil.html
/usr/local/share/doc/ffmpeg/libswresample.html
/usr/local/share/doc/ffmpeg/libswscale.html
/usr/local/share/doc/ffmpeg/mailing-list-faq.html
/usr/local/share/doc/ffmpeg/nut.html
/usr/local/share/doc/ffmpeg/platform.html
/usr/local/share/ffmpeg/examples/Makefile
/usr/local/share/ffmpeg/examples/README
/usr/local/share/ffmpeg/examples/avio_dir_cmd.c
/usr/local/share/ffmpeg/examples/avio_reading.c
/usr/local/share/ffmpeg/examples/decode_audio.c
/usr/local/share/ffmpeg/examples/decode_video.c
/usr/local/share/ffmpeg/examples/demuxing_decoding.c
/usr/local/share/ffmpeg/examples/encode_audio.c
/usr/local/share/ffmpeg/examples/encode_video.c
/usr/local/share/ffmpeg/examples/extract_mvs.c
/usr/local/share/ffmpeg/examples/filter_audio.c
/usr/local/share/ffmpeg/examples/filtering_audio.c
/usr/local/share/ffmpeg/examples/filtering_video.c
/usr/local/share/ffmpeg/examples/http_multiclient.c
/usr/local/share/ffmpeg/examples/hw_decode.c
/usr/local/share/ffmpeg/examples/metadata.c
/usr/local/share/ffmpeg/examples/muxing.c
/usr/local/share/ffmpeg/examples/qsvdec.c
/usr/local/share/ffmpeg/examples/remuxing.c
/usr/local/share/ffmpeg/examples/resampling_audio.c
/usr/local/share/ffmpeg/examples/scaling_video.c
/usr/local/share/ffmpeg/examples/transcode_aac.c
/usr/local/share/ffmpeg/examples/transcoding.c
/usr/local/share/ffmpeg/examples/vaapi_encode.c
/usr/local/share/ffmpeg/ffprobe.xsd
/usr/local/share/ffmpeg/libvpx-1080p.ffpreset
/usr/local/share/ffmpeg/libvpx-1080p50_60.ffpreset
/usr/local/share/ffmpeg/libvpx-360p.ffpreset
/usr/local/share/ffmpeg/libvpx-720p.ffpreset
/usr/local/share/ffmpeg/libvpx-720p50_60.ffpreset
/usr/local/share/man/man1/ffmpeg-all.1
/usr/local/share/man/man1/ffmpeg-bitstream-filters.1
/usr/local/share/man/man1/ffmpeg-codecs.1
/usr/local/share/man/man1/ffmpeg-devices.1
/usr/local/share/man/man1/ffmpeg-filters.1
/usr/local/share/man/man1/ffmpeg-formats.1
/usr/local/share/man/man1/ffmpeg-protocols.1
/usr/local/share/man/man1/ffmpeg-resampler.1
/usr/local/share/man/man1/ffmpeg-scaler.1
/usr/local/share/man/man1/ffmpeg-utils.1
/usr/local/share/man/man1/ffmpeg.1
/usr/local/share/man/man1/ffprobe-all.1
/usr/local/share/man/man1/ffprobe.1
/usr/local/share/man/man3/libavcodec.3
/usr/local/share/man/man3/libavdevice.3
/usr/local/share/man/man3/libavfilter.3
/usr/local/share/man/man3/libavformat.3
/usr/local/share/man/man3/libavutil.3
/usr/local/share/man/man3/libswresample.3
/usr/local/share/man/man3/libswscale.3
/usr/local/lib/libavcodec.58.dylib -> /usr/local/lib/libavcodec.58.6.102.dylib
/usr/local/lib/libavcodec.a
/usr/local/lib/libavcodec.dylib -> /usr/local/lib/libavcodec.58.6.102.dylib
/usr/local/lib/libavdevice.58.dylib -> /usr/local/lib/libavdevice.58.0.100.dylib
/usr/local/lib/libavdevice.a
/usr/local/lib/libavdevice.dylib -> /usr/local/lib/libavdevice.58.0.100.dylib
/usr/local/lib/libavfilter.7.dylib -> /usr/local/lib/libavfilter.7.6.100.dylib
/usr/local/lib/libavfilter.a
/usr/local/lib/libavfilter.dylib -> /usr/local/lib/libavfilter.7.6.100.dylib
/usr/local/lib/libavformat.58.dylib -> /usr/local/lib/libavformat.58.2.103.dylib
/usr/local/lib/libavformat.a
/usr/local/lib/libavformat.dylib -> /usr/local/lib/libavformat.58.2.103.dylib
/usr/local/lib/libavutil.56.dylib -> /usr/local/lib/libavutil.56.5.100.dylib
/usr/local/lib/libavutil.a
/usr/local/lib/libavutil.dylib -> /usr/local/lib/libavutil.56.5.100.dylib
/usr/local/lib/libpostproc.55.dylib -> /usr/local/lib/libpostproc.55.0.100.dylib
/usr/local/lib/libpostproc.dylib -> /usr/local/lib/libpostproc.55.0.100.dylib
/usr/local/lib/libswresample.3.dylib -> /usr/local/lib/libswresample.3.0.101.dylib
/usr/local/lib/libswresample.a
/usr/local/lib/libswresample.dylib -> /usr/local/lib/libswresample.3.0.101.dylib
/usr/local/lib/libswscale.5.dylib -> /usr/local/lib/libswscale.5.0.101.dylib
/usr/local/lib/libswscale.a
/usr/local/lib/libswscale.dylib -> /usr/local/lib/libswscale.5.0.101.dylib
/usr/local/lib/pkgconfig/libavcodec.pc
/usr/local/lib/pkgconfig/libavdevice.pc
/usr/local/lib/pkgconfig/libavfilter.pc
/usr/local/lib/pkgconfig/libavformat.pc
/usr/local/lib/pkgconfig/libavutil.pc
/usr/local/lib/pkgconfig/libpostproc.pc
/usr/local/lib/pkgconfig/libswresample.pc
/usr/local/lib/pkgconfig/libswscale.pc

告诉我/usr/local/bin/ffmpeg存在了,无法link。额~去/usr/local/bin/里瞅一眼,确实是存在,然后引荐我履行rm '/usr/local/bin/ffmpeg',履行了指令之后。持续brew install ffmpeg,会持续报上面的错,不同的是让删去`rm

‘/usr/local/bin/ffprobe’,额,看起来是需求把这些Possible conflicting files are:`的file全删去才能够~~~~
这一个一个的删去肯定不现实~~ 写个shell脚本删好了。

1、手动复制需求删去的这些个东西到一个txt文件。这种最简略,还能够删掉->后的内容

/usr/local/bin/ffmpeg
/usr/local/bin/ffprobe
...
/usr/local/lib/pkgconfig/libswresample.pc
/usr/local/lib/pkgconfig/libswscale.pc

2、不想手动复制的时分能够用shell的重定向指令把输出的内容写到一个txt文件里边。比如:

brew install ffmpeg >> aaa.txt就会把>>前面指令的输出输出到txt文件里边而不是输出到termial屏幕上。其他指令也是相似的。

然后咱们写一个脚原本把需求的内容搞出来,假设shell文件叫a.sh,内容存在b.txt,直接./a.sh b.txt批量删去就好了。

#!/bin/bash
#sh跟文件参数
file=$1
#逐行读取文件内容
cat $file | while read line
do
	#如果本行是/usr/local/最初则是咱们需求处理的
	if [[ "$line" == /usr/local/* ]];then
		li=${line%% ->*}
		echo $li
		#用的时分翻开,rm,删掉此行文件
		#rm $li
	fi
done

履行之后再履行brew install ffmpeg就OK了。