shell腳本實現 視頻格式轉換 ffmpeg 實現視頻轉換


#!/bin/bash


original=$1
echo $original

# 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 
    target=${original%.*}.mp4   #截取文件最長的字符串,比如 文件的名字是  a.html.dds.dd.ddedeers.sd.date.mp4,  在這里值截取   .mp4 以前的字符為target
    tmp=${original%.*}`date +%N`.mp4   # 文件的臨時名字
    ffmpeg -i $original -vcodec libx264 -acodec libfaac  -vpre slow  -vpre baseline  -qscale 4 -y  $tmp
    rm $original
    mv $tmp $target
fi

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM