前言
为了让我的录播机能在线播放,所以找了个脚本,这个脚本是群里面一位大佬发出来的,非常感谢这位大佬的脚本。
准备
提前安装好ffmpeg
使用
脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| #!/bin/bash
RED='\033[0;31m' YELLOW='\033[1;33m' GREEN='\033[0;32m' NC='\033[0m'
if [ $# -lt 1 ]; then echo -e "${RED}Missing argument!${NC}" echo "Usage example:" echo " ./convert.sh \"/path/to/*.flv\"" exit elif [ $# -gt 1 ]; then echo -e "${RED}Too much argument!${NC}" echo -e "${YELLOW}Note${NC}: Did you forget quotes?" echo "Usage example:" echo " ./convert.sh \"/path/to/*.flv\"" exit fi
SOURCE_PATTERN="$1"
if [ -z "${FFMPEG}" ]; then FFMPEG=ffmpeg else echo -e "${YELLOW}[NOTE] Using custom ffmpeg path: \"${FFMPEG}\"${NC}" echo "" fi
for source in $SOURCE_PATTERN; do target="${source%.*}.mp4" if [ -f "$source" ]; then if [ -e "$target" ]; then echo -e "${YELLOW}[SKIP]${NC} MP4 exist: $target" else echo -e "${GREEN}[RUN ]${NC} convert \"$source\" to \"$target\"" $FFMPEG -hide_banner -nostats -loglevel warning -i "$source" -c copy "$target" fi fi done
|
如果出现“解释器错误:没有那个文件或目录”尝试运行以下命令
1
| sed -i.bak 's/\r$//g' zhuanma.sh
|