ffmpeg is basically a very fast video and audio converter. It can grab from a live audio/video source. It can also convert between arbitrary sample rates and resize video on the fly with a high quality polyphase filter. ffmpeg reads from an arbitrary number of input “files” and writes to an arbitrary number of output “files”, which are specified by a plain output url.

How to install it in linux?

To install it in Linux - ubuntu, open the /etc/apt/sources.list file and add below lines and save the file.

deb http://ftp.uk.debian.org/debian jessie-backports main

Then update and install ffmpeg using below commands.

$ sudo apt-get update
$ sudo apt-get install ffmpeg

Here are few useful commands I tried using ffmpeg.

FFmeg syntax

ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Converting a yuv/raw video to MP4 video

For NV21 raw video,

ffmpeg -f rawvideo -vcodec rawvideo -s 352x288 -r 25 -pix_fmt nv21 -i sample_cif_nv21.yuv -c:v libx264 -preset slow -qp 0 sample_cif.mp4

For yuv420p raw video,

ffmpeg -f rawvideo -vcodec rawvideo -s 352x288 -r 25 -pix_fmt yuv420p -i sample_cif_yuv420p.yuv -c:v libx264 -preset slow -qp 0 sample_cif.mp4

where,

option Description
-f fmt force format
-vcodec codec force video codec (‘copy’ to copy stream)
-i infile
-c codec codec name
-f fmt force format
-f fmt force format
-r rate set frame rate (Hz value, fraction or abbreviation)
-s size set frame size (WxH or abbreviation)
-pre preset preset name
-qp quality 0 is best, 51

FFmpeg on Android

FFMPEG support for android is available in the below link.

https://github.com/guardianproject/android-ffmpeg