FFmpeg脚本

1.将当前目录下的flv视频文件转换为mp4格式,并删除原文件

#! usr/bin/env bash

for file in $(ls *flv)
do
    ffmpeg -i $file -c copy ${file%.flv*}.mp4
#   echo ${file%.mp4*}
done

rm -rf *flv

2.将原视频加速为2倍速

ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mp4

copy

-filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" -b:v 

视频详细信息

ffprobe -i 

windows硬件加速1

ffmpeg -c:v h264_qsv -i 

windows硬件2倍速加速

-filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" -c:v h264_qsv -b:v 

windows硬件4倍速加速

-filter_complex "[0:v]setpts=0.25*PTS[v];[0:a]atempo=4.0[a]" -map "[v]" -map "[a]" -c:v h264_qsv -b:v 
k

3.将本目录下的所有mp4文件加速为2倍速

#! usr/bin/env bash

for file in $(ls *mp4)
do
    ffmpeg -i $file -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" ${file%.mp4*}.mp4
#   echo ${file%.mp4*}
done

4.将本目录下的所有mp4文件加速为2倍速并设置为固定码率

#! usr/bin/env bash

for file in $(ls *mp4)
do
    ffmpeg -i $file -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" -b:v 1500k ${file%.mp4*}.mp4
#   echo ${file%.mp4*}
done

你可能感兴趣的:(FFmpeg脚本)