Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # (C) Copyright 2012 by Madhawa Jayanath ([email protected])
- #
- #
- # This program is free software; you can redistribute it and/or modify it under
- # the terms of the GNU General Public License as published by the Free Software
- # Foundation; either version 3 of the License, or (at your option) any later
- # version.
- #
- # This program is distributed in the hope that it will be useful, but WITHOUT
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- # details.
- #
- # You should have received a copy of the GNU General Public License along with
- # this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
- # Street, Fifth Floor, Boston, MA 02110-1301, USA.
- array=(`ls -1 /dev/shm/stream128ios*.ts`)
- len=${#array[*]}
- if [ $len -gt 20 ] ; then
- rm -f `echo ${array[0]}`
- fi
- seq=`echo ${array[$len-5]}| cut -c22-30 | sed 's/^0*//g'`
- durationa=`mediainfo --Inform='Video;%Duration/String3%' ${array[$len-5]} | cut -c7-11 | bc`
- durationa=`printf %0.f $durationa`
- durationb=`mediainfo --Inform='Video;%Duration/String3%' ${array[$len-4]} | cut -c7-11 | bc`
- durationb=`printf %0.f $durationb`
- durationc=`mediainfo --Inform='Video;%Duration/String3%' ${array[$len-3]} | cut -c7-11 | bc`
- durationc=`printf %0.f $durationc`
- durationd=`mediainfo --Inform='Video;%Duration/String3%' ${array[$len-2]} | cut -c7-11 | bc`
- durationd=`printf %0.f $durationd`
- tduration=10
- if [ $durationa -gt $tduration ] ; then
- tduration=$durationa
- fi
- if [ $durationb -gt $tduration ] ; then
- tduration=$durationb
- fi
- if [ $durationc -gt $tduration ] ; then
- tduration=$durationc
- fi
- if [ $durationd -gt $tduration ] ; then
- tduration=$durationd
- fi
- echo "#EXTM3U" > /dev/shm/abcd_live_128k.m3u8
- echo "#EXT-X-VERSION:1" >> /dev/shm/abcd_live_128k.m3u8
- echo "#EXT-X-ALLOW-CACHE:NO" >> /dev/shm/abcd_live_128k.m3u8
- echo "#EXT-X-TARGETDURATION:$tduration" >> /dev/shm/abcd_live_128k.m3u8
- echo "#EXT-X-MEDIA-SEQUENCE:$seq" >> /dev/shm/abcd_live_128k.m3u8
- echo "#EXTINF:$durationa," >> /dev/shm/abcd_live_128k.m3u8
- SUBSTRING=`echo ${array[$len-5]}| cut -c22-30`
- echo "http://123.123.117.37/hls/stream128ios$SUBSTRING.ts" >> /dev/shm/abcd_live_128k.m3u8
- echo "#EXTINF:$durationb," >> /dev/shm/abcd_live_128k.m3u8
- SUBSTRING=`echo ${array[$len-4]}| cut -c22-30`
- echo "http://123.123.117.37/hls/stream128ios$SUBSTRING.ts" >> /dev/shm/abcd_live_128k.m3u8
- echo "#EXTINF:$durationc," >> /dev/shm/abcd_live_128k.m3u8
- SUBSTRING=`echo ${array[$len-3]}| cut -c22-30`
- echo "http://123.123.117.37/hls/stream128ios$SUBSTRING.ts" >> /dev/shm/abcd_live_128k.m3u8
- echo "#EXTINF:$durationd," >> /dev/shm/abcd_live_128k.m3u8
- SUBSTRING=`echo ${array[$len-2]}| cut -c22-30`
- echo "http://123.123.117.37/hls/stream128ios$SUBSTRING.ts" >> /dev/shm/abcd_live_128k.m3u8
- exit
Advertisement
Add Comment
Please, Sign In to add comment