Skip to content

[FIX] Flush the last 608 caption for g608 and simple-xml output - #2459

Open
SajalDevX wants to merge 1 commit into
CCExtractor:masterfrom
SajalDevX:fix/g608-simplexml-flush
Open

SajalDevX wants to merge 1 commit into
CCExtractor:masterfrom
SajalDevX:fix/g608-simplexml-flush

Conversation

@SajalDevX

@SajalDevX SajalDevX commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

In raising this pull request, I confirm the following (please check boxes):

Reason for this PR:

  • This PR adds new functionality.
  • This PR fixes a bug that I have personally experienced or that a real user has reported and for which a sample exists.
  • This PR is porting code from C to Rust.

Sanity check:

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • If the PR adds new functionality, I've added it to the changelog. If it's just a bug fix, I have NOT added it to the changelog.
  • I am NOT adding new C code unless it's to fix an existing, reproducible bug.

Repro instructions:

Sample (attached, last_caption_on_screen.scc): two pop-on captions, "First" at 00:00:01:00 and "Second" at 00:00:03:00. "Second" is never erased before the file ends (the last line at 00:00:06:00 is only padding).

Scenarist_SCC V1.0

00:00:01:00	9420 9420 94ae 94ae 9470 9470 46e9 f273 f480 942f 942f

00:00:03:00	9420 9420 94ae 94ae 9470 9470 d3e5 e3ef 6e64 942f 942f

00:00:06:00	8080 8080
ccextractor last_caption_on_screen.scc -out=srt --stdout
ccextractor last_caption_on_screen.scc -out=g608 --stdout
ccextractor last_caption_on_screen.scc -out=simple-xml --stdout

On master, srt (and webvtt, sami, smptett, ssa, txt, ...) has both captions, "Second" ending at 00:00:06,699. g608 and simple-xml only have "First":

<?xml version="1.0" encoding="utf-8"?>
<captions>
<caption>First</caption>
</captions>

It is not specific to SCC input. Same result with the .bin written by -out=bin from that file, and with a MOV that has the captions in a c608 track (ffmpeg -f lavfi -i color=black:s=160x120:r=30000/1001:d=8 -i last_caption_on_screen.scc -map 0:v -map 1:s -c:v mpeg4 -c:s copy sample.mov).


flush_cc_decode() only calls flush_608_context() for a fixed list of output formats. G608 and SIMPLE_XML use process608 like the others, but they are not in that list, so whatever is still on screen at the end of the input is dropped for those two formats. This adds them to both lists (field 1 and field 2).

Testing: built with linux/build and ran the old and new binary on the sample above (SCC, BIN and MOV versions) with srt, webvtt, sami, ssa, ttxt, txt, smptett, scc, ccd, g608, simple-xml, mcc and bin output, plus two SCC files whose last caption is erased before EOF and a teletext TS. The only differences are in g608 and simple-xml for the three inputs where a caption is still on screen at the end, where "Second" is now written (g608 gets the same 00:00:03,001 --> 00:00:06,699 as srt). Nothing changes for files that end with an empty screen, so no caption is written twice.

flush_cc_decode() only flushes the 608 decoders for a fixed list of
output formats, and -out=g608 and -out=simple-xml are not in it, even
though both go through process608 and write_cc_buffer. A caption that
is still on screen when the input ends was never written in those two
formats, while srt, webvtt, sami etc. write it with the end time at the
end of the stream.

Add both formats to the two flush lists.
@ccextractor-bot

Copy link
Copy Markdown
Collaborator
CCExtractor CI platform finished running the test files on linux. 172/238 tests matched the approved output:
Report Name Tests Passed
Broken 9/13
CEA-708 2/14
DVB 0/7
DVD 3/3
DVR-MS 2/2
General 26/28
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 69/86
Teletext 0/21
WTV 12/13
XDS 32/34

66 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.


Compared with the tip of master — test 9984, commit 24d1e0a:

  • 0 pass there and fail here
  • 0 fail there and pass here
  • 0 fail on both, with different output
  • 66 fail on both, byte for byte the same

Compared with the commit this branch was cut from: the same run as the tip of master (test 9984), so the comparison above already covers it.


No test changes behaviour relative to the tip of master: every failure above fails there too, byte for byte. The approved output for those tests is out of date, which is a baseline to review rather than a regression in this branch.

@ccextractor-bot

Copy link
Copy Markdown
Collaborator
CCExtractor CI platform finished running the test files on windows. 172/238 tests matched the approved output:
Report Name Tests Passed
Broken 9/13
CEA-708 2/14
DVB 0/7
DVD 3/3
DVR-MS 2/2
General 26/28
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 69/86
Teletext 0/21
WTV 12/13
XDS 32/34

66 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.


Compared with the tip of master — test 9985, commit 24d1e0a:

  • 0 pass there and fail here
  • 0 fail there and pass here
  • 0 fail on both, with different output
  • 66 fail on both, byte for byte the same

Compared with the commit this branch was cut from: the same run as the tip of master (test 9985), so the comparison above already covers it.


No test changes behaviour relative to the tip of master: every failure above fails there too, byte for byte. The approved output for those tests is out of date, which is a baseline to review rather than a regression in this branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants