segment-video.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/UsingHTTPLiveStreaming/UsingHTTPLiveStreaming.html
  3. # https://docs.peer5.com/guides/production-ready-hls-vod/
  4. # http://www.bogotobogo.com/VideoStreaming/ffmpeg_http_live_streaming_hls.php
  5. # https://www.encoding.com/blog/2014/02/24/simplify-http-live-streaming-encoding-com-hls-segmenter/
  6. # detailed example of ffmpeg cli options: https://forums.roku.com/viewtopic.php?t=60698
  7. # details of GOP params: https://superuser.com/questions/908280/what-is-the-correct-way-to-fix-keyframes-in-ffmpeg-for-dash
  8. # example ffmpeg for multi-transcoding: https://blog.twitch.tv/live-video-transmuxing-transcoding-ffmpeg-vs-twitchtranscoder-part-i-489c1c125f28
  9. # http://www.streamingmedia.com/Articles/ReadArticle.aspx?ArticleID=95251&PageNum=3
  10. # Tinkerboard (decoders only): https://tinkerboarding.co.uk/forum/archive/index.php/thread-51.html
  11. # adding hls to ffmpeg:
  12. # https://trac.ffmpeg.org/ticket/1642
  13. # https://trac.ffmpeg.org/ticket/1642
  14. # https://trac.ffmpeg.org/wiki/EncodingForStreamingSites
  15. # rpi omx: https://signal-flag-z.blogspot.com/2017/05/raspberry-pix264ffmpeg.html
  16. VIDEO_PATH="$1"
  17. VIDEO_PATH_PREFIX=$(echo "$VIDEO_PATH" | cut -f 1 -d '.')
  18. PLAYLIST_PATH="$VIDEO_PATH_PREFIX.m3u8"
  19. avconv \
  20. -i $VIDEO_PATH \
  21. -c copy \
  22. -flags \
  23. +cgop \
  24. -g 30 \
  25. -hls_time 2 \
  26. -hls_list_size 100000 \
  27. -bsf h264_mp4toannexb \
  28. $PLAYLIST_PATH