Opened 12 years ago

Last modified 9 years ago

#1482 open enhancement

Support eia_608 in wtv

Reported by: ramitb Owned by:
Priority: wish Component: avformat
Version: git-master Keywords: cc wtv
Cc: Anshul Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug: When extracing subtitles in SRT format FFMPEG creates a file but it is an illegible format.

The link to the original file (too big to attach)
http://www.mediafire.com/?dnvw6m61mky8pea

Attaching the output file created

How to reproduce:
COMMAND:
ffmpeg -i srt.ts -an -vn -scodec copy -copyinkf -f srt sub.srt

ffmpeg version N-41578-ga5c1a0c Copyright (c) 2000-2012 the FFmpeg developers
  built on Jun 13 2012 22:34:53 with gcc 4.6.3
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enab
le-bzlib --enable-frei0r --enable-libass --enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable
-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-librtmp --enable-libschro
edinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-
libvorbis --enable-libvpx --ena  libavutil      51. 58.100 / 51. 58.100
  libavcodec     54. 25.100 / 54. 25.100
  libavformat    54.  6.101 / 54.  6.101
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 79.100 /  2. 79.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[mpegts @ 002dbd00] max_analyze_duration 5000000 reached at 5000000
[NULL @ 02b171c0] start time is not set in estimate_timings_from_pts
Input #0, mpegts, from 'srt.ts':
  Duration: 00:01:38.16, start: 0.151678, bitrate: 4310 kb/s
  Program 1
    Stream #0:0[0x30]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 15000 kb
/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x40](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16, 256 kb/s
    Stream #0:2[0x50](eng): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Output #0, srt, to 'sub.srt':
  Metadata:
    encoder         : Lavf54.6.101
    Stream #0:0(eng): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream mapping:
  Stream #0:2 -> #0:0 (copy)
Press [q] to stop, [?] for help
size=     113kB time=00:01:37.25 bitrate=   9.5kbits/s
video:0kB audio:0kB global headers:0kB muxing overhead inf%
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)

Attachments (1)

sub.srt (113.2 KB ) - added by ramitb 12 years ago.

Download all attachments as: .zip

Change History (31)

by ramitb, 12 years ago

Attachment: sub.srt added

comment:1 by Cigaes, 12 years ago

Please check with latest Git head before submitting a bug report. The issue your are reporting has been fixed two days ago.

That does not mean your command will work: it can not, as subtitles in your MPEG-TS file are images and ffmpeg does not implement an OCR system. But at least it will fail with a clear message:

[srt @ 0x80fe40] Unsupported subtitles codec: dvb_subtitle

comment:2 by ramitb, 12 years ago

Okay thanks.

How did you know it's a image and not text?

Reason I'm asking, I tried a different file - a WTV file which has Closed Captions (I'm able to extract them using CCExtractor after converting it to a TS file).

When I try to use FFMPEG wtih teh WTV file, here's the error I get:

ffmpeg -i "..\NCIS HD.wtv" -an -vn -scodec copy -copyinkf -f srt sub.srt

ffmpeg version N-41843-gc17808c Copyright (c) 2000-2012 the FFmpeg developers
  built on Jun 22 2012 17:40:07 with gcc 4.7.1
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enab
le-bzlib --enable-frei0r --enable-libass --enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable
-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-librtmp --enable-libschro
edinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-
libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      51. 61.100 / 51. 61.100
  libavcodec     54. 29.100 / 54. 29.100
  libavformat    54. 11.100 / 54. 11.100
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 82.100 /  2. 82.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[mpeg2video @ 01d77800] mpeg_decode_postinit() failure
    Last message repeated 10 times
Input #0, wtv, from '..\NCIS HD.wtv':
  Metadata:
    WM/MediaClassPrimaryID: db9830bd-3ab3-4fab-8a371a995f7ff74
    WM/MediaClassSecondaryID: ba7f258a-62f7-47a9-b21f4651c42a000
    Title           : NCIS: Los Angeles
    WM/SubTitle     : Sacrifice
    WM/SubTitleDescription: The LAPD asks NCIS for help when a case exposes a link between a Mexican drug cartel and a t
errorist.
    genre           : Drama;General;Series;Action/Adventure
    WM/OriginalReleaseTime: 0
    WM/MediaCredits : Chris O'Donnell/LL Cool J/Linda Hunt/Daniela Ruah/Eric Christian Olsen/Barrett Foa/Renée Felice S
mith;John P. Kousakis;;America Olivo/Brant Cotton/Doug Rao/Danny Nucci/Gino Montesinos/Farshad Farahat/Carlos Arellano/C
heryl Texiera/Brian Michael Jones/Jen
    service_provider: KPHODT
    service_name    : KPHODT (KPHO-DT)
    WM/MediaNetworkAffiliation: CBS Affiliate
    WM/MediaOriginalChannel: 5
    WM/MediaOriginalChannelSubNumber: 1
    WM/MediaOriginalBroadcastDateTime: 2011-10-18T07:00:00Z
    WM/MediaOriginalRunTime: 38375940244
    WM/MediaIsStereo: true
    WM/MediaIsRepeat: false
    WM/MediaIsLive  : false
    WM/MediaIsTape  : false
    WM/MediaIsDelay : false
    WM/MediaIsSubtitled: false
    WM/MediaIsMovie : false
    WM/MediaIsPremiere: false
    WM/MediaIsFinale: false
    WM/MediaIsSAP   : false
    WM/MediaIsSport : false
    WM/ParentalRating: TV-14
    WM/Provider     : MediaCenterDefault
    WM/VideoClosedCaptioning: true
    WM/WMRVEncodeTime: 2011-10-19 03:00:02
    WM/WMRVSeriesUID: !MCSeries!01158361
    WM/WMRVServiceID: !MCService!28455624
    WM/WMRVProgramID: !MCProgram!264522248
    WM/WMRVRequestID: 0
    WM/WMRVScheduleItemID: 0
    WM/WMRVQuality  : 3
    WM/WMRVOriginalSoftPrePadding: 420
    WM/WMRVOriginalSoftPostPadding: 180
    WM/WMRVHardPrePadding: -300
    WM/WMRVHardPostPadding: 0
    WM/WMRVATSCContent: true
    WM/WMRVDTVContent: true
    WM/WMRVHDContent: true
    Duration        : 36582312388
    WM/WMRVEndTime  : 2011-10-19 04:01:00
    WM/WMRVBitrate  : 12.738619
    WM/WMRVKeepUntil: 0
    WM/WMRVActualSoftPrePadding: 297
    WM/WMRVActualSoftPostPadding: 0
    WM/WMRVContentProtected: false
    WM/WMRVContentProtectedPercent: 0
    WM/WMRVExpirationSpan: 9223372036854775807
    WM/WMRVInBandRatingSystem: 255
    WM/WMRVInBandRatingLevel: 255
    WM/WMRVInBandRatingAttributes: 0
    WM/WMRVWatched  : false
    WM/MediaThumbWidth: 352
    WM/MediaThumbHeight: 198
    WM/MediaThumbStride: 1056
    WM/MediaThumbRet: 0
    WM/MediaThumbRatingSystem: 255
    WM/MediaThumbRatingLevel: 255
    WM/MediaThumbRatingAttributes: 0
    WM/MediaThumbAspectRatioX: 16
    WM/MediaThumbAspectRatioY: 9
    WM/MediaThumbTimeStamp: 4634350287386204132
    WM/MediaThumbType: 3
  Duration: 01:00:57.28, start: 1.797444, bitrate: 12741 kb/s
    Stream #0:0[0xe](eng): Audio: ac3, 48000 Hz, 5.1(side), s16, 384 kb/s
    Stream #0:1[0xf](eng): Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
    Stream #0:2[0x10]: Video: mpeg2video (Main), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 38810 kb/s, 57.22 fps, 29.97 tbr
, 10000k tbn, 59.94 tbc
    Stream #0:3[0x11]: Subtitle: dvb_teletext
    Stream #0:4[0x0]: Attachment: mjpeg
    Metadata:
      title           : TV Thumbnail
[srt @ 033150e0] Unsupported subtitles codec: dvb_teletext
Output #0, srt, to 'sub.srt':
  Metadata:
    WM/MediaClassPrimaryID: db9830bd-3ab3-4fab-8a371a995f7ff74
    WM/MediaClassSecondaryID: ba7f258a-62f7-47a9-b21f4651c42a000
    Title           : NCIS: Los Angeles
    WM/SubTitle     : Sacrifice
    WM/SubTitleDescription: The LAPD asks NCIS for help when a case exposes a link between a Mexican drug cartel and a t
errorist.
    genre           : Drama;General;Series;Action/Adventure
    WM/OriginalReleaseTime: 0
    WM/MediaCredits : Chris O'Donnell/LL Cool J/Linda Hunt/Daniela Ruah/Eric Christian Olsen/Barrett Foa/Renée Felice S
mith;John P. Kousakis;;America Olivo/Brant Cotton/Doug Rao/Danny Nucci/Gino Montesinos/Farshad Farahat/Carlos Arellano/C
heryl Texiera/Brian Michael Jones/Jen
    service_provider: KPHODT
    service_name    : KPHODT (KPHO-DT)
    WM/MediaNetworkAffiliation: CBS Affiliate
    WM/MediaOriginalChannel: 5
    WM/MediaOriginalChannelSubNumber: 1
    WM/MediaOriginalBroadcastDateTime: 2011-10-18T07:00:00Z
    WM/MediaOriginalRunTime: 38375940244
    WM/MediaIsStereo: true
    WM/MediaIsRepeat: false
    WM/MediaIsLive  : false
    WM/MediaIsTape  : false
    WM/MediaIsDelay : false
    WM/MediaIsSubtitled: false
    WM/MediaIsMovie : false
    WM/MediaIsPremiere: false
    WM/MediaIsFinale: false
    WM/MediaIsSAP   : false
    WM/MediaIsSport : false
    WM/ParentalRating: TV-14
    WM/Provider     : MediaCenterDefault
    WM/VideoClosedCaptioning: true
    WM/WMRVEncodeTime: 2011-10-19 03:00:02
    WM/WMRVSeriesUID: !MCSeries!01158361
    WM/WMRVServiceID: !MCService!28455624
    WM/WMRVProgramID: !MCProgram!264522248
    WM/WMRVRequestID: 0
    WM/WMRVScheduleItemID: 0
    WM/WMRVQuality  : 3
    WM/WMRVOriginalSoftPrePadding: 420
    WM/WMRVOriginalSoftPostPadding: 180
    WM/WMRVHardPrePadding: -300
    WM/WMRVHardPostPadding: 0
    WM/WMRVATSCContent: true
    WM/WMRVDTVContent: true
    WM/WMRVHDContent: true
    Duration        : 36582312388
    WM/WMRVEndTime  : 2011-10-19 04:01:00
    WM/WMRVBitrate  : 12.738619
    WM/WMRVKeepUntil: 0
    WM/WMRVActualSoftPrePadding: 297
    WM/WMRVActualSoftPostPadding: 0
    WM/WMRVContentProtected: false
    WM/WMRVContentProtectedPercent: 0
    WM/WMRVExpirationSpan: 9223372036854775807
    WM/WMRVInBandRatingSystem: 255
    WM/WMRVInBandRatingLevel: 255
    WM/WMRVInBandRatingAttributes: 0
    WM/WMRVWatched  : false
    WM/MediaThumbWidth: 352
    WM/MediaThumbHeight: 198
    WM/MediaThumbStride: 1056
    WM/MediaThumbRet: 0
    WM/MediaThumbRatingSystem: 255
    WM/MediaThumbRatingLevel: 255
    WM/MediaThumbRatingAttributes: 0
    WM/MediaThumbAspectRatioX: 16
    WM/MediaThumbAspectRatioY: 9
    WM/MediaThumbTimeStamp: 4634350287386204132
    WM/MediaThumbType: 3
    encoder         : Lavf54.11.100
    Stream #0:0: Subtitle: dvb_teletext
Stream mapping:
  Stream #0:3 -> #0:0 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

in reply to:  2 comment:3 by Cigaes, 12 years ago

Replying to ramitbhalla:

How did you know it's a image and not text?

Your copy-pasted console output had:

Stream #0:2[0x50](eng): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)

dvb_subtitle is a bitmap codec.

Reason I'm asking, I tried a different file - a WTV file which has Closed Captions (I'm able to extract them using CCExtractor after converting it to a TS file).
When I try to use FFMPEG wtih teh WTV file, here's the error I get:

    Stream #0:3[0x11]: Subtitle: dvb_teletext
[srt @ 033150e0] Unsupported subtitles codec: dvb_teletext

That is normal with the current state of affairs, but it may be possible to enhance it. Can you point me to a file with such a track? It does not need to be big, just a few subtitles exchanges would be enough.

comment:4 by ramitb, 12 years ago

in reply to:  4 comment:5 by Carl Eugen Hoyos, 12 years ago

Replying to ramitbhalla:

The file is uploaded at:
http://www.mediafire.com/?8p2xgb7navf7m1b

Which application shows subtitles for this sample (and when)?

comment:6 by ramitb, 12 years ago

Okay the app name is CCExtractor (it' a free CLI/GUI app) - just run with GUI and default settings.

Before you can get CCExtractor to work on it you need to convert it to MPEGTS

I use FFMPEG -i ncis.ts -vcodec copy -acodec copy -scodec copy ncis.ts

Then CCExtractor will take out the subtitles and store them as a SRT file

comment:7 by ramitb, 12 years ago

One more problem I've seen (in the same wtv file above). when using the ffmpeg command to copy the subtitle stream it converts the subtitles from dvb_teletext to dvb_subtitle (from text to image if I understand correct).

Is that normal? Shouldn' it preserve the teletext stream?

e.g. ffmpeg -i ncis.wtv

  Duration: 00:31:59.52, start: 1.797444, bitrate: 874 kb/s
    Stream #0:0[0xe](eng): Audio: ac3, 48000 Hz, 5.1(side), s16, 384 kb/s
    Stream #0:1[0xf](eng): Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
    Stream #0:2[0x10]: Video: mpeg2video (Main), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 38810 kb/s, 57.22 fps, 29.97 tbr
, 10000k tbn, 59.94 tbc
    Stream #0:3[0x11]: Subtitle: dvb_teletext
    Stream #0:4[0x0]: Attachment: mjpeg

After stream copying to TS, ffmpeg -i ncis.ts

    Stream #0:0[0x100](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), s16, 384 kb/s
    Stream #0:1[0x101](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, s16, 192 kb/s
    Stream #0:2[0x102]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 38810 k
b/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:3[0x103](eng): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)

comment:8 by ramitb, 12 years ago

Hi any thoughts on this?

also can you please let me know what's the correct command for ffmpeg to extract the bitmap subtitles from a TS stream (svb_subtitle) into a subtitle image format (.sup)?

comment:9 by Cigaes, 12 years ago

I have several problems with this issue:

First of all, in your WTV file, none of the subtitles packets have the keyframe flag. As a consequence, -scodec copy does not copy anything. And with -copyinkf:s, I get the infamous non monotonically increasing dts.

Second, if I remux only the video, not the subtitles, then ccextractor sees the subtitles in the resulting TS file. That means that the CC subtitles are not in fact in the subtitle stream but in the video stream. I do not know whether that is normal or whether the WTV demuxer is at fault.

comment:10 by ramitb, 12 years ago

  1. Any solution how to handle this? I'm getting the same issues with another TS file recording. If you'd like I can upload that that too
  1. That I believe is normal, the CC is embedded as part of the video, which is why when FFMPEG "recodes" the video (not copy) it loses the CC stream. CCExtractor extracts the CC directly from the video stream. Can FFMPEG also do it?

I'm more interested in 1, since that's where most of the non US/international subtitles exist. This is the standard MCE recording format that I've uploaded

comment:11 by pross, 12 years ago

NCIS.wtv is an interesting file:

  • stream 0 & 1 contain AC3 audio (one for visual impaired persons)
  • stream 2, which WTV reports as video, also contains

Subtitles
MP2 audio
SDT metadata

WTV clearly marks the stream as video. Just a a guess, this probably the fault of the broadcaster.

  • stream 3 has DVB_TELETEXT encoded subtitles. FFmpeg doesnt have the capability to decode teletext at present.

in reply to:  11 comment:12 by Carl Eugen Hoyos, 12 years ago

Keywords: cc added
Version: unspecifiedgit-master

Replying to pross:

  • stream 3 has DVB_TELETEXT encoded subtitles. FFmpeg doesnt have the capability to decode teletext at present.

It is supposed to work with mplayer -demuxer lavf -sid 0 (pressing "X") but MPlayer claims there is no actual teletext data transmitted.

comment:13 by pross, 12 years ago

Correction:

Stream 3 of the NCIS.wtv actually contains EIA-608/Line 21 subtitles.

FFmpeg doesnt have AV_CODEC_ID for this subtitle codec. It is reporting it as AV_CODEC_ID_DVB_TELETEXT, hence why Mplayer fails to decode it.

comment:14 by reimar, 12 years ago

Why are you claiming that? FFmpeg does have CODEC_ID_EIA_608 which is supported both in MOV and MXF.

comment:15 by Carl Eugen Hoyos, 12 years ago

MPlayer shows still no subtitles if I change AV_CODEC_ID_DVB_TELETEXT to AV_CODEC_ID_EIA_608 in ffmpeg/libavformat/wtvdec.c.

diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 2999382..f879d21 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -695,7 +695,7 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
         if (ff_guidcmp(formattype, ff_format_none))
             av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype));
         avio_skip(pb, size);
-        st->codec->codec_id   = AV_CODEC_ID_DVB_TELETEXT;
+        st->codec->codec_id   = AV_CODEC_ID_EIA_608;
         return st;
     } else if (!ff_guidcmp(mediatype, mediatype_mpeg2_sections) &&
                !ff_guidcmp(subtype, mediasubtype_mpeg2_sections)) {

comment:16 by reimar, 12 years ago

Not surprising, since I can't find anything that looks like EIA-608 in the file.
They might be using yet another format, but since the string "GA94" exists in the file I'd expect that it rather uses EIA-708.
However I haven't check which stream that EIA-708 data is part of, it really should be embedded in the video stream which would then still leave open what that subtitle stream actually contains.

comment:17 by Carl Eugen Hoyos, 12 years ago

The subtitles in the third stream are text-based as can be seen with:
$ ffmpeg -i NCIS.wtv -vn -an -scodec copy -f rawvideo out
$ hexdump -C out

Shouldn't MPlayer show the "GA94" subtitles in the video stream?
(mplayer NCIS.wtv -dumpvideo && grep GA94 stream.dump)

comment:18 by reimar, 12 years ago

EIA-608 does not give plain-text, in particular since the highest bit is a parity bit, plus every third "character" is a control byte.
And while I have a patch for EIA-708 in MPlayer it is not committed since it cannot work. The data needs to be reordered in the same way that the frames are during decoding, and that is a mess to implement.

comment:19 by reimar, 12 years ago

A far larger sample size will be needed to reverse-engineer this format properly, but for reference below hack to MPlayer makes it mostly display correctly (using -sid 0 -subcc 1).
However how the whole rollup, rollon, number of lines etc. pp. is encoded in the format is still quite unclear to me.

Index: sub/sub_cc.c
===================================================================
--- sub/sub_cc.c	(revision 35108)
+++ sub/sub_cc.c	(working copy)
@@ -376,11 +381,26 @@
 
 void subcc_process_data(const uint8_t *inputdata, unsigned int len)
 {
+	int newline = 0;
 	int mov_mode = len >= 10 &&
 	               memcmp(inputdata, mov_cc_signature_1, sizeof(mov_cc_signature_1)) == 0;
 	if(!subcc_enabled) return;
 	if(!initialized) subcc_init();
 
+	cc_mode = CC_ROLLUP;
+	if (len < 2) return;
+	newline = (inputdata[1] & 0xf0) == 0x30;
+	inputdata += 2;
+	len -= 2;
+	channel = 0;
+	while (len >= 2 && (inputdata[0] & 0x60)) {
+		cc_decode_EIA608(inputdata[0] | (inputdata[1] << 8));
+		if (!(inputdata[1] & 0x60)) break;
+		inputdata += 2;
+		len -= 2;
+	}
+	if (newline) append_char('\n');
+	return;
 	if (mov_mode) {
 		mov_subcc_decode(inputdata, len);
 		return;

comment:20 by Carl Eugen Hoyos, 12 years ago

(Committing the patches will lead to more samples imo.)

A longer sample that I believe produces not entirely correctly subtitles with mplayer -sid 1 -subcc 1 is at samples/ffmpeg-bugs/trac/ticket1065/Test1.wtv (It btw does not show subtitles with mplayer -sid 0 that ffplay shows.)

comment:21 by pross, 12 years ago

Hi reimar & cehoyos. You are right, I got 608 and 708 confused, nonetheless, both CEA-708 and EIA-608 subtitles are present in the file.

  • NCIS.wtv, Stream 3. Subtitles are stored using CEA-708. By no coindicence, the stream type guid is MEDIASUBTYPE_DTVCCDATA. Most packets in the stream correspond to a CEA-708 DTVCCDATA packet (described in the CEA-708 standard). There are also many 2-byte packets, which seem out of place; perhaps they are frame counters or checksums added by Microsoft.
  • NCIS.wtv, Stream 1. If you copy this stream into TS format, the CCextractor program will extract subtitles from it. The subtitles within Stream 1 are in EIA-608 format.

I have uploaded two more .wtv samples to /incoming/wtv_dtvccdata.

Last edited 12 years ago by pross (previous) (diff)

comment:22 by pross, 12 years ago

@cehoyos
samples/ffmpeg-bugs/trac/ticket1065/Test1.wtv contains mediatype_mstvcaption packets

Currently FFmpeg interprets both 'mediatype_mstvcaption' and 'mediasubtype_dtvccdata' as AVCODEC_ID_DVB_TELETEXT (see extract from wtvdec.c below). That now looks to be wrong.

mediasubtype_dtvccdata is a variant of CEA-708.

mediatype_mstvcaption is something different again. Another proprietary format, perhaps.

---wtvdec.c

} else if (!ff_guidcmp(mediatype, mediatype_mstvcaption) && !ff_guidcmp(subtype, mediasubtype_dtvccdata)) {

st = new_stream(s, st, sid, AVMEDIA_TYPE_SUBTITLE);
if (!st)

return NULL;

if (ff_guidcmp(formattype, ff_format_none))

av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype));

avio_skip(pb, size);
st->codec->codec_id = AV_CODEC_ID_DVB_TELETEXT;
return st;

---wtvdec.c

comment:23 by reimar, 12 years ago

Concerning Test1.wtv: a fix for the DVB subs is sent.
The other subtitle stream is indeed teletext, in 3/4ths processed form, as this hack shows:

Index: mpcommon.c
===================================================================
--- mpcommon.c	(revision 35108)
+++ mpcommon.c	(working copy)
@@ -276,6 +276,15 @@
             if (type == 'd') {
                 if (d_dvdsub->demuxer->teletext) {
                     uint8_t *p = packet;
+                            teletext_control(d_dvdsub->demuxer->teletext,
+                                TV_VBI_CONTROL_RESET, NULL);
+while (len >= 42) {
+                            teletext_control(d_dvdsub->demuxer->teletext,
+                                TV_VBI_CONTROL_DECODE_DVB, p);
+                        p   += 42;
+                        len -= 42;
+}
+return;
                     p++;
                     len--;
                     while (len >= 46) {Index: libmpcodecs/dec_teletext.c
===================================================================
--- libmpcodecs/dec_teletext.c	(revision 35108)
+++ libmpcodecs/dec_teletext.c	(working copy)
@@ -1546,11 +1546,12 @@
     uint8_t data[42];
 
     mp_msg(MSGT_TELETEXT,MSGL_DBG3, "vbi: vbi_decode_dvb\n");
+memcpy(data, buf, 42);
 
     /* Reverse bit order, skipping the first two bytes (field parity, line
        offset and framing code). */
-    for (i = 0; i < sizeof(data); i++)
-        data[i] = av_reverse[buf[2 + i]];
+//    for (i = 0; i < sizeof(data); i++)
+//        data[i] = av_reverse[buf[2 + i]];
 
     vbi_decode_line(priv, data);
     if (priv->cache_reset)
@@ -1683,6 +1684,8 @@
     priv_vbi_t* priv=(priv_vbi_t*)p;
     tt_page* pgc;
 
+if (cmd == TV_VBI_CONTROL_RESET)
+        clear_cache(priv);
     if (!priv && cmd!=TV_VBI_CONTROL_START)
         return VBI_CONTROL_FALSE;
     if (!arg && cmd!=TV_VBI_CONTROL_STOP && cmd!=TV_VBI_CONTROL_MARK_UNCHANGED)

However all those formats are just slightly off from the standard format that I just don't know what to do about it.
Should the demuxer convert them? Should it be a different codec? Should there be some auto-detection?
Some extradata to mark them?

comment:24 by reimar, 12 years ago

The subtitles within Stream 1 are in EIA-608 format.
mediasubtype_dtvccdata is a variant of CEA-708.

Could you please be more specific and/or quote some specification?
For all variants I know, the CC data consists of 3 byte packages with one (kind of) control and two data.
Those subtitle streams however have long sequences of only data bytes (text and probably EIA-708 control codes).
And those first two mystery bytes are at least a concern.

comment:25 by reimar, 12 years ago

So it looks like:
1) the 2-byte packets are the EIA-608 compatibility packets
2) the longer packets always start with a packet that has been a DTVCC_PACKET_START and then continues with all that have been DTVCC_PACKET_DATA after that
In both cases, the data is unchanged compared to what is in the MPEG file except that any and all header and filler and control data (like packet_start vs. packet_data markers) has been removed

comment:26 by pross, 12 years ago

@reimar.
This standard: http://apps.fcc.gov/ecfs/comment/view;jsessionid=Hy6KP9KJLPgvLv1LqJ5QvkJDG8jLXyH0yvztjM7nJ0G5yPXpmCZW!-1221852939!-1969853125?id=5003806575.

As to what do to, I dont know either. The demuxer is probably best placed to deal with it, since it just involves inserting additional control codes.

comment:27 by ramitb, 10 years ago

Sorry to crash the party, but was there any resolution to this?

comment:28 by Carl Eugen Hoyos, 10 years ago

Component: undeterminedavformat
Keywords: wtv added
Priority: normalwish
Status: newopen
Summary: FFMPEG fails to create a SRT file when extracting SubtitlesSupport eia_608 in wtv
Type: defectenhancement

comment:29 by Carl Eugen Hoyos, 9 years ago

Cc: Anshul added

Anshul, could you look at this sample?
http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket1482/
Timestamps for the Closed Captions are wrong, the Closed Captions play too slow: Four minutes instead of 20 seconds.

comment:30 by compn, 9 years ago

anybody test how these samples are handled with the new asf demuxer?

Note: See TracTickets for help on using tickets.