From 126882f826295032837e63b02ec1a358e58171d5 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Mon, 9 Jan 2023 13:20:52 +0300 Subject: [PATCH 1/4] Update_vod_transcode_script --- vod_transcode.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vod_transcode.sh b/vod_transcode.sh index 56c3ce93..626a122e 100644 --- a/vod_transcode.sh +++ b/vod_transcode.sh @@ -9,6 +9,9 @@ # sudo service antmedia restart # +# Just convert to HLS +HLS="1" + # Don't forget to change the Ant Media Server App Name AMS_APP_NAME="WebRTCAppEE" @@ -26,4 +29,9 @@ c=("320x240" "800k") cd /usr/local/antmedia/webapps/$AMS_APP_NAME/streams/ -$(command -v ffmpeg) -i $file -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -s:v:0 ${a[0]} -c:v:0 libx264 -b:v:0 ${a[1]} -s:v:1 ${b[0]} -c:v:1 libx264 -b:v:1 ${b[1]} -s:v:2 ${c[0]} -c:v:2 libx264 -b:v:2 ${c[1]} -c:a aac -f hls -hls_playlist_type vod -master_pl_name ${file_name}.m3u8 -hls_segment_filename ${file_name}_%v/${file_name}%03d.ts -use_localtime_mkdir 1 -var_stream_map "v:0,a:0,name:720p v:1,a:1,name:480p v:2,a:2,name:360p" ${file_name}_%v.m3u \ No newline at end of file + +if [ $HLS == "1" ]; then + $(command -v ffmpeg) -i $file -crf 27 -preset veryfast -codec copy -hls_segment_filename ${file_name}_%v/${file_name}%03d.ts -use_localtime_mkdir 1 ${file_name}.m3u8 +else + $(command -v ffmpeg) -i $file -crf 27 -preset veryfast -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -s:v:0 ${a[0]} -c:v:0 libx264 -b:v:0 ${a[1]} -s:v:1 ${b[0]} -c:v:1 libx264 -b:v:1 ${b[1]} -s:v:2 ${c[0]} -c:v:2 libx264 -b:v:2 ${c[1]} -c:a aac -f hls -hls_playlist_type vod -master_pl_name ${file_name}.m3u8 -hls_segment_filename ${file_name}_%v/${file_name}%03d.ts -use_localtime_mkdir 1 -var_stream_map "v:0,a:0,name:720p v:1,a:1,name:480p v:2,a:2,name:240p" ${file_name}_%v.m3u +fi From 768f9fc7c411e93e0898278d050b74a4f7963c48 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Mon, 30 Jan 2023 13:46:59 +0300 Subject: [PATCH 2/4] Remove -preset and -crf parameters --- vod_transcode.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vod_transcode.sh b/vod_transcode.sh index 626a122e..f972abe3 100644 --- a/vod_transcode.sh +++ b/vod_transcode.sh @@ -31,7 +31,7 @@ cd /usr/local/antmedia/webapps/$AMS_APP_NAME/streams/ if [ $HLS == "1" ]; then - $(command -v ffmpeg) -i $file -crf 27 -preset veryfast -codec copy -hls_segment_filename ${file_name}_%v/${file_name}%03d.ts -use_localtime_mkdir 1 ${file_name}.m3u8 + $(command -v ffmpeg) -i $file -codec copy -hls_segment_filename ${file_name}_%v/${file_name}%03d.ts -use_localtime_mkdir 1 ${file_name}.m3u8 else $(command -v ffmpeg) -i $file -crf 27 -preset veryfast -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -s:v:0 ${a[0]} -c:v:0 libx264 -b:v:0 ${a[1]} -s:v:1 ${b[0]} -c:v:1 libx264 -b:v:1 ${b[1]} -s:v:2 ${c[0]} -c:v:2 libx264 -b:v:2 ${c[1]} -c:a aac -f hls -hls_playlist_type vod -master_pl_name ${file_name}.m3u8 -hls_segment_filename ${file_name}_%v/${file_name}%03d.ts -use_localtime_mkdir 1 -var_stream_map "v:0,a:0,name:720p v:1,a:1,name:480p v:2,a:2,name:240p" ${file_name}_%v.m3u fi From 887c97551efbbf87e981eceefa9ec15572067be0 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Wed, 1 Feb 2023 18:13:09 +0300 Subject: [PATCH 3/4] Remove specific file path --- vod_transcode.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/vod_transcode.sh b/vod_transcode.sh index f972abe3..01c9df0c 100644 --- a/vod_transcode.sh +++ b/vod_transcode.sh @@ -12,9 +12,6 @@ # Just convert to HLS HLS="1" -# Don't forget to change the Ant Media Server App Name -AMS_APP_NAME="WebRTCAppEE" - file=$1 file_name=$(basename $file .mp4) @@ -26,9 +23,7 @@ b=("640x480" "1500k") # 240p c=("320x240" "800k") - -cd /usr/local/antmedia/webapps/$AMS_APP_NAME/streams/ - +cd ${file%/*}/ if [ $HLS == "1" ]; then $(command -v ffmpeg) -i $file -codec copy -hls_segment_filename ${file_name}_%v/${file_name}%03d.ts -use_localtime_mkdir 1 ${file_name}.m3u8 From 381d738c7b94825c1eb4b756a2011ee803124184 Mon Sep 17 00:00:00 2001 From: murat Date: Mon, 6 Feb 2023 00:09:53 +0300 Subject: [PATCH 4/4] Update the script --- vod_transcode.sh | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/vod_transcode.sh b/vod_transcode.sh index 01c9df0c..7647bd0e 100644 --- a/vod_transcode.sh +++ b/vod_transcode.sh @@ -9,24 +9,31 @@ # sudo service antmedia restart # -# Just convert to HLS -HLS="1" - file=$1 file_name=$(basename $file .mp4) # Bitrates + # 720p -a=("1280x720" "2500k") +a=("" "") # 480p -b=("640x480" "1500k") +b=("" "") + +# 720p +#a=("1280x720" "2500k") +# 480p +#b=("640x480" "1500k") # 240p -c=("320x240" "800k") +#c=("320x240" "800k") cd ${file%/*}/ -if [ $HLS == "1" ]; then - $(command -v ffmpeg) -i $file -codec copy -hls_segment_filename ${file_name}_%v/${file_name}%03d.ts -use_localtime_mkdir 1 ${file_name}.m3u8 +if [ ! -z $a ]; then + $(command -v ffmpeg) -i $file -crf 27 -preset veryfast -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -s:v:0 ${a[0]} -c:v:0 libx264 -b:v:0 ${a[1]} -c:a aac -f hls -hls_playlist_type vod -master_pl_name ${file_name}.m3u8 -hls_segment_filename ${file_name}_%v/${file_name}%03d.ts -use_localtime_mkdir 1 -var_stream_map "v:0,a:0,name:720p" ${file_name}_%v.m3u +elif [ ! -z $b ]; then + $(command -v ffmpeg) -i $file -crf 27 -preset veryfast -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -s:v:1 ${b[0]} -c:v:1 libx264 -b:v:1 ${b[1]} -c:a aac -f hls -hls_playlist_type vod -master_pl_name ${file_name}.m3u8 -hls_segment_filename ${file_name}_%v/${file_name}%03d.ts -use_localtime_mkdir 1 -var_stream_map "v:1,a:1,name:480p" ${file_name}_%v.m3u +elif [ ! -z $a ] && [ ! -z $b ]; then + $(command -v ffmpeg) -i $file -crf 27 -preset veryfast -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -s:v:0 ${a[0]} -c:v:0 libx264 -b:v:0 ${a[1]} -s:v:1 ${b[0]} -c:v:1 libx264 -b:v:1 ${b[1]} -s:v:2 ${c[0]} -c:v:2 libx264 -b:v:2 ${c[1]} -c:a aac -f hls -hls_playlist_type vod -master_pl_name ${file_name}.m3u8 -hls_segment_filename ${file_name}_%v/${file_name}%03d.ts -use_localtime_mkdir 1 -var_stream_map "v:0,a:0,name:720p v:1,a:1,name:480p" ${file_name}_%v.m3u else - $(command -v ffmpeg) -i $file -crf 27 -preset veryfast -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -s:v:0 ${a[0]} -c:v:0 libx264 -b:v:0 ${a[1]} -s:v:1 ${b[0]} -c:v:1 libx264 -b:v:1 ${b[1]} -s:v:2 ${c[0]} -c:v:2 libx264 -b:v:2 ${c[1]} -c:a aac -f hls -hls_playlist_type vod -master_pl_name ${file_name}.m3u8 -hls_segment_filename ${file_name}_%v/${file_name}%03d.ts -use_localtime_mkdir 1 -var_stream_map "v:0,a:0,name:720p v:1,a:1,name:480p v:2,a:2,name:240p" ${file_name}_%v.m3u + $(command -v ffmpeg) -i $file -codec copy -hls_segment_filename ${file_name}_%v/${file_name}%03d.ts -use_localtime_mkdir 1 ${file_name}.m3u8 fi