So I played with this some more and came up with this patch. It fixes the issue for me.
Description: Fix text/cc subtitles with Matroska container When encoding a file which includes a Closed Captions subtitles track (CEA-608 or similar), Handbrake on Debian fails to transcode to a Matroska container. This is due to upstream Handbrake using libav, while Debian uses ffmpeg. The former uses AV_CODEC_ID_SSA for Matroska, while the latter uses AV_CODEC_ID_ASS. ffmpeg also appears to not require the same additional information as libav. This patch fixes both of these issues. Author: Mike Ruprecht <cma...@gmail.com> Bug-Debian: https://bugs.debian.org/805526 Forwarded: not-needed Last-Update: 2016-05-07
Index: handbrake/libhb/muxavformat.c =================================================================== --- handbrake-0.10.2+ds1.orig/libhb/muxavformat.c +++ handbrake-0.10.2+ds1/libhb/muxavformat.c @@ -715,7 +715,7 @@ static int avformatInit( hb_mux_object_t } else { - track->st->codec->codec_id = AV_CODEC_ID_SSA; + track->st->codec->codec_id = AV_CODEC_ID_ASS; need_fonts = 1; if (subtitle->extradata_size) @@ -1183,40 +1183,12 @@ static int avformatMux(hb_mux_object_t * pkt.size = buffersize + stylesize + 2; } } - if (track->st->codec->codec_id == AV_CODEC_ID_SSA && + if (track->st->codec->codec_id == AV_CODEC_ID_ASS && job->mux == HB_MUX_AV_MKV) { - // avformat requires the this additional information - // which it parses and then strips away - int start_hh, start_mm, start_ss, start_ms; - int stop_hh, stop_mm, stop_ss, stop_ms, layer; - char *ssa; - - start_hh = buf->s.start / (90000 * 60 * 60); - start_mm = (buf->s.start / (90000 * 60)) % 60; - start_ss = (buf->s.start / 90000) % 60; - start_ms = (buf->s.start / 900) % 100; - stop_hh = buf->s.stop / (90000 * 60 * 60); - stop_mm = (buf->s.stop / (90000 * 60)) % 60; - stop_ss = (buf->s.stop / 90000) % 60; - stop_ms = (buf->s.stop / 900) % 100; - - // Skip the read-order field - ssa = strchr((char*)buf->data, ','); - if (ssa != NULL) - ssa++; - // Skip the layer field - layer = strtol(ssa, NULL, 10); - ssa = strchr(ssa, ','); - if (ssa != NULL) - ssa++; - sprintf((char*)sub_out, - "Dialogue: %d,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s", - layer, - start_hh, start_mm, start_ss, start_ms, - stop_hh, stop_mm, stop_ss, stop_ms, ssa); - pkt.data = sub_out; - pkt.size = strlen((char*)sub_out) + 1; + // For some reason the pkt.size is 5 bytes too large + // For safety, just strlen pkt.size + pkt.size = strlen((char*)pkt.data) + 1; } pkt.convergence_duration = pkt.duration;