Skip to content

FFprobe closed_captions JSON tag not set #94

Closed

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/[email protected]/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/[email protected]/msg133559.html

Activity

  1. added
    bug
    external
    on Mar 17, 2022
  2. added a commit that references this issue on Mar 23, 2022
  3. ptr727 commented on Apr 17, 2025

    @ptr727
    OwnerAuthor

    Abandoning, see #497.

  4. added
    wontfix
    on Apr 17, 2025
  5. bbgdzxng1 commented on Jan 9, 2026

    @bbgdzxng1

    @ptr727 did you ever solve to your satisfaction?

    I saw your cross referenced requests on various forums (reddit & ccextractor) and I think you may just have been missing the -analyze_frames option.

    -analyze_frames

    Analyze frames and/or their side data up to the provided read interval, providing additional information that may be useful at a stream level. Must be paired with the -show_streams option or it will have no effect.
    
    Currently, the additional fields provided by this option when enabled are the closed_captions and film_grain fields. 
    
    $ ffprobe -hide_banner -loglevel 'quiet' -show_entries 'stream=closed_captions' -analyze_frames -print_format 'json' "http://streams.videolan.org/streams/ts/CC/NewsStream-608-ac3.ts" | jq -r '.streams[0].closed_captions'
    1
    
    $ ffprobe -hide_banner -loglevel 'quiet' -show_entries 'stream=closed_captions' -analyze_frames -print_format 'json' "http://streams.videolan.org/streams/ts/CC/NewsStream-608-ac3.ts"
    
    {
        "programs": [
            {
                "streams": [
                    {
                        "closed_captions": 1,
                        "side_data_list": [
                            {
    
                            }
                        ]
                    },
                    {
    
                    }
                ]
            }
        ],
        "stream_groups": [
    
        ],
        "streams": [
            {
                "closed_captions": 1,
                "side_data_list": [
                    {
    
                    }
                ]
            },
            {
    
            }
        ]
    }

    Hope this helps you without needing a code change in FFmpeg.

  6. ptr727 commented on Jan 10, 2026

    @ptr727
    OwnerAuthor

    did you ever solve to your satisfaction?

    There is a comment about this in the readme, I have not retested recently, but when I tested this it was not yet released.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugexternalwontfix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions