Download and merge TS fragments from m3u8 index

HLS, DASH and everything else
admin
Site Admin
Posts: 12
Joined: Thu Oct 03, 2013 5:49 pm

Download and merge TS fragments from m3u8 index

Postby admin » Tue Feb 13, 2018 11:27 am

If you have the index and it's called index_1_av.m3u8

Download all fragments:

Code: Select all

wget -I index_1_av.m3u8


merge the fragments:

Code: Select all

#!/bin/bash
 
NUM_SEGMENTS=653
OUT_FILE=MyVideo.ts

rm $OUT_FILE

# Tested using bash version 4.1.5
#for ((i=1;i<=100;i++));
for ((i=1;i<=($NUM_SEGMENTS-1);i++));
do
   # your-unix-command-here
   FILENAME=segment"$i"_1_av.ts
   cat $FILENAME >> $OUT_FILE
done

fabiodelorenzo
Posts: 65
Joined: Thu Oct 03, 2013 5:54 pm

Re: Download and merge TS fragments from m3u8 index

Postby fabiodelorenzo » Thu Feb 22, 2018 10:07 am

admin wrote:If you have the index and it's called index_1_av.m3u8

Download all fragments:

Code: Select all

wget -i index_1_av.m3u8


merge the fragments:

Code: Select all

#!/bin/bash
 
NUM_SEGMENTS=653
OUT_FILE=MyVideo.ts

rm $OUT_FILE

# Tested using bash version 4.1.5
#for ((i=1;i<=100;i++));
for ((i=1;i<=($NUM_SEGMENTS-1);i++));
do
   # your-unix-command-here
   FILENAME=segment"$i"_1_av.ts
   cat $FILENAME >> $OUT_FILE
done

fabiodelorenzo
Posts: 65
Joined: Thu Oct 03, 2013 5:54 pm

Re: Download and merge TS fragments from m3u8 index

Postby fabiodelorenzo » Thu Feb 22, 2018 10:41 am

admin wrote:If you have the index and it's called index_1_av.m3u8

Download all fragments:

Code: Select all

wget -I index_1_av.m3u8


merge the fragments:

Code: Select all

#!/bin/bash
 
OUT_FILE=MyVideo.ts

NUM_SEGMENTS=`ls -l *.ts  | wc -l`

echo "NUM SEGMENTS: $NUM_SEGMENTS"

rm $OUT_FILE

# Tested using bash version 4.1.5
#for ((i=1;i<=100;i++));
for ((i=1;i<=($NUM_SEGMENTS);i++));
do
   # your-unix-command-here
   FILENAME=segment"$i"_1_av.ts
   cat $FILENAME >> $OUT_FILE
done


Return to “Segmented video Streaming”

Who is online

Users browsing this forum: No registered users and 0 guests