#11470 closed defect (fixed)

get_eia608_packet misparses well formed files and corrupts Close Captions since 2020

Reported by: Pavel Koshevoy Owned by:
Priority: critical Component: avformat
Version: git-master Keywords: lavf mov captions
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

$ ./ffmpeg -i 'Test for Quicktime 608 CC file.mov' -map 0 -c copy -y /tmp/remuxed.mov
ffmpeg version N-118471-ga50d36b5fd Copyright (c) 2000-2025 the FFmpeg developers
  built with gcc 7 (SUSE Linux)
  configuration: --prefix=/Developer/x86_64 --prefix=/Developer/x86_64 --enable-runtime-cpudetect --enable-libzimg --enable-libx264 --enable-libass --enable-libmodplug --enable-libxml2 --enable-libvmaf --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-gnutls --enable-libfreetype --enable-pic --disable-static --enable-shared --enable-rpath --enable-ffnvcodec --enable-debug --disable-stripping --disable-optimizations --disable-mmx
  libavutil      59. 56.100 / 59. 56.100
  libavcodec     61. 33.102 / 61. 33.102
  libavformat    61.  9.107 / 61.  9.107
  libavdevice    61.  4.100 / 61.  4.100
  libavfilter    10.  9.100 / 10.  9.100
  libswscale      8. 13.100 /  8. 13.100
  libswresample   5.  4.100 /  5.  4.100
  libpostproc    58.  4.100 / 58.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Test for Quicktime 608 CC file.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    creation_time   : 2010-11-04T17:28:46.000000Z
  Duration: 00:00:28.40, start: 0.000000, bitrate: 1603 kb/s
  Stream #0:0[0x1](eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709, progressive), 640x360, 1485 kb/s, 29.97 fps, 29.97 tbr, 2997 tbn (default)
    Metadata:
      creation_time   : 2010-11-04T17:28:46.000000Z
      handler_name    : Apple Video Media Handler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 109 kb/s (default)
    Metadata:
      creation_time   : 2010-11-04T17:28:46.000000Z
      handler_name    : Apple Sound Media Handler
      vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](eng): Subtitle: eia_608 (cc_dec) (c608 / 0x38303663), 640x360, 4 kb/s (default)
    Metadata:
      creation_time   : 2010-11-04T17:28:46.000000Z
      handler_name    : Apple Closed Caption Media Handler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
Output #0, mov, to '/tmp/remuxed.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    encoder         : Lavf61.9.107
  Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709, progressive), 640x360, q=2-31, 1485 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn (default)
    Metadata:
      creation_time   : 2010-11-04T17:28:46.000000Z
      handler_name    : Apple Video Media Handler
      vendor_id       : [0][0][0][0]
  Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 109 kb/s (default)
    Metadata:
      creation_time   : 2010-11-04T17:28:46.000000Z
      handler_name    : Apple Sound Media Handler
      vendor_id       : [0][0][0][0]
  Stream #0:2(eng): Subtitle: eia_608 (c608 / 0x38303663), 640x360, 4 kb/s (default)
    Metadata:
      creation_time   : 2010-11-04T17:28:46.000000Z
      handler_name    : Apple Closed Caption Media Handler
Press [q] to stop, [?] for help
[out#0/mov @ 0x17fb8420] video:5147KiB audio:379KiB subtitle:15KiB other streams:0KiB global headers:0KiB muxing overhead: 0.546079%
frame=  851 fps=0.0 q=-1.0 Lsize=    5571KiB time=00:00:27.66 bitrate=1649.8kbits/s speed= 920x

The problem was introduced in commit f91906973c62459f31beb5683a8e2105758af0bb in June 2020
The problem is reproducible with 'Test for Quicktime 608 CC file.mov' from https://samples.ffmpeg.org/MPEG2/subcc/

A fix was provided in June 2023:
https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2023-June/310456.html

Two alternative fixes were provided in February 2025:
https://ffmpeg.org//pipermail/ffmpeg-devel/2025-February/339780.html
https://ffmpeg.org//pipermail/ffmpeg-devel/2025-February/339790.html

Attached are screenshots demonstrating the problem with the closed captions corruption caused in get_eia608_packet, and what the captions are supposed to look like when get_eia608_packet is fixed.

Attachments (2)

20250215_100345_ffmpeg_c608_bug.png (332.9 KB ) - added by Pavel Koshevoy 15 months ago.
a screenshot of a player demonstrating the corrupted closed captions prior to the fix
20250215_100345_ffmpeg_c608_fixed.png (335.2 KB ) - added by Pavel Koshevoy 15 months ago.
a screenshot of a player demonstrating the corrupted closed captions after the fix

Download all attachments as: .zip

Change History (3)

by Pavel Koshevoy, 15 months ago

a screenshot of a player demonstrating the corrupted closed captions prior to the fix

by Pavel Koshevoy, 15 months ago

a screenshot of a player demonstrating the corrupted closed captions after the fix

comment:1 by Pavel Koshevoy, 15 months ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.