Skip to content

Instantly share code, notes, and snippets.

@Donmclean
Last active September 18, 2021 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Donmclean/7422e26eb9c5a83036af25d194387ec4 to your computer and use it in GitHub Desktop.
Save Donmclean/7422e26eb9c5a83036af25d194387ec4 to your computer and use it in GitHub Desktop.
Shell Stream audio with ffmpeg
ffmpeg -re -i INPUT -acodec libmp3lame -ab 160k -ar 44100 -f rtp rtp://host:port
#list device audio & video inputs
ffmpeg -f avfoundation -list_devices true -i ""
#stream from device audio & video inputs to rtmp
ffmpeg -f avfoundation -framerate 30 -i "0:2" -vcodec libx264 -tune zerolatency -s 1440x900 -acodec libmp3lame -f flv -strict -1 rtmp://host:port
#stream from audio inputs ONLY to rtmp
ffmpeg -f avfoundation -framerate 30 -i ":2" -acodec libmp3lame -f flv -strict -1 rtmp://host:port/live/$stream_name
#stream audio file
ffmpeg -re -i INPUT.mp3 -f flv -strict -1 rtmp://host:port
#Rip HLS Streams to MP4
ffmpeg -i http://.../playlist.m3u8 -c copy -bsf:a aac_adtstoasc output.mp4
#MP4 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 index.m3u8
#ffmpeg to facebook live
ffmpeg -f avfoundation -video_device_index 0 -framerate 30 -pixel_format uyvy422 -i ":1" -vcodec libx264 -pix_fmt yuv420p -preset medium -r 30 -g 60 -b:v 2500k -acodec libfdk_aac -ar 44100 -threads 6 -qscale 3 -b:a 128k -bufsize 512k -f flv "$rtmpUrl/$streamKey"
#stream encoded in h.264
ffmpeg -re -threads 4 -i input.mp4 -c:v libx264 -preset slow -crf 22 -ar 44100 -ac 2 -c:a aac -b:a 256k -f flv rtmp://host:port/live/$streamName
#convert audio to video with black background
ffmpeg -f lavfi -i color=c=black:s=640x480 -i someinput.mp3 -c:v libx264 -tune stillimage -pix_fmt yuv420p -shortest -c:a aac -b:a 128k output-with-audio.mp4
#normalize file loudness based on peak
ffmpeg-normalize originalFilePath -vdf -c:a libmp3lame -b:a 256k -nt peak -t 0 -vn -mn -o outputFilePath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment