https://blog.maxwellgale.com/2021/01/30/streaming-video-over-webrtc-using-ffmpeg/ * Home * Contact Max Gale's Blog * Home * Contact * Press ESC to close [ ] Programming Streaming video over WebRTC using FFmpeg Max Gale January 30, 2021 0 Comments 0 13304 Note: The original version of this post highlighted the disadvantages of using a fixed key frame interval. I've since learned that this problem can be avoided using intra refresh in the H264 stream. Streaming media. specifically video, is a fickle beast. This will be a short post, but it will cover everything you need to know to stream media using FFmpeg to WebRTC clients. This technique has many applications, such as streaming synchronized videos to users. Setting up the input Before inputting a file into FFmpeg, we need to pass a few flags: > ffmpeg \ -v info \ -fflags +genpts \ -protocol_whitelist pipe,tls,file,http,https,tcp,rtp \ These flags set the log level to info, generate pts if they're missing, and sets up the protocols we can use. Next we need to provide the input to FFmpeg. -i in.mp4 In this example, a file name in.mp4 is used, but a http(s) URL could also be used. This command starts playback at the beginning of the input file. If you want to start playback in the middle of the input file, then you can add the -ss