【shell】脚本实现自动化MP4转成jpg

代码

#!/bin/sh  

read -p "input path:" FilePath;  

function getAllFiles()  
{  
        #cd $FilePath;
        fileList=`ls *.mp4`;  

        for fileName in $fileList;  
        do  
           if test -f $fileName; then   
              sub_name=${fileName%.*};
              #echo $sub_name;
              #ffmpe 命令
              ffmpeg -i $fileName -r 1 -q:v 2 -f image2 $sub_name-4%d.jpg ;
           fi  
        done  
}  

cd $FilePath;  
getAllFiles;  
echo "DONE"; 

代码说明

ffmpeg -i $fileName -r 1 -q:v 2 -f image2 $sub_name-4%d.jpg ;
   -i 后面跟着要输入的视频名称
   -r 后面跟着每秒提取图片的帧数
   -q:v 后面跟着 提取出图片的质量 2 表示高质量

猜你喜欢

转载自blog.csdn.net/jobbofhe/article/details/79274211