-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencode.sh
More file actions
executable file
·41 lines (37 loc) · 1.42 KB
/
Copy pathencode.sh
File metadata and controls
executable file
·41 lines (37 loc) · 1.42 KB
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
#!/bin/bash
# Usage: ./encode.sh input.mp4 output_dir
set -e
INPUT="${1:-input.mp4}"
OUT="${2:-output}"
mkdir -p "$OUT"/{720p,480p,270p,audio}
ffmpeg -i "$INPUT" \
-filter_complex "
[0:v]split=3[v720raw][v480raw][v270raw];
[v720raw]scale=720:1280:force_original_aspect_ratio=decrease,pad=720:1280:(ow-iw)/2:(oh-ih)/2[v720];
[v480raw]scale=480:854:force_original_aspect_ratio=decrease,pad=480:854:(ow-iw)/2:(oh-ih)/2[v480];
[v270raw]scale=270:480:force_original_aspect_ratio=decrease,pad=270:480:(ow-iw)/2:(oh-ih)/2[v270]
" \
-map "[v720]" -map "[v480]" -map "[v270]" -map 0:a \
\
-c:v:0 libx264 -b:v:0 1800k -maxrate:v:0 1861k -bufsize:v:0 3722k \
-profile:v:0 high -level:v:0 4.0 \
\
-c:v:1 libx264 -b:v:1 800k -maxrate:v:1 837k -bufsize:v:1 1674k \
-profile:v:1 high -level:v:1 3.1 \
\
-c:v:2 libx264 -b:v:2 350k -maxrate:v:2 371k -bufsize:v:2 742k \
-profile:v:2 high -level:v:2 3.0 \
\
-c:a:0 aac -b:a:0 128k -ac 2 -ar 48000 \
\
-f hls \
-hls_time 6 \
-hls_playlist_type vod \
-hls_flags independent_segments \
-hls_segment_type fmp4 \
-hls_fmp4_init_filename "init.mp4" \
-hls_segment_filename "$OUT/%v/%03d.m4s" \
-master_pl_name "master.m3u8" \
-var_stream_map "v:0,agroup:audio-hi-0,name:720p v:1,agroup:audio-hi-0,name:480p v:2,agroup:audio-hi-0,name:270p a:0,agroup:audio-hi-0,language:und,default:yes,name:audio" \
"$OUT/%v/rendition.m3u8"
echo "Done → $OUT/master.m3u8"