Last active
February 11, 2022 07:59
-
-
Save flydo/4d5222ff662bbfae5719331a91a3ec13 to your computer and use it in GitHub Desktop.
将视频转换为 mp4 格式
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## | |
## 用法: | |
## tomp4.sh 忽略参数时,默认为将当前目录下的所有 rmvb 格式视频转换为 mp4 格式 | |
## tomp4.sh . .wmv : 将当前目录下的所有 wmv 格式视频转换为 mp4 格式 | |
## tomp4.sh a.avi .avi 将 a.avi 视频转换为 mp4 格式 | |
## | |
## -c:a mp3 mp3 可修改为 aac 等音频格式码。 | |
## -c:v libx265 libx265 可修改为 h264、libx264 (H.264 格式)和 libx265 (H.265 格式),其中 H.265 占用资源比 H。264 少一倍。 | |
## | |
NAME="." | |
EXT=".rmvb" | |
if [ "${2}x" != ""x ]; then | |
EXT="${2}" | |
fi | |
if [ "${1}x" == ""x ]; then | |
NAME="." | |
else | |
NAME="${1}" | |
fi | |
if [ "${NAME}x" = "."x ]; then | |
for i in *${EXT} | |
do | |
echo -e "\n\n\e[0;31m${i} ...\e[m \n" | |
newfname=$(echo "${i}" | sed "s/$EXT/\.mp4/") | |
#ffmpeg -i "${i}" -c:v h264 -c:a mp3 "${newfname}" | |
ffmpeg -i "${i}" -c:v libx265 -c:a mp3 -y "${newfname}" | |
done | |
else | |
newfname=$(echo "${NAME}" | sed "s/$EXT/\.mp4/") | |
#ffmpeg -i "${NAME}" -c:a copy -c:v h264 "${NAME}.mp4" | |
ffmpeg -i "${NAME}" -c:a mp3 -c:v libx265 -y "${newfname}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment