ffmpeg linux命令行 虚拟机centos7.6

ffmpeg linux命令行 虚拟机centos7.6
转码切片
#!/bin/bash
#根据这个网址(https://www.johnvansickle.com/ffmpeg/faq/)安装ffmpeg环境,因为需要多种的编码器。这个可以满足现在的这个脚本
original=$1
fenbianlv=$2
crf=$3
#文件路径 影片名字/4k/影片名字.mp4 | 影片名字/1080/影片名字.mp4 | 影片名字/720/影片名字.mp4 | 影片名字/480/影片名字.mp4
dir=
echo $original
echo $fenbianlv
echo $crf
echo $dir

check whether file is exist

if $original de chang du wei 0 huo bu $original bu shi chang gui wenjian

if [ -z $original ] || [ ! -f $original ]; then #判断位置变量没有值或者不是一个文件就退出
echo “file $original not exist!”
exit
fi

check whether file is end of ‘.mp4’ or whether it is h264 encodeing.

显示 以 .mp4结尾的文件名字或者 h264编码的文件名字 不需要转换的啊

if [ -n “echo $1 | sed -n /.mp4\$/p” ] && [ ffprobe -show_streams $1 | grep "codec_name=h264" ]; then
echo “Don’t need convert!”
else
#截取文件最长的字符串,比如 文件的名字是 a.html.dds.dd.ddedeers.sd.date.mp4, 在这里值截取 .mp4 以前的字符为target
target=KaTeX parse error: Expected '}', got '#' at position 23: …al%.*}.mp4 #̲文件的临时名字 …{original%.*}date +%N.mp4
#-c:v h264格式-s 分辨率-perset 转码压缩速度(veryfast fast slower veryslow) -crf 码率取值范围(0-51)建议取值16-26,取值越大文件
越小清晰度也越差 -c:a 音频格式 aac
ffmpeg -i $original -c:v libx264 -s $fenbianlv -preset fast -crf $crf -c:a aac $dir

#切片m3u8文件
#将MP4文件转换成ts文件
wen=${target%.*}.ts
ffmpeg -y -i $target -vcodec copy -acodec copy -vbsf h264_mp4toannexb $wen

#$wen 是源文件名,playlist.m3u8是生成的m3u8文件名,10 是切片秒数,output%03d.ts是输出文件名
ffmpeg -i $wen -c copy -map 0 -f segment -segment_list $dir/playlist.m3u8 -segment_time 10 $dir/output%03d.ts

参考很多文档,自己记录的脚本,是否正确不敢保证。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值