Skip to content

Instantly share code, notes, and snippets.

@FreddyFY
Last active December 10, 2017 15:37
Show Gist options
  • Save FreddyFY/89b38a20f7dd41db4c44de43105a8371 to your computer and use it in GitHub Desktop.
Save FreddyFY/89b38a20f7dd41db4c44de43105a8371 to your computer and use it in GitHub Desktop.
# Downlaod TS-Files and convert them
#
# How to get the ts-filepath https://stackoverflow.com/questions/22188332/download-ts-files-from-video-stream#answer-42124169
#
# required: wget, ffmpeg
prelink="https://domain.com/path/to/ts/file"
lastnumner=5
output=$HOME"/desktop/movie.mp4"
headers=""
filetype=".ts"
tmppath="tmp/"
# stop editing
allfile=$tmppath"all.ts"
for i in $(seq $lastnumner)
do
tsfile=$prelink$i$filetype
# save .ts file in tmp-folder
wget -q --header=$headers -P $tmppath $tsfile
# concat .ts files
bin=`cat $tmppath$(basename $tsfile) >> $allfile`
# status
echo $(awk "BEGIN { pc=100*${i}/${lastnumner}; j=int(pc); print (pc-j<0.5)?j:j+1 }")"%"
done
echo "start converting"
# mp4 converter
bin=`ffmpeg -i $allfile -bsf:a aac_adtstoasc -loglevel quiet -vcodec copy $output`
# remove tmp folder
bin=`rm -rf $tmppath`
echo "mp4 created $output"
start $(dirname $output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment