I wanted to try stream to a popular live-streaming service from a low-powered portable device. It could not do a good encode at the bitrates the streaming service limits us to. Never mind that even a high-powered device won't output good quality if you're limited to only 6000 Kbps H264.
The solution to this is a two PC streaming setup where the device you capture on sends a high-bitrate low-complexity stream to a more powerful PC such as a desktop or server. Usually a hardware encoder is used on the first device. This will then re-encode the video and send it onward.
The client device captures a stream and directs it to the server device (10.0.0.2), creating a RTP SDP file which can be used in place of manually specifying the input format to the second machine.
ffmpeg -f avfoundation -capture_cursor 1 -s 2880x1800 -pix_fmt 0rgb \
-i 1 -s 1400x900 -r 30 \
-c:v h264_videotoolbox -profile:v main -b:v 40M \
-sdp_file source.sdp -f rtp rtp://192.168.0.2:8080
The SDP file can then be transferred over to the second machine and the stream re-encoded on it.
ffmpeg -i source.sdp \
-s 1440x900 -r 30 -g 60 \
-c:v libx264 -keyint_min 30 -preset slow \
-b:v 6000k -minrate 6000k -maxrate 6000k -pix_fmt yuv420p \
-c:a aac -b:a 160k -ac 2 -ar 44100 \
-threads 0 -strict normal \
-f flv "rtmp://$ENDPOINT"
You'll note that this is a bit awkward to setup as you first have to run the client encode, copy over the file, and then run the server encode. The server encode will exit when the client quits. ffserver
would have been a good way to setup the second PC to encode on-demand but it was removed from FFmpeg. Maybe one day someone will have enough motivation to write a good replacement.