Skip to content

Instantly share code, notes, and snippets.

@zhuqling
Last active August 29, 2015 14:28
Show Gist options
  • Save zhuqling/6ccef21669a52e170a20 to your computer and use it in GitHub Desktop.
Save zhuqling/6ccef21669a52e170a20 to your computer and use it in GitHub Desktop.
ffmpeg for dummies

ffmpeg for dummies

Links:

https://trac.ffmpeg.org/wiki/StreamingGuide

https://ffmpeg.org/ffmpeg-devices.html

http://www.ffmpeg.org/ffmpeg-protocols.html#toc-rtp

http://tools.ietf.org/html/rfc3984

Installing ffmpeg

The --with-ffplay is necessary if you want to play streams.

brew install ffmpeg --with-ffplay

RTP broadcast on localhost:5600

Note this generates a .sdp file.

ffmpeg -re -f lavfi -i smptebars -vcodec libx264 -tune zerolatency -vf scale=1920:1080 -b 900k -sdp_file stream.sdp -f rtp "rtp://127.0.0.1:5600"

Mainly sends STAP-A packets.

Play above rtp stream

ffplay stream.sdp

List all AVFoundation devices

ffmpeg -f avfoundation -list_devices true -i ""

Record default AVFoundation device to MPEG-1 Video file

ffmpeg -f avfoundation -i "default" out.mpg

Stream from Default AVFoundation device

ffmpeg -re -f avfoundation -i "default" -vcodec libx264 -sdp_file stream.sdp -f rtp "rtp://127.0.0.1:5600"
ffmpeg -framerate 30 -f avfoundation -i "default" -vcodec libx264 -tune zerolatency -vf scale=1920:1080 -b 900k -sdp_file stream.sdp -f rtp "rtp://127.0.0.1:5600"

-frametate 30 may or may not be needed.

-tune zerolatency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment