This commit is contained in:
jay
2025-05-15 11:22:56 +08:00
parent 89fb2a1b56
commit 28d7111aee
4 changed files with 132 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "請輸入檔案名稱"
exit 1
fi
if [ ! -f "$1" ]; then
echo "file not exists"
exit 1
fi
FILENAME="${1##*/}"
DIRNAME="${FILENAME%.*}"
EXTNAME="${FILENAME##*.}"
echo "$DIRNAME"
mkdir "$DIRNAME"
# gen key
openssl rand 16 > "$DIRNAME/enc.key"
# new key info file
echo "enc.key" > keyinfo
echo "$DIRNAME/enc.key" >> keyinfo
openssl rand 16 -hex >> keyinfo
# convert
ffmpeg -i "$1" -f hls -hls_time 10 -hls_list_size 0 -vn -hls_segment_filename "$DIRNAME/segment%d.ts" -hls_key_info_file keyinfo -hls_playlist_type vod "$DIRNAME/playlist.m3u8"
# move origin file
cp "$1" "$DIRNAME/origin.$EXTNAME"
# clean tmp file
rm keyinfo