Recoding AVCHD
The Panasonic TZ7 has many good sides, but in one particular point it falls down hard: The way it encodes AVCHD files.
A video stream consists of individual frames that in turn can contain three types of frame data:
-
I: Intra-coded data. This is data that is stand-alone.
-
P: Predictive-coded data. This is data that references previous frames. "I'm just like that frame before me, with these changes."
-
B: Bidirectional-coded data. This is data that references previous and following frames. "I'm just like that frame before me, with these changes, combined with that frame you have decoded but not shown yet, with these changes."
So a video stream can look like this, for example: IBBPBBPBBIBBPBBPBBI...
I-frames, frames containing nothing but I-coded data, are also known as keyframes and, since they can be decoded and shown without having to decode any other frames, are typically the only points that can be fast-forwarded to, or in general, the only frames from which the video clip can be random-accessed. They are also the only frames where the video stream can be cut without re-encoding parts or all of it.
So what does a TZ7 AVCHD-coded movie look like? Well: IPPPPPPPPPPP... That is, a single I-frame followed by nothing but P frames. What does that mean? Most important, it means that you can't trim the start of a clip without recoding it. Why is that a problem? Because recoding means loss of data and takes time. To add insult to injury, it is usually the start of the clip that is in most need of trimming - that's when you keep the camera running just so you don't miss something. Once that something has happened, turning off the camera is easy.
Recoding with FFmpeg
FFmpeg is pretty much the Swiss Army knife for manipulation of video files. I took a typical clip and recoded it with different parameters. The error below is the per-frame sum-of-squares of individual pixel errors introduced by the recoding. Each pixel is stored as a triplet of values [0..1), and the reference frame is subtracted from the recoded frame. In the resulting error frame, all values are component-wise squared and summed. The average error is the average of all error values across all frames (n = 100), and the standard deviation is the standard deviation for the 100 error values.
Codec | Mbps | Quality | Size (MB) | Average | Std. Dev. | Speed |
---|---|---|---|---|---|---|
TZ7 AVCHD | 17 | SH | 36.7 | 0.0 | 0.0 | - |
x264 | 48 | intra + lossless_ | 168.3 | 0.0 | 0.0 | Fast |
x264 | 48 | intra + default | 76.8 | 58.7 | 6.4 | Medium |
x264 | 48 | intra + normal | 77.7 | 60.2 | 6.4 | Fast |
x264 | 24 | max | 60.4 | 71.7 | 11.5 | Slow |
x264 | 24 | hq | 60.3 | 76.1 | 14.0 | Medium |
x264 | 16 | hq | 40.3 | 135.4 | 30.8 | Medium |
x264 | 24 | intra + max | 43.4 | 154.1 | 26.7 | Medium |
x264 | 14 | max | 35.3 | 152.6 | 36.5 | Slow |
x264 | 14 | hq | 35.3 | 161.7 | 40.2 | Medium |
mpeg4 | 14 | sameq | 32.9 | 243.7 | 23.4 | Fast |
mjpeg | 48 | -b 48M | 53.5 | 249.4 | 18.9 | Fast |
mjpeg | 27 | sameq | 64.5 | 275.3 | 11.1 | Fast |
x264 | 14 | intra + max | 26.1 | 312.5 | 48.8 | Medium |
Analysis
First, codecs rule. Second, bit rate rules. We can see that the h264 codec really does improve on the mpeg4 and mjpeg codecs.