#5283(avcodec:new): Add bitstream filter to remove Closed Captions from h264
#5283: Add bitstream filter to remove Closed Captions from h264 ---------------------------------------+--------------------------------- Reporter: cehoyos | Owner: Type: enhancement | Status: new Priority: wish | Component: avcodec Version: git-master | Keywords: h264 cc Blocked By: | Blocking: Reproduced by developer: 0 | Analyzed by developer: 0 ---------------------------------------+--------------------------------- http://thread.gmane.org/gmane.comp.video.ffmpeg.user/61438/focus=61440 The sample from ticket #2885 contains Closed Captions, FFmpeg does not allow to remove them without reencoding. {{{ $ ffmpeg -i transformers.ts -vcodec copy out.h264 ffmpeg version N-78869-gdd2ea5c Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.7 (SUSE Linux) configuration: --enable-gpl libavutil 55. 19.100 / 55. 19.100 libavcodec 57. 27.101 / 57. 27.101 libavformat 57. 27.102 / 57. 27.102 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 38.100 / 6. 38.100 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 Input #0, mpegts, from 'transformers.ts': Duration: 00:01:59.29, start: 0.578456, bitrate: 9015 kb/s Program 1 Stream #0:0[0x1e1]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc Stream #0:1[0x1e2]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), fltp, 384 kb/s Output #0, h264, to 'out.h264': Metadata: encoder : Lavf57.27.102 Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuvj420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 29.97 fps, 29.97 tbr, 29.97 tbn, 29.97 tbc Stream mapping: Stream #0:0 -> #0:0 (copy) Press [q] to stop, [?] for help frame= 3575 fps=0.0 q=-1.0 Lsize= 118242kB time=00:01:59.25 bitrate=8122.6kbits/s speed= 580x video:118291kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown }}} {{{ $ ffmpeg -i out.h264 ffmpeg version N-78869-gdd2ea5c Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.7 (SUSE Linux) configuration: --enable-gpl libavutil 55. 19.100 / 55. 19.100 libavcodec 57. 27.101 / 57. 27.101 libavformat 57. 27.102 / 57. 27.102 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 38.100 / 6. 38.100 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 [h264 @ 0x3a8c280] Stream #0: not enough frames to estimate rate; consider increasing probesize Input #0, h264, from 'out.h264': Duration: N/A, bitrate: N/A Stream #0:0: Video: h264 (High), yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 1200k tbn, 59.94 tbc At least one output file must be specified }}} -- Ticket URL: <https://trac.ffmpeg.org/ticket/5283> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5283: Add bitstream filter to remove Closed Captions from h264 -------------------------------------+----------------------------------- Reporter: cehoyos | Owner: Type: enhancement | Status: new Priority: wish | Component: avcodec Version: git-master | Resolution: Keywords: h264 cc | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+----------------------------------- Comment (by feno): I'm very surprised to see that this feature does not exist in ffmpeg. I was almost sure I could do that with ffmpeg so I was looking to docs to see how to do that. Then found out it's actually not possible. I found link to this issue in some forums where other people were asking how to do this in ffmpeg. So it's something that people actually need and ask around. No response to this issue for years since it was reported. So looks like no hope to see it implemented :( I really need this function so badly, would appreciate a lot if any dev interested in implementing it :\ -- Ticket URL: <https://trac.ffmpeg.org/ticket/5283#comment:1> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5283: Add bitstream filter to remove Closed Captions from h264 -------------------------------------+------------------------------------- Reporter: Carl Eugen | Owner: (none) Hoyos | Type: enhancement | Status: closed Priority: wish | Component: avcodec Version: git-master | Resolution: fixed Keywords: h264 cc | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Changes (by Balling): * status: new => closed * resolution: => fixed Comment: It is actually possible, just like with primaries/trc/matrix OF THE SOURCE that is in prefix type of SEI. FFmpeg has a bitstream filter called filter_units, which allows you to pass or reject NAL units by type. So we can use this to remove all the SEI NAL units, which strips out the captions. Type 6 is for closed caption. ffmpeg -i input.mkv -codec copy -bsf:v "filter_units=remove_types=6" output.mkv See: https://stackoverflow.com/questions/48177694/removing-eia-608-closed- captions-from-h-264-without-reencode Now, that is not perfect, since there are many types of SEI. You can further use the type of SEI (like 39 for prefix SEI) I suppose the same can be done for HEVC. -- Ticket URL: <https://trac.ffmpeg.org/ticket/5283#comment:2> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5283: Add bitstream filter to remove Closed Captions from h264 -------------------------------------+------------------------------------- Reporter: Carl Eugen | Owner: (none) Hoyos | Type: enhancement | Status: reopened Priority: wish | Component: avcodec Version: git-master | Resolution: Keywords: h264 cc | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Changes (by Carl Eugen Hoyos): * status: closed => reopened * resolution: fixed => -- Ticket URL: <https://trac.ffmpeg.org/ticket/5283#comment:3> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5283: Add bitstream filter to remove Closed Captions from h264 -------------------------------------+------------------------------------- Reporter: Carl Eugen | Owner: (none) Hoyos | Type: enhancement | Status: reopened Priority: wish | Component: avcodec Version: git-master | Resolution: Keywords: h264 cc | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Comment (by Balling): Replying to [comment:3 Carl Eugen Hoyos]: So you seriously want the filter that will remove all GA94 T.35 packets? -- Ticket URL: <https://trac.ffmpeg.org/ticket/5283#comment:4> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5283: Add bitstream filter to remove Closed Captions from h264 -------------------------------------+------------------------------------- Reporter: Carl Eugen | Owner: (none) Hoyos | Type: enhancement | Status: reopened Priority: wish | Component: avcodec Version: git-master | Resolution: Keywords: h264 cc | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Comment (by Nicolas George): The ticket asks for a way to remove closed-captions, and nothing more. It is a perfectly valid request; there may be sensitive data in the closed captions, for example. This ticket should not be closed until there is a way to remove exactly closed-captions. -- Ticket URL: <https://trac.ffmpeg.org/ticket/5283#comment:5> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
The ticket asks for a way to remove closed-captions, and nothing more. It is a perfectly valid request; there may be sensitive data in the closed
#5283: Add bitstream filter to remove Closed Captions from h264 -------------------------------------+------------------------------------- Reporter: Carl Eugen | Owner: (none) Hoyos | Type: enhancement | Status: reopened Priority: wish | Component: avcodec Version: git-master | Resolution: Keywords: h264 cc | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Comment (by Balling): Replying to [comment:5 Nicolas George]: captions, for example.
This ticket should not be closed until there is a way to remove exactly
closed-captions. As I said there is a way to do it by removing SEI. I suppose ffmpeg should be able to remove EVEN specifically GA94 T.35 SEI, but I do not know the command. -- Ticket URL: <https://trac.ffmpeg.org/ticket/5283#comment:6> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5283: Add bitstream filter to remove Closed Captions from h264 -------------------------------------+------------------------------------- Reporter: Carl Eugen | Owner: (none) Hoyos | Type: enhancement | Status: reopened Priority: wish | Component: avcodec Version: git-master | Resolution: Keywords: h264 cc | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Comment (by Balling): And also may be interesting to implement this: https://superuser.com/questions/1356674/how-to-change-offset-of-eia-608 -subtitles-in-an-mp4 -- Ticket URL: <https://trac.ffmpeg.org/ticket/5283#comment:7> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5283: Add bitstream filter to remove Closed Captions from h264 -------------------------------------+------------------------------------- Reporter: Carl Eugen | Owner: (none) Hoyos | Type: enhancement | Status: reopened Priority: wish | Component: avcodec Version: git-master | Resolution: Keywords: h264 cc | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Comment (by varenc): I believe this is possible right now using the `filter_units` bitstream filter. Though this isn't documented or generally well known, and an easier to use method for this common request would be welcome. Here's how: {{{ ffmpeg -i input.mkv -codec copy -bsf:v "filter_units=remove_types=6" out.mkv }}} Discovered this online here: https://stackoverflow.com/questions/48177694 /removing-eia-608-closed-captions-from-h-264-without-reencode which also explains why it works. (SEI NAL units have type=6) -- Ticket URL: <https://trac.ffmpeg.org/ticket/5283#comment:8> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5283: Add bitstream filter to remove Closed Captions from h264 -------------------------------------+------------------------------------- Reporter: Carl Eugen | Owner: (none) Hoyos | Type: enhancement | Status: reopened Priority: wish | Component: avcodec Version: git-master | Resolution: Keywords: h264 cc | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Comment (by Balling): You are wrong, varenc. HDR10+ metadata is also stored in T.35 AFAIK, so it will remove that too. -- Ticket URL: <https://trac.ffmpeg.org/ticket/5283#comment:9> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5283: Add bitstream filter to remove Closed Captions from h264 -------------------------------------+------------------------------------- Reporter: Carl Eugen | Owner: (none) Hoyos | Type: enhancement | Status: reopened Priority: wish | Component: avcodec Version: git-master | Resolution: Keywords: h264 cc | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Comment (by ptr727): Since around Jan 2025 FFprobe no longer reports the presence of "Closed Captions", see https://code.ffmpeg.org/FFmpeg/FFmpeg/commit/19c95ecbff84eebca254d200c941ce0.... So also requesting a way to detect the presence of CC's using FFprobe, and to remove CC's from a video stream for all (MPEG2, H264, H265, etc.) supported types. -- Ticket URL: <https://trac.ffmpeg.org/ticket/5283#comment:10> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
participants (1)
-
FFmpeg