Skip to content

Instantly share code, notes, and snippets.

@x1wins
Last active Mar 12, 2019
Embed
What would you like to do?
#!/usr/bin/env bash
start=$(date)
# source="trailer_1080p.ogg"
# target="trailer"
source=${1}
target=${2}
rm -rf ${target}
mkdir ${target}
function encoding {
rm -rf ${target}/${2}
mkdir ${target}/${2}
mp4="${target}/${2}/${2}.mp4"
trans="ffmpeg -y -i ${source} -vf scale=w=${1}:h=${2} -c:v libx265 -crf 28 -c:a aac -b:a 128k -tag:v hvc1 ${mp4}"
${trans}
hls="ffmpeg -i ${mp4} -c:v copy -c:a copy -g 48 -keyint_min 48 -hls_time 4 -hls_playlist_type vod -hls_segment_type fmp4 -hls_segment_filename ${target}/${2}/${2}-%08d.m4s ${target}/${2}/${2}.m3u8"
${hls}
rm ${mp4}
}
encoding 640 360
encoding 1280 720
encoding 1920 1080
cp playlist_h265.m3u8 ${target}/playlist_h265.m3u8
echo -e "Encoding Start \n$start"
echo "Encoding Complete"
date
# example
# bash encoding_h265.sh iamlegend.ts iamlegend
# bash encoding_h265.sh trailer_1080p.ogg trailer
@x1wins

This comment has been minimized.

Copy link
Owner Author

@x1wins x1wins commented Mar 12, 2019

  1. How to run
$ bash encoding_h265.sh SOURCE_FILE SAVE_PATH
$ bash encoding_h265.sh trailer_1080p.ogg trailer

if you want sample movie
I will recommend big buck bunny
download https://peach.blender.org/trailer-page/

  1. create playlist
    download https://gist.github.com/x1wins/9c36baadfc9985092a23d73a6a6f1e1a
    copy to trailer/playlist_h265.m3u8

  2. you can connect below url
    https://localhost/trailer/360/360.m3u8
    https://localhost/trailer/720/720.m3u8
    https://localhost/trailer/1080/1080.m3u8
    https://localhost/trailer/playlist_h265.m3u8

http server

# https://www.npmjs.com/package/http-server
$  npm install http-server -g
$ http-server ./ -p 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment