Hi,聆听·彼岸



听说,你是我最遥不可及的梦。
What should I do?
What should I do?
I think I'm going to fall in love with myself.

ffmpeg

发表于 2023-04-15| 分类于 笔记 | | 评论数
# ubuntu
sudo apt-get install ffmpeg
# 其他linux参考(群友推荐):https://gitee.com/baihu433/ffmpeg
# Windows 参考:https://www.jianshu.com/p/5015a477de3c

这里主要看群有推荐的用法

ffmpeg.sh

#!/bin/bash
case $(arch) in
aarch64|arm64)
ffmpeg=arm64
;;
amd64|x86_64)
ffmpeg=amd64
;;
armhf)
ffmpeg=armhf
;;
i686)
ffmpeg=i686
;;
armel)
ffmpeg=armel
;;
*)
echo -e "\033[31m暂不支持您的设备\033[0m"
exit
;;
esac
curl -o ffmpeg-release-${ffmpeg}-static.tar.xz https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-${ffmpeg}-static.tar.xz
curl -o ffmpeg.tar.xz.md5 https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-${ffmpeg}-static.tar.xz.md5
if md5sum -c ffmpeg.tar.xz.md5
then
echo -e "\033[36m下载成功\033[0m"
else
echo -e "\033[31m下载失败033[0m"
exit
fi
if ! [ -x "$(command -v xz-utils)" ];then
apt install xz-utils -y
fi
xz -d ffmpeg-release-${ffmpeg}-static.tar.xz
mkdir ffmpeg
tar -xvf ffmpeg-release-${ffmpeg}-static.tar -C ffmpeg
path=$(ls ffmpeg)
rm -rf /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg &>/dev/null
rm -rf /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg &>/dev/null
mv ffmpeg/${path}/ffmpeg /usr/local/bin/ffmpeg
mv ffmpeg/${path}/ffprobe /usr/local/bin/ffprobe
chmod +x /usr/local/bin/ffmpeg
chmod +x /usr/local/bin/ffprobe
rm -rf ffmpeg ffmpeg.tar
if [ -e /usr/local/bin/ffmpeg ] && [ -e /usr/local/bin/ffprobe ]
then
ffmpeg
echo
echo -e "\033[36m安装完成\033[0m"
else
echo -e "\033[31m安装失败\033[0m"
fi

命令行

nohup bash ffmpeg.sh > test.log 2>&1 &
tail -f test.log

ts2mp4

ffmpeg -i 1.ts 1.mp4

mp42png

ffmpeg -i 1.ts -r 25 -f image2 .\output\frame_%%5d.png

提取音频

ffmpeg -i 1.mp4 -vn -c:a copy 1.aac

图片合成视频

ffmpeg -f image2 -i .\output\frame_%%5d_3x.png -vcodec libx264 -r 25 -b 458k output1.mp4

音频合并视频

ffmpeg -i output1.mp4 -i 1.aac -vcodec copy -acodec copy output.mp4

合并视频

for var in `ls`; do echo "file '$var'" >> ff.txt; done;
ffmpeg -f concat -i ff.txt -c copy output_set.mp4

满分是10分的话,这篇文章你给几分,您的支持将鼓励我继续创作!