Topfield make a variety of personal video recorders that allow for the transfer of recorded programmes via an onboard USB port. The ".rec" files they produce are MPEG2 transport streams with a 3760 byte header containing archive information for the PVR. This patch checks for the presence of "TFrc" in the first four bytes of a file and identifies it as an mpeg transport stream if present. It subsequently skips this header when the services are probed. With the patch in place these files are then fully supported by ffmpeg. topfield.rec is a short example of a topfield recording. Index: libavformat/mpegts.c =================================================================== --- libavformat/mpegts.c (revision 15938) +++ libavformat/mpegts.c (working copy) @@ -1179,6 +1179,13 @@ int score, fec_score, dvhs_score; #define CHECK_COUNT 10 + /* check for Topfield PVR "REC" file header */ + if(size>=4) { + if (p->buf[0]=='T' && p->buf[1]=='F' && p->buf[2]=='r' && p->buf[3]=='c') { + return AVPROBE_SCORE_MAX; + } + } + if (size < (TS_FEC_PACKET_SIZE * CHECK_COUNT)) return -1; @@ -1194,7 +1201,7 @@ else return -1; #else /* only use the extension for safer guess */ - if (match_ext(p->filename, "ts")) + if (match_ext(p->filename, "ts") || match_ext(p->filename, "rec")) return AVPROBE_SCORE_MAX; else return 0; @@ -1252,6 +1259,16 @@ len = get_buffer(pb, buf, sizeof(buf)); if (len != sizeof(buf)) goto fail; + + /* check for Topfield PVR "REC" file header and skip it */ + if (buf[0]=='T' && buf[1]=='F' && buf[2]=='r' && buf[3]=='c') { + pos += 0xeb0; + url_fseek(pb, pos, SEEK_SET); + len = get_buffer(pb, buf, sizeof(buf)); + if (len != sizeof(buf)) + goto fail; + } + ts->raw_packet_size = get_packet_size(buf, sizeof(buf)); if (ts->raw_packet_size <= 0) goto fail;