Skip to content

Instantly share code, notes, and snippets.

@Domin8-IPTV
Created June 17, 2019 20:34
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save Domin8-IPTV/1eef34433ea75359c2a676d84cf4a575 to your computer and use it in GitHub Desktop.
Save Domin8-IPTV/1eef34433ea75359c2a676d84cf4a575 to your computer and use it in GitHub Desktop.
create hls live stream from files
#!/bin/bash
# Change this to path of file to stream /edit/to/vod/path.mp4
mediaFile="/edit/to/vod/path.mp4"
### 480x video400kbps audio40kbps ###
mediaStreams="-map 0"
audCodec="-acodec mp2"
audKbps="-b:a 40k"
vidCodec="-bsf h264_mp4toannexb -segment_format mpegts"
vidKbps="-b:v 400k"
vidRatio="-vf scale=480:-1"
mediaSegment="-f segment -segment_time 10"
mediaPaths="-segment_list /Library/WebServer/Documents/hls/wireshark/480/_playList.m3u8 /Library/WebServer/Documents/hls/wireshark/480/movSeg_%03d.ts"
/bin/ffmpeg -i "$mediaFile" $mediaStreams $audCodec $audKbps $vidCodec $vidKbps $vidRatio $mediaSegment $mediaPaths
### 640x video1200kbps audio40kbps ###
mediaStreams="-map 0"
audCodec="-acodec mp2"
audKbps="-b:a 40k"
vidCodec="-bsf h264_mp4toannexb -segment_format mpegts"
vidKbps="-b:v 1200k"
vidRatio="-vf scale=640:-1"
mediaPaths="-segment_list /Library/WebServer/Documents/hls/wireshark/640/_playList.m3u8 /Library/WebServer/Documents/hls/wireshark/640/movSeg_%03d.ts"
mediaSegment="-f segment -segment_time 10"
/bin/ffmpeg -i "$mediaFile" $mediaStreams $audCodec $audKbps $vidCodec $vidKbps $vidRatio $mediaSegment $mediaPaths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment