madhawa

Sample "makem3u8_128k" for Apple HLS on FFMpeg Encoder

May 30th, 2012
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.87 KB | None | 0 0
  1. #!/bin/bash
  2. # (C) Copyright 2012 by Madhawa Jayanath ([email protected])
  3. #
  4. #
  5. # This program is free software; you can redistribute it and/or modify it under
  6. # the terms of the GNU General Public License as published by the Free Software
  7. # Foundation; either version 3 of the License, or (at your option) any later
  8. # version.
  9. #
  10. # This program is distributed in the hope that it will be useful, but WITHOUT
  11. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  13. # details.
  14. #
  15. # You should have received a copy of the GNU General Public License along with
  16. # this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
  17. # Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18.  
  19. array=(`ls -1 /dev/shm/stream128ios*.ts`)
  20. len=${#array[*]}
  21. if [ $len -gt 20 ] ; then
  22. rm -f `echo ${array[0]}`
  23. fi
  24.  
  25. seq=`echo ${array[$len-5]}| cut -c22-30 | sed 's/^0*//g'`
  26.  
  27. durationa=`mediainfo --Inform='Video;%Duration/String3%' ${array[$len-5]} | cut -c7-11 | bc`
  28. durationa=`printf %0.f $durationa`
  29.  
  30. durationb=`mediainfo --Inform='Video;%Duration/String3%' ${array[$len-4]} | cut -c7-11 | bc`
  31. durationb=`printf %0.f $durationb`
  32.  
  33. durationc=`mediainfo --Inform='Video;%Duration/String3%' ${array[$len-3]} | cut -c7-11 | bc`
  34. durationc=`printf %0.f $durationc`
  35.  
  36. durationd=`mediainfo --Inform='Video;%Duration/String3%' ${array[$len-2]} | cut -c7-11 | bc`
  37. durationd=`printf %0.f $durationd`
  38.  
  39. tduration=10
  40.  
  41. if [ $durationa -gt $tduration ] ; then
  42. tduration=$durationa
  43. fi
  44.  
  45. if [ $durationb -gt $tduration ] ; then
  46. tduration=$durationb
  47. fi
  48.  
  49. if [ $durationc -gt $tduration ] ; then
  50. tduration=$durationc
  51. fi
  52.  
  53. if [ $durationd -gt $tduration ] ; then
  54. tduration=$durationd
  55. fi
  56.  
  57. echo "#EXTM3U" > /dev/shm/abcd_live_128k.m3u8
  58. echo "#EXT-X-VERSION:1" >> /dev/shm/abcd_live_128k.m3u8
  59. echo "#EXT-X-ALLOW-CACHE:NO" >> /dev/shm/abcd_live_128k.m3u8
  60. echo "#EXT-X-TARGETDURATION:$tduration" >> /dev/shm/abcd_live_128k.m3u8
  61. echo "#EXT-X-MEDIA-SEQUENCE:$seq" >> /dev/shm/abcd_live_128k.m3u8
  62.  
  63. echo "#EXTINF:$durationa," >> /dev/shm/abcd_live_128k.m3u8
  64. SUBSTRING=`echo ${array[$len-5]}| cut -c22-30`
  65. echo "http://123.123.117.37/hls/stream128ios$SUBSTRING.ts" >> /dev/shm/abcd_live_128k.m3u8
  66.  
  67. echo "#EXTINF:$durationb," >> /dev/shm/abcd_live_128k.m3u8
  68. SUBSTRING=`echo ${array[$len-4]}| cut -c22-30`
  69. echo "http://123.123.117.37/hls/stream128ios$SUBSTRING.ts" >> /dev/shm/abcd_live_128k.m3u8
  70.  
  71. echo "#EXTINF:$durationc," >> /dev/shm/abcd_live_128k.m3u8
  72. SUBSTRING=`echo ${array[$len-3]}| cut -c22-30`
  73. echo "http://123.123.117.37/hls/stream128ios$SUBSTRING.ts" >> /dev/shm/abcd_live_128k.m3u8
  74.  
  75. echo "#EXTINF:$durationd," >> /dev/shm/abcd_live_128k.m3u8
  76. SUBSTRING=`echo ${array[$len-2]}| cut -c22-30`
  77. echo "http://123.123.117.37/hls/stream128ios$SUBSTRING.ts" >> /dev/shm/abcd_live_128k.m3u8
  78.  
  79. exit
Advertisement
Add Comment
Please, Sign In to add comment