Linux shell wget download batch ts files from m3u8 and merge into 1 file

1. Get m2u8 through your web browser. Chrome/Development mode.  F10/F5, search m3u8 

2. Download all ts files through m3u8

3. Cat every ts files into one ts file. MPEG/Ts

4. Merge your ts file into one MPEG4. Use MediaCodec/Windows or FFMPEG/Linux 

Linux Shell for ts and merge through m3u8 

lake@localhost:~/tmp/aoshu$ cat aoshu_m3u8.sh 
#!/bin/bash
###demo 
##URL="https://wscdn.alhls.xiaoka.tv/2018714/e23/2d6/j-2g0QAhJnGSBxnN/index.m3u8"
 

input_m3u8_filename=`echo $URL| awk  -F "/"  '{print $NF}'` 
URLHead=`echo $URL| awk  -F "/"  'OFS="/"{$NF="";print}'` 
urlfilename=""
allfilename=""
linenumber=0;

echo $URL
echo $input_m3u8_filename
echo $URLHead

finalfilename=aoshu`date -d today +"%Y-%m-%d_%H%M"`.ts

touch   $finalfilename 

wget -q -c  $URL 
cat $input_m3u8_filename | grep -v "^#" |while read tsfilename; 
do 
   linenumber=`expr $linenumber + 1`; 
   urlfilename=$URLHead$tsfilename
   echo "$linenumber  wget   -q -c    $urlfilename"
   wget  -q -c   $urlfilename
   echo $linenumber  :  $allfilename
   cat  $finalfilename $tsfilename >temp
   mv temp   $finalfilename
   ##sleep  2 

done 

 
 

猜你喜欢

转载自blog.csdn.net/hushui/article/details/81454265