Skip to content

Instantly share code, notes, and snippets.

@albert-zhang
Last active June 20, 2019 11:15
Show Gist options
  • Save albert-zhang/e95d891b3a19ae65db51ea28349ee112 to your computer and use it in GitHub Desktop.
Save albert-zhang/e95d891b3a19ae65db51ea28349ee112 to your computer and use it in GitHub Desktop.
ffmpeg

Convert to specific resolution:

ffmpeg -i input.mov -vcodec h264 -acodec aac -s 1280x720 output.mp4

ffmpeg -i {input}.mov -vcodec h264 -acodec aac -strict -2 output.mp4

Stream camera to rtmp on Mac:

ffmpeg -f avfoundation -framerate 30 -i "0" -c:v libx264 -an -f flv rtmp://localhost:1935/live/mystream

Stream file to rtmp:

ffmpeg -re -i ~/Desktop/input.mp4 -c copy -f flv rtmp://localhost:1935/live/mystream

Convert file to HLS:

ffmpeg -i input.mp4 -profile:v baseline -level 3.0 -s 640x360 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls mystream.m3u8

download m3u8

ref: https://stackoverflow.com/questions/32528595/ffmpeg-mp4-from-http-live-streaming-m3u8-file

ffmpeg -i http://.../playlist.m3u8 -c copy -bsf:a aac_adtstoasc output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment