media.sh 748 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. Media="$1"
  3. Uploader="upload_yuque.sh"
  4. Thread=2
  5. # Main
  6. if [ -n "${Media}" ] && [ -f "${Media}" ]; then
  7. echo "media file: '${Media}'."
  8. else
  9. echo "Not found '${Media}'."
  10. exit 1
  11. fi
  12. MediaName=`basename "${Media}" |cut -d'.' -f1`
  13. OutPutM3u8="${MediaName}.m3u8"
  14. OutPutLog="${MediaName}.log"
  15. MediaFloder="${MediaName}.output"
  16. ## m3u8
  17. ffmpeg -i ${Media} -threads ${Thread} -thread_type slice -vcodec copy -acodec aac -bsf:v h264_mp4toannexb -map 0 -f segment -segment_list output.m3u8 -segment_time 10 ${MediaFloder}/output_%03d.ts
  18. ## upload
  19. if [ -f "${Uploader}" ]; then
  20. bash "${Uploader}" "${MediaFloder}" |tee -a "${OutPutLog}"
  21. ## mod m3u8
  22. if [ -f "m3u8.sh" ]; then
  23. bash "m3u8.sh" "${OutPutLog}" "${OutPutM3u8}"
  24. fi
  25. fi