ffmpeg批量获取视频第一帧shell脚本

ffmpeg批量获取视频第一帧shell脚本

#!/bin/bash
echo  "ffmpegmp4"

ffmpegmp4(){
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 [ `ffprobe -show_streams $1 | grep "codec_name=h264"` ]; then
 #   echo "Don't need convert!"
 # else 
                  #  target=${original%.*}_h264.${original##*.}  截取文件最长的字符串,比如 文件的名字是  a.html.dds.dd.ddedeers.sd.date.mp4,  在这里值截取   .mp4 以前的字符为target
    target=${original%.*}.${original##*.}  
    tmp=${original%.*}`date +%N`.mp4   # 文件的临时名字
    picpath=${original%.*}_pic.jpg
                  ## ffmpeg -i $original  -ab 56 -ar 22050 -qscale 8 -codec:v libx264 -c:a copy -movflags faststart -r  15  -s 480*320  -y  $tmp  
      ffmpeg -i $original  -ab 56 -ar 22050 -qscale 8 -codec:v libx264 -c:a copy -movflags faststart -r  15  -s 480*320  -y  $tmp  
      
      ffmpeg -ss 0 -i $original -y -f image2 -t 0.001 -s 238*140  $picpath
   # 覆盖原文件
    mv $tmp $target
#fi
}
echo  "ffmpegmp4 over"

list_allpdf(){
  for i in `ls -a  $1`; do  
  if [ -d "$1/$i" -a x"$i" != x"." -a x"$i" != x".." ];then 
	      list_allpdf "$1/$i" 
	elif [ -f "$1/$i" -a -s "$1/$i"  ];then
	      echo "$1/$i" 
	      if [ "${i##*.}" = "mp4" -o "${i##*.}" = "flv" -o "${i##*.}" = "MP4" -o "${i##*.}" = "FLV" ];then
		       echo "---------------------------111--------------------------------"
		       ffmpegmp4  $1/$i
			  fi
           echo "*******************************"
	             
	fi
	         
  done  
}


list_allpdf $1











评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

翅膀君

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值