api.video
SearchCtrl K

Features

Developers

Glossary

All things video.

Full glossary

ffmpeg

FFmpeg

What is ffmpeg?

FFMPEG stands for Fast Forward Moving Picture Experts Group. It is a free and open source software project that offers many tools for video and audio processing. It's designed to run on a command line interface, and has many different libraries and programs to manipulate and handle video files. However, FFMPEG is available for use in many different programming languages. With FFMPEG, you can decode, encode, transcode, mux, demux, stream, filter and play most types of video and audio. A fun fact about the FFMPEG logo is that it is based on the zigzag scan used in entropy encoding for images and video.

FFMPEG offers three main command line tools:

  1. ffmpeg - a tool for converting audio or video formats. It can also capture and encode in real-time from hardware or software sources.
  2. ffplay - a media player that uses Simple DirectMedia Layer (SDL) and ffmpeg libraries.
  3. ffprobe - a tool for displaying details about your media in text, csv, xml or json.

The FFMPEG project was started by Farice Bellard under the pseudonym Gérard Lantau in 2000 and was then led by Michael Niedermayer from 2004 until 2015. Due to internal disagreements about how the project was managed, from 2011 on, FFMPEG was split into two forks -- FFMPEG and libav. Both projects were nearly identical in terms of what they contained, but distributors would have to choose which to use. Today, libav is reintegrated with FFMPEG. A new release of FFMPEG is published every roughly three months.

Most video programs include FFMPEG as a part of the video processing pipeline (api.video included). Part of what makes FFMPEG so popular is its inclusion of codecs for the encoding and/or decoding of most audio and video file formats, allowing it to be used for transcoding of all types of media files into a single common format. If you're interested in getting started with FFMPEG using Python, try this beginner's guide to popular commands.

Some examples in our sample applications include livestream.a.video and record.a.video. These two web apps record the camera using webRTC protocols. To stream on the web with api.video, this needs to be converted to RTMP. This is done using FFMPEG on an intermediate NodeJS server:

	var ops = [
				'-i','-',
        '-preset', 'ultrafast', '-tune', 'zerolatency', 
			  '-r', framerate, '-g', framerate*2, '-keyint_min',keyint_min, 
     				'-c:a', 'aac', '-b:a','44k', '-ar', 44100, 
			        '-f', 'flv', socket._rtmpDestination		
		
		];
	
		ffmpeg_process=spawn('ffmpeg', ops);

the operators take the incoming video stream, and using the ultrafast preset, and the zerolatency tuning, convert the video to flv (RTMP flash format), and send the file to the rtmpDestination variable.

In watermark.a.video the livestream further adds an image as a watermark:

var ops = [
				'-i', socket._watermarkUrl,
				'-i','-',
				'-preset', 'ultrafast', '-tune', 'zerolatency', 
			  '-r', framerate, '-g', framerate*2, '-keyint_min',keyint_min, 
				'-filter_complex', '[1:v][0:v] overlay=25:25',
     		'-c:a', 'aac', '-b:a','44k', '-ar', 44100, 
			  '-f', 'flv', socket._rtmpDestination		
		
		];

In this case, there are 2 inputs, the video, and the image (watermarkUrl). the filter_complex places the 0 input on top of the 1 input at x,y (25, 25).

These are just 2 small examples of the power that ffmpeg can harness with your videos.