Today, I learned how to use framecrc as a debug tool. Many Libav tests use framecrc to compare expected and actual decoding. While rewriting existing code, the output from the old and new versions of the code on the same sample can be checked; this makes a lot of mistakes clear quickly, including ones that can be quite difficult to debug otherwise.
Checking framecrcs interactively is straightforward:
./avconv -i somefile -c:a copy -f framecrc -. The
-c:a copy specifies that the original, rather than decoded, packet should be used. The
- at the end makes the output go to stdout, rather than a named file.
The output has several columns, for the stream index, dts, pts, duration, packet size, and crc:
0, 0, 0, 192, 2304, 0xbf0a6b45
0, 192, 192, 192, 2304, 0xdd016b78
0, 384, 384, 192, 2304, 0x18da71d6
0, 576, 576, 192, 2304, 0xcf5a6a07
0, 768, 768, 192, 2304, 0x3a84620a
It is also unusually simple to find out what the fields are, as libavformat/framecrcenc.c spells it out quite clearly:
static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
uint32_t crc = av_adler32_update(0, pkt->data, pkt->size);
snprintf(buf, sizeof(buf), “%d, %10″PRId64″, %10″PRId64″, %8d, %8d, 0x%08″PRIx32″\n”,
pkt->stream_index, pkt->dts, pkt->pts, pkt->duration, pkt->size, crc);
avio_write(s->pb, buf, strlen(buf));
Keiler, one of my Libav mentors, patiently explained the above; I hope documenting it helps other people who are starting with Libav development.