Video codecs (All the things you never really wanted to know about them...!)

Sometimes, it is useful to know which codec a video is encoded in. 1

The first thing to be aware of, is that container formats are not codecs. Thus, a Flash video (with a .flv file extension) is not a codec, but a container supporting the following codecs: H.264, VP6, Sorenson H.263.
Actually, most popular file extension (.avi, .flv, divx, etc.) represent containers and not codecs.

How to know which codec is used in a video?

You have to know the Four Character Code (FourCC) that represent the video data format. has a list of FourCC representing compressed formats (as most video formats are).

One way to get the FourCC code is with tcprobe:

$  tcprobe -i test.avi
[tcprobe] RIFF data, AVI video
[avilib] V: 14.985 fps, codec=FMP4, frames=328, width=720, height=480
[avilib] A: 48000 Hz, format=0x50, bits=0, channels=2, bitrate=64 kbps,
[avilib]    899 chunks, 172608 bytes, VBR
[tcprobe] summary for test.avi, (*) = not default, 0 = not detected
import frame size: -g 720x480 [720x576] (*)
       frame rate: -f 14.985 [25.000] frc=0 (*)
      audio track: -a 0 [0] -e 48000,0,2 [48000,16,2] -n 0x50 [0x2000] (*)
               bitrate=64 kbps
           length: 328 frames, frame_time=66 msec, duration=0:00:21.888

In the example above, the codec is listed as FMP4, which we can know both from wikipedia and, is the default MPEG4 format used by ffmpeg.

tcprobe<code> does not seem to support .flv videos. For Flash videos, we can use the command <code>ffmpeg -i file.flv or even with mplayer:

$ ffmpeg -i file.flv
[... snip ...]
Input #0, flv, from 'file.flv':
  Duration: 00:09:20.6, start: 0.000000, bitrate: 64 kb/s
  Stream #0.0: Video: vp6f, yuv420p, 720x480, 29.97 fps(r)
  Stream #0.1: Audio: mp3, 44100 Hz, mono, 64 kb/s
Must supply at least one output file

Above, we can see (by looking carefully!) that the video codec used is vp6f which is apparently the same as VP6 2, which is one of the video codecs supported by Flash videos.

We could have found the same information with mplayer:

$ mplayer file.flv
[... snip ...]
libavformat file format detected.
[lavf] Video stream found, -vid 0
[lavf] Audio stream found, -aid 1
VIDEO:  [VP6F]  720x480  0bpp  29.970 fps    0.0 kbps ( 0.0 kbyte/s)

See the sample of videos with different codecs by ffmpeg: (useful for testing).

Flash video codecs

Using the above methods, we can find the following FourCC in flash videos: FLV1, VP6F.

There are two types of flv files, the one based on H.263 (which exists since Flash 6) and another based on VP6 (which was introduced in Flash 8). In Flash 9 Update 3 Adobe added support for MPEG-4, thus since this version flv files may also contain H.264 and HE-AAC.3

There seem to be an audio/video sync problem with VP6F videos 4

ffmpeg cannot make vp6 video. mencoder can.
mencoder -ovc vfw -xvfwopts codec=vp6vfw.dll -of lavf -o done.flv 5