Skip to content

FFprobe closed_captions JSON tag not set #94

Description

@ptr727

ffprobe does not identify closed captions when using JSON output mode.

Unformatted output:

./ffprobe.exe D:\Temp\CC.mkv
  Stream #0:0(eng): Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080, Closed Captions, SAR 1:1 DAR 16:9, 29.97 fps, 29.97 tbr, 1k tbn (default)

Note the Closed Captions attribute.

JSON output:

./ffprobe.exe -loglevel quiet -print_format json -show_streams -show_format D:\Temp\CC.mkv
{
    "streams": [
        {
            "index": 0,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
...
            "closed_captions": 0,

Note the closed_captions attribute is 0, expect it to be 1.

Asked for help or alternatives here:
https://www.reddit.com/r/ffmpeg/comments/tcnhto/how_to_detect_closed_captions_in_video_stream/
https://forum.videohelp.com/threads/405123-Detect-embedded-closed-captions-in-video-stream-using-ffprobe-json-output

Discovered an abandoned patch for exactly this issue, seems there was some internal disagreement:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/MN2PR04MB59815313285AA685E37D09AEBAB09@MN2PR04MB5981.namprd04.prod.outlook.com/
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=&submitter=&state=*&q=closed_captions&archive=both&delegate=
https://www.mail-archive.com/ffmpeg-devel@ffmpeg.org/msg126211.html

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 90e895bbf9..f5c6335a13 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2655,9 +2655,9 @@  static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id
         if (dec_ctx) {
             print_int("coded_width",  dec_ctx->coded_width);
             print_int("coded_height", dec_ctx->coded_height);
-            print_int("closed_captions", !!(dec_ctx->properties & FF_CODEC_PROPERTY_CLOSED_CAPTIONS));
-            print_int("film_grain", !!(dec_ctx->properties & FF_CODEC_PROPERTY_FILM_GRAIN));
         }
+        print_int("closed_captions", !!(par->properties & FF_CODEC_PROPERTY_CLOSED_CAPTIONS));
+        print_int("film_grain", !!(par->properties & FF_CODEC_PROPERTY_FILM_GRAIN));
         print_int("has_b_frames", par->video_delay);
         sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
         if (sar.num) {

Source related to closed_captions setting:
https://github.com/FFmpeg/FFmpeg/blob/b8e58f0858116ac102fc116ce1bdf6727df1eb0c/libavcodec/avcodec.c#L650
https://github.com/FFmpeg/FFmpeg/blob/316e0ff752c782439843cc63d0eb8b9c998e47de/fftools/ffprobe.c#L2902

My request to the ffmpeg-devel list to reconsider:
https://www.mail-archive.com/ffmpeg-devel@ffmpeg.org/msg133559.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexternalExternal dependencywontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions