* [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files @ 2025-05-21 13:34 Timothée 2025-05-22 11:59 ` Ronald S. Bultje 2025-06-06 19:32 ` Tomas Härdin 0 siblings, 2 replies; 13+ messages in thread From: Timothée @ 2025-05-21 13:34 UTC (permalink / raw) To: ffmpeg-devel Hello, I am interested in expanding ffmpeg's capabilities to extract low-level data from video codecs. Specifically, I'd like to implement functionality that would allow exporting frame data, macroblock information, quantization tables, and similar codec-specific elements to binary files for further analysis. After searching through the documentation and existing features, I haven't found similar functionality, though I may have missed something. Has this been implemented before, or are there related features I should examine? I'd appreciate your feedback on whether this feature would be considered valuable for the project and if it aligns with ffmpeg's development goals. If there's interest, I can provide a more detailed technical proposal. I'm new to both ffmpeg development and open source contributions in general, so I welcome any guidance or information that might help me contribute effectively. Thank you for your time and consideration. Timothée _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files 2025-05-21 13:34 [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files Timothée @ 2025-05-22 11:59 ` Ronald S. Bultje 2025-05-22 12:32 ` Ramiro Polla 2025-05-23 0:45 ` Michael Niedermayer 2025-06-06 19:32 ` Tomas Härdin 1 sibling, 2 replies; 13+ messages in thread From: Ronald S. Bultje @ 2025-05-22 11:59 UTC (permalink / raw) To: FFmpeg development discussions and patches Hi, On Wed, May 21, 2025 at 9:34 AM Timothée < timothee.informatique@regaud-chapuy.fr> wrote: > Hello, > > I am interested in expanding ffmpeg's capabilities to extract > low-level data from video codecs. Specifically, I'd like to implement > functionality that would allow exporting frame data, macroblock > information, quantization tables, and similar codec-specific elements > to binary files for further analysis. > > After searching through the documentation and existing features, I > haven't found similar functionality, though I may have missed > something. Has this been implemented before, or are there related > features I should examine? Some older codecs implement minor variants for this, e.g. grep for AV_FRAME_DATA_MOTION_VECTORS, which attaches a frame's motion vectors to the picture data. I believe there's an example app and possibly a filter to overlay MVs on top of the video frame based on this concept. You could extend this to cover other (macro)block info. There used to be a variant of this for quant-tables also but I can't find it, maybe it was removed. Placing the side-data in binary files is probably not really something that libavcodec would do, but rather something that would exist at the application level. Ronald _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files 2025-05-22 11:59 ` Ronald S. Bultje @ 2025-05-22 12:32 ` Ramiro Polla 2025-05-22 17:02 ` Timothée 2025-05-22 20:27 ` Ronald S. Bultje 2025-05-23 0:45 ` Michael Niedermayer 1 sibling, 2 replies; 13+ messages in thread From: Ramiro Polla @ 2025-05-22 12:32 UTC (permalink / raw) To: FFmpeg development discussions and patches Hi, On Thu, May 22, 2025 at 1:59 PM Ronald S. Bultje <rsbultje@gmail.com> wrote: > On Wed, May 21, 2025 at 9:34 AM Timothée < > timothee.informatique@regaud-chapuy.fr> wrote: > > I am interested in expanding ffmpeg's capabilities to extract > > low-level data from video codecs. Specifically, I'd like to implement > > functionality that would allow exporting frame data, macroblock > > information, quantization tables, and similar codec-specific elements > > to binary files for further analysis. > > > > After searching through the documentation and existing features, I > > haven't found similar functionality, though I may have missed > > something. Has this been implemented before, or are there related > > features I should examine? > > Some older codecs implement minor variants for this, e.g. grep > for AV_FRAME_DATA_MOTION_VECTORS, which attaches a frame's motion vectors > to the picture data. I believe there's an example app and possibly a filter > to overlay MVs on top of the video frame based on this concept. You could > extend this to cover other (macro)block info. There used to be a variant of > this for quant-tables also but I can't find it, maybe it was removed. If I recall correctly, we wanted to move away from exporting more of this kind of codec-specific information as picture data. Timothée, this kind of feature depends a lot on the codec that you want to work with. It will also depend on which syntax elements you need from the codec. In FFmpeg, there is the CBS code which describes the bitstream for a few codecs, which might help you. I have a separate project (called FFglitch), which lets you export some elements (such as quantization tables, dct coefficients, and motion vectors) from some codecs (jpeg, mpeg2, mpeg4) to JSON format, and even modify them in the bitstream. In the end, it will depend on what you want to do with the extracted low-level data, and for which codecs. Ramiro _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files 2025-05-22 12:32 ` Ramiro Polla @ 2025-05-22 17:02 ` Timothée 2025-05-22 17:43 ` Ramiro Polla 2025-05-22 20:27 ` Ronald S. Bultje 1 sibling, 1 reply; 13+ messages in thread From: Timothée @ 2025-05-22 17:02 UTC (permalink / raw) To: FFmpeg development discussions and patches The 2025-05-22T14:33:22.000+02:00, Ramiro Polla <ramiro.polla@gmail.com> wrote : > Hi, > > On Thu, May 22, 2025 at 1:59 PM Ronald S. Bultje <rsbultje@gmail.com> wrote: > >> On Wed, May 21, 2025 at 9:34 AM Timothée < >> timothee.informatique@regaud-chapuy.fr> wrote: >> >>> I am interested in expanding ffmpeg's capabilities to extract >>> low-level data from video codecs. Specifically, I'd like to >>> implement functionality that would allow exporting frame data, >>> macroblock information, quantization tables, and similar >>> codec-specific elements to binary files for further analysis. >>> After searching through the documentation and existing features, >>> I haven't found similar functionality, though I may have missed >>> something. Has this been implemented before, or are there >>> related features I should examine? >> >> Some older codecs implement minor variants for this, e.g. grep >> for AV_FRAME_DATA_MOTION_VECTORS, which attaches a frame's motion >> vectors to the picture data. I believe there's an example app and >> possibly a filter to overlay MVs on top of the video frame based >> on this concept. You could extend this to cover other (macro)block >> info. There used to be a variant of this for quant-tables also but >> I can't find it, maybe it was removed. > > If I recall correctly, we wanted to move away from exporting more > of this kind of codec-specific information as picture data. > Timothée, this kind of feature depends a lot on the codec that you > want to work with. It will also depend on which syntax elements you > need from the codec. In FFmpeg, there is the CBS code which > describes the bitstream for a few codecs, which might help you. I > have a separate project (called FFglitch), which lets you export > some elements (such as quantization tables, dct coefficients, and > motion vectors) from some codecs (jpeg, mpeg2, mpeg4) to JSON > format, and even modify them in the bitstream. In the end, it will > depend on what you want to do with the extracted low-level data, and > for which codecs. Ramiro Thank you for your response and for mentioning FFglitch - it looks like an excellent project that's very relevant to what I'm trying to accomplish. I have a question about FFglitch's capabilities: is it possible to extract quantization parameter (QP) tables using ffedit? I've reviewed the documentation but may have missed this functionality if it exists. Ideally I would want to extract data for all existing codecs, but I know this is impossible. My current focus is on implementing this feature for H.264, with plans to extend support to H.265 and AVI formats as well. I want to extract this data for scientific use. Thank you again for your time and suggestions. Timothée _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files 2025-05-22 17:02 ` Timothée @ 2025-05-22 17:43 ` Ramiro Polla 0 siblings, 0 replies; 13+ messages in thread From: Ramiro Polla @ 2025-05-22 17:43 UTC (permalink / raw) To: FFmpeg development discussions and patches On Thu, May 22, 2025 at 7:03 PM Timothée <timothee.informatique@regaud-chapuy.fr> wrote: > The 2025-05-22T14:33:22.000+02:00, Ramiro Polla > <ramiro.polla@gmail.com> wrote : > > On Thu, May 22, 2025 at 1:59 PM Ronald S. Bultje <rsbultje@gmail.com> wrote: > >> On Wed, May 21, 2025 at 9:34 AM Timothée < > >> timothee.informatique@regaud-chapuy.fr> wrote: > >>> I am interested in expanding ffmpeg's capabilities to extract > >>> low-level data from video codecs. Specifically, I'd like to > >>> implement functionality that would allow exporting frame data, > >>> macroblock information, quantization tables, and similar > >>> codec-specific elements to binary files for further analysis. > >>> After searching through the documentation and existing features, > >>> I haven't found similar functionality, though I may have missed > >>> something. Has this been implemented before, or are there > >>> related features I should examine? > >> > >> Some older codecs implement minor variants for this, e.g. grep > >> for AV_FRAME_DATA_MOTION_VECTORS, which attaches a frame's motion > >> vectors to the picture data. I believe there's an example app and > >> possibly a filter to overlay MVs on top of the video frame based > >> on this concept. You could extend this to cover other (macro)block > >> info. There used to be a variant of this for quant-tables also but > >> I can't find it, maybe it was removed. > > > > If I recall correctly, we wanted to move away from exporting more > > of this kind of codec-specific information as picture data. > > Timothée, this kind of feature depends a lot on the codec that you > > want to work with. It will also depend on which syntax elements you > > need from the codec. In FFmpeg, there is the CBS code which > > describes the bitstream for a few codecs, which might help you. I > > have a separate project (called FFglitch), which lets you export > > some elements (such as quantization tables, dct coefficients, and > > motion vectors) from some codecs (jpeg, mpeg2, mpeg4) to JSON > > format, and even modify them in the bitstream. In the end, it will > > depend on what you want to do with the extracted low-level data, and > > for which codecs. Ramiro > > Thank you for your response and for mentioning FFglitch - it looks > like an excellent project that's very relevant to what I'm trying to > accomplish. > > I have a question about FFglitch's capabilities: is it possible to > extract quantization parameter (QP) tables using ffedit? I've reviewed > the documentation but may have missed this functionality if it exists. You can get the dqt for jpeg and qscale for mpeg-2, but that's about it for the moment. > Ideally I would want to extract data for all existing codecs, but I > know this is impossible. My current focus is on implementing this > feature for H.264, with plans to extend support to H.265 and AVI > formats as well. I want to extract this data for scientific use. I see a few qp fields in libavcodec/cbs_h264.h and libavcodec/cbs_h265.h. I've never used this functionality before, but it might help you. OTOH, if you want to add h264 support to FFglitch I would be very happy :) Ramiro _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files 2025-05-22 12:32 ` Ramiro Polla 2025-05-22 17:02 ` Timothée @ 2025-05-22 20:27 ` Ronald S. Bultje 1 sibling, 0 replies; 13+ messages in thread From: Ronald S. Bultje @ 2025-05-22 20:27 UTC (permalink / raw) To: FFmpeg development discussions and patches Hi, On Thu, May 22, 2025 at 8:33 AM Ramiro Polla <ramiro.polla@gmail.com> wrote: > On Thu, May 22, 2025 at 1:59 PM Ronald S. Bultje <rsbultje@gmail.com> > wrote: > > On Wed, May 21, 2025 at 9:34 AM Timothée < > > timothee.informatique@regaud-chapuy.fr> wrote: > > > I am interested in expanding ffmpeg's capabilities to extract > > > low-level data from video codecs. Specifically, I'd like to implement > > > functionality that would allow exporting frame data, macroblock > > > information, quantization tables, and similar codec-specific elements > > > to binary files for further analysis. > > > > > > After searching through the documentation and existing features, I > > > haven't found similar functionality, though I may have missed > > > something. Has this been implemented before, or are there related > > > features I should examine? > > > > Some older codecs implement minor variants for this, e.g. grep > > for AV_FRAME_DATA_MOTION_VECTORS, which attaches a frame's motion vectors > > to the picture data. I believe there's an example app and possibly a > filter > > to overlay MVs on top of the video frame based on this concept. You could > > extend this to cover other (macro)block info. There used to be a variant > of > > this for quant-tables also but I can't find it, maybe it was removed. > > If I recall correctly, we wanted to move away from exporting more of > this kind of codec-specific information as picture data. > > Timothée, this kind of feature depends a lot on the codec that you > want to work with. It will also depend on which syntax elements you > need from the codec. In FFmpeg, there is the CBS code which describes > the bitstream for a few codecs, which might help you. I believe CBS only describes headers, not block data? Ronald _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files 2025-05-22 11:59 ` Ronald S. Bultje 2025-05-22 12:32 ` Ramiro Polla @ 2025-05-23 0:45 ` Michael Niedermayer 2025-05-23 0:57 ` Michael Niedermayer 1 sibling, 1 reply; 13+ messages in thread From: Michael Niedermayer @ 2025-05-23 0:45 UTC (permalink / raw) To: FFmpeg development discussions and patches [-- Attachment #1.1: Type: text/plain, Size: 2061 bytes --] Hi Ronald On Thu, May 22, 2025 at 07:59:06AM -0400, Ronald S. Bultje wrote: > Hi, > > On Wed, May 21, 2025 at 9:34 AM Timothée < > timothee.informatique@regaud-chapuy.fr> wrote: > > > Hello, > > > > I am interested in expanding ffmpeg's capabilities to extract > > low-level data from video codecs. Specifically, I'd like to implement > > functionality that would allow exporting frame data, macroblock > > information, quantization tables, and similar codec-specific elements > > to binary files for further analysis. > > > > After searching through the documentation and existing features, I > > haven't found similar functionality, though I may have missed > > something. Has this been implemented before, or are there related > > features I should examine? > > > Some older codecs implement minor variants for this, e.g. grep > for AV_FRAME_DATA_MOTION_VECTORS, which attaches a frame's motion vectors > to the picture data. I believe there's an example app and possibly a filter > to overlay MVs on top of the video frame based on this concept. You could > extend this to cover other (macro)block info. There used to be a variant of > this for quant-tables also but I can't find it, maybe it was removed. For motion vectors: ./ffplay -flags2 +export_mvs -i matrixbench_mpeg2.mpg -vf codecview=mv=pf+bf+bb For macroblock segmentation and type vissualization + also motion vectors: ffplay-3.4.13 -debug vis_mb_type matrixbench_mpeg2.mpg -vf codecview=mv=pf+bf+bb For QP vissualization + also motion vectors: ffplay-3.4.13 -debug vis_qp matrixbench_mpeg2.mpg -vf codecview=mv=pf+bf+bb For qp values dumped on the console ./ffplay -debug qp -i matrixbench_mpeg2.mpg [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 1 "Used only once" - "Some unspecified defect prevented a second use" "In good condition" - "Can be repaird by experienced expert" "As is" - "You wouldnt want it even if you were payed for it, if you knew ..." [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] [-- Attachment #2: Type: text/plain, Size: 251 bytes --] _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files 2025-05-23 0:45 ` Michael Niedermayer @ 2025-05-23 0:57 ` Michael Niedermayer 2025-05-23 9:33 ` Timothée 0 siblings, 1 reply; 13+ messages in thread From: Michael Niedermayer @ 2025-05-23 0:57 UTC (permalink / raw) To: FFmpeg development discussions and patches [-- Attachment #1.1: Type: text/plain, Size: 2930 bytes --] On Fri, May 23, 2025 at 02:45:59AM +0200, Michael Niedermayer wrote: > Hi Ronald > > On Thu, May 22, 2025 at 07:59:06AM -0400, Ronald S. Bultje wrote: > > Hi, > > > > On Wed, May 21, 2025 at 9:34 AM Timothée < > > timothee.informatique@regaud-chapuy.fr> wrote: > > > > > Hello, > > > > > > I am interested in expanding ffmpeg's capabilities to extract > > > low-level data from video codecs. Specifically, I'd like to implement > > > functionality that would allow exporting frame data, macroblock > > > information, quantization tables, and similar codec-specific elements > > > to binary files for further analysis. > > > > > > After searching through the documentation and existing features, I > > > haven't found similar functionality, though I may have missed > > > something. Has this been implemented before, or are there related > > > features I should examine? > > > > > > Some older codecs implement minor variants for this, e.g. grep > > for AV_FRAME_DATA_MOTION_VECTORS, which attaches a frame's motion vectors > > to the picture data. I believe there's an example app and possibly a filter > > to overlay MVs on top of the video frame based on this concept. You could > > extend this to cover other (macro)block info. There used to be a variant of > > this for quant-tables also but I can't find it, maybe it was removed. > > For motion vectors: > ./ffplay -flags2 +export_mvs -i matrixbench_mpeg2.mpg -vf codecview=mv=pf+bf+bb > > For macroblock segmentation and type vissualization + also motion vectors: > ffplay-3.4.13 -debug vis_mb_type matrixbench_mpeg2.mpg -vf codecview=mv=pf+bf+bb > > For QP vissualization + also motion vectors: > ffplay-3.4.13 -debug vis_qp matrixbench_mpeg2.mpg -vf codecview=mv=pf+bf+bb > > For qp values dumped on the console > ./ffplay -debug qp -i matrixbench_mpeg2.mpg And this can easily be extended to other codecs, ATM it should work with all 16x16 MB based codecs like msmpeg4*/wmv*/mpeg1/2/4/h263/h264 mbtype and qp vissualization need codecview to be extended or versions around 3.4 which implemented it differently Implementing vissualization as done currently with sidedata and codecview is simple and efficient. It also would allow exporting the data to json by writing a codec2json filter in place of codecview Also all decoders already have all this data parsed and available so its simpler than trying to do it in a decoder independant way I would thus suggest implementations of this for modern codecs to follow the same path as the existing code. thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "You are 36 times more likely to die in a bathtub than at the hands of a terrorist. Also, you are 2.5 times more likely to become a president and 2 times more likely to become an astronaut, than to die in a terrorist attack." -- Thoughty2 [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] [-- Attachment #2: Type: text/plain, Size: 251 bytes --] _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files 2025-05-23 0:57 ` Michael Niedermayer @ 2025-05-23 9:33 ` Timothée 2025-05-23 11:55 ` Michael Niedermayer 0 siblings, 1 reply; 13+ messages in thread From: Timothée @ 2025-05-23 9:33 UTC (permalink / raw) To: FFmpeg development discussions and patches On 2025-05-23T02:57:36.000+02:00, Michael Niedermayer <michael@niedermayer.cc> wrote: > On Fri, May 23, 2025 at 02:45:59AM +0200, Michael Niedermayer wrote: > >> Hi Ronald On Thu, May 22, 2025 at 07:59:06AM -0400, Ronald S. >> Bultje wrote: >> >>> Hi, On Wed, May 21, 2025 at 9:34 AM Timothée < >>> timothee.informatique@regaud-chapuy.fr> wrote: >>> >>>> Hello, I am interested in expanding ffmpeg's capabilities to >>>> extract low-level data from video codecs. Specifically, I'd >>>> like to implement functionality that would allow exporting >>>> frame data, macroblock information, quantization tables, and >>>> similar codec-specific elements to binary files for further >>>> analysis. After searching through the documentation and >>>> existing features, I haven't found similar functionality, >>>> though I may have missed something. Has this been implemented >>>> before, or are there related features I should examine? >>> >>> Some older codecs implement minor variants for this, e.g. grep >>> for AV_FRAME_DATA_MOTION_VECTORS, which attaches a frame's >>> motion vectors to the picture data. I believe there's an example >>> app and possibly a filter to overlay MVs on top of the video >>> frame based on this concept. You could extend this to cover >>> other (macro)block info. There used to be a variant of this for >>> quant-tables also but I can't find it, maybe it was removed. >> >> For motion vectors: ./ffplay -flags2 +export_mvs -i >> matrixbench_mpeg2.mpg -vf codecview=mv=pf+bf+bb For macroblock >> segmentation and type vissualization + also motion vectors: >> ffplay-3.4.13 -debug vis_mb_type matrixbench_mpeg2.mpg -vf >> codecview=mv=pf+bf+bb For QP vissualization + also motion vectors: >> ffplay-3.4.13 -debug vis_qp matrixbench_mpeg2.mpg -vf >> codecview=mv=pf+bf+bb For qp values dumped on the console ./ffplay >> -debug qp -i matrixbench_mpeg2.mpg > > And this can easily be extended to other codecs, ATM it should work > with all 16x16 MB based codecs like > msmpeg4*/wmv*/mpeg1/2/4/h263/h264 mbtype and qp vissualization need > codecview to be extended or versions around 3.4 which implemented it > differently Implementing vissualization as done currently with > sidedata and codecview is simple and efficient. It also would allow > exporting the data to json by writing a codec2json filter in place > of codecview Also all decoders already have all this data parsed and > available so its simpler than trying to do it in a decoder > independant way I would thus suggest implementations of this for > modern codecs to follow the same path as the existing code. thx Thanks for the helpful pointers! I will work on the codec2json filter. Looking at the code, I see where I can access sidedata but extracting qb table seems to fail. (in codecview.c l.233: ff_qp_table_extract() return 0 and qp_table is empty) (I use ./ffmpeg -flags2 +export_mvs -i input.mp4 -vf codecview=qp=1 output.mp4 -y) Is is qp extraction not implemented yet? Or is it because I have h264 video? If it's not implemented, I'm curious why there’s already code that appears to handle it. Timothée _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files 2025-05-23 9:33 ` Timothée @ 2025-05-23 11:55 ` Michael Niedermayer 2025-05-26 18:09 ` Timothée 0 siblings, 1 reply; 13+ messages in thread From: Michael Niedermayer @ 2025-05-23 11:55 UTC (permalink / raw) To: FFmpeg development discussions and patches [-- Attachment #1.1: Type: text/plain, Size: 4371 bytes --] On Fri, May 23, 2025 at 11:33:40AM +0200, Timothée wrote: > On 2025-05-23T02:57:36.000+02:00, Michael Niedermayer > <michael@niedermayer.cc> wrote: > > > On Fri, May 23, 2025 at 02:45:59AM +0200, Michael Niedermayer wrote: > > > >> Hi Ronald On Thu, May 22, 2025 at 07:59:06AM -0400, Ronald S. > >> Bultje wrote: > >> > >>> Hi, On Wed, May 21, 2025 at 9:34 AM Timothée < > >>> timothee.informatique@regaud-chapuy.fr> wrote: > >>> > >>>> Hello, I am interested in expanding ffmpeg's capabilities to > >>>> extract low-level data from video codecs. Specifically, I'd > >>>> like to implement functionality that would allow exporting > >>>> frame data, macroblock information, quantization tables, and > >>>> similar codec-specific elements to binary files for further > >>>> analysis. After searching through the documentation and > >>>> existing features, I haven't found similar functionality, > >>>> though I may have missed something. Has this been implemented > >>>> before, or are there related features I should examine? > >>> > >>> Some older codecs implement minor variants for this, e.g. grep > >>> for AV_FRAME_DATA_MOTION_VECTORS, which attaches a frame's > >>> motion vectors to the picture data. I believe there's an example > >>> app and possibly a filter to overlay MVs on top of the video > >>> frame based on this concept. You could extend this to cover > >>> other (macro)block info. There used to be a variant of this for > >>> quant-tables also but I can't find it, maybe it was removed. > >> > >> For motion vectors: ./ffplay -flags2 +export_mvs -i > >> matrixbench_mpeg2.mpg -vf codecview=mv=pf+bf+bb For macroblock > >> segmentation and type vissualization + also motion vectors: > >> ffplay-3.4.13 -debug vis_mb_type matrixbench_mpeg2.mpg -vf > >> codecview=mv=pf+bf+bb For QP vissualization + also motion vectors: > >> ffplay-3.4.13 -debug vis_qp matrixbench_mpeg2.mpg -vf > >> codecview=mv=pf+bf+bb For qp values dumped on the console ./ffplay > >> -debug qp -i matrixbench_mpeg2.mpg > > > > And this can easily be extended to other codecs, ATM it should work > > with all 16x16 MB based codecs like > > msmpeg4*/wmv*/mpeg1/2/4/h263/h264 mbtype and qp vissualization need > > codecview to be extended or versions around 3.4 which implemented it > > differently Implementing vissualization as done currently with > > sidedata and codecview is simple and efficient. It also would allow > > exporting the data to json by writing a codec2json filter in place > > of codecview Also all decoders already have all this data parsed and > > available so its simpler than trying to do it in a decoder > > independant way I would thus suggest implementations of this for > > modern codecs to follow the same path as the existing code. thx > > Thanks for the helpful pointers! > > I will work on the codec2json filter. > > Looking at the code, I see where I can access sidedata but extracting > qb table seems to fail. (in codecview.c l.233: ff_qp_table_extract() > return 0 and qp_table is empty) (I use ./ffmpeg -flags2 +export_mvs -i > input.mp4 -vf codecview=qp=1 output.mp4 -y) > > Is is qp extraction not implemented yet? Or is it because I have h264 > video? If it's not implemented, I'm curious why there’s already code > that appears to handle it. look at ff_print_debug_info2() theres probably something missing The QP and MB type code was changed from being inside arrays of pictures to sidedata. Something likely was lost/forgotten in the process -debug qp works with h264 so likely teh export into sidedata is not fully implemented thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "Nothing to hide" only works if the folks in power share the values of you and everyone you know entirely and always will -- Tom Scott [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] [-- Attachment #2: Type: text/plain, Size: 251 bytes --] _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files 2025-05-23 11:55 ` Michael Niedermayer @ 2025-05-26 18:09 ` Timothée 2025-05-26 18:57 ` Ronald S. Bultje 0 siblings, 1 reply; 13+ messages in thread From: Timothée @ 2025-05-26 18:09 UTC (permalink / raw) To: FFmpeg development discussions and patches On 2025-05-23T13:55:57.000+02:00, Michael Niedermayer <michael@niedermayer.cc> wrote: > On Fri, May 23, 2025 at 11:33:40AM +0200, Timothée wrote: > >> On 2025-05-23T02:57:36.000+02:00, Michael Niedermayer >> <michael@niedermayer.cc> wrote: >> >>> On Fri, May 23, 2025 at 02:45:59AM +0200, Michael Niedermayer >>> wrote: >>> >>>> Hi Ronald On Thu, May 22, 2025 at 07:59:06AM -0400, Ronald S. >>>> Bultje wrote: >>>> >>>>> Hi, On Wed, May 21, 2025 at 9:34 AM Timothée < >>>>> timothee.informatique@regaud-chapuy.fr> wrote: >>>>> >>>>>> Hello, I am interested in expanding ffmpeg's capabilities >>>>>> to extract low-level data from video codecs. Specifically, >>>>>> I'd like to implement functionality that would allow >>>>>> exporting frame data, macroblock information, quantization >>>>>> tables, and similar codec-specific elements to binary >>>>>> files for further analysis. After searching through the >>>>>> documentation and existing features, I haven't found >>>>>> similar functionality, though I may have missed something. >>>>>> Has this been implemented before, or are there related >>>>>> features I should examine? >>>>> >>>>> Some older codecs implement minor variants for this, e.g. >>>>> grep for AV_FRAME_DATA_MOTION_VECTORS, which attaches a >>>>> frame's motion vectors to the picture data. I believe >>>>> there's an example app and possibly a filter to overlay MVs >>>>> on top of the video frame based on this concept. You could >>>>> extend this to cover other (macro)block info. There used to >>>>> be a variant of this for quant-tables also but I can't find >>>>> it, maybe it was removed. >>>> >>>> For motion vectors: ./ffplay -flags2 +export_mvs -i >>>> matrixbench_mpeg2.mpg -vf codecview=mv=pf+bf+bb For macroblock >>>> segmentation and type vissualization + also motion vectors: >>>> ffplay-3.4.13 -debug vis_mb_type matrixbench_mpeg2.mpg -vf >>>> codecview=mv=pf+bf+bb For QP vissualization + also motion >>>> vectors: ffplay-3.4.13 -debug vis_qp matrixbench_mpeg2.mpg -vf >>>> codecview=mv=pf+bf+bb For qp values dumped on the console >>>> ./ffplay -debug qp -i matrixbench_mpeg2.mpg >>> >>> And this can easily be extended to other codecs, ATM it should >>> work with all 16x16 MB based codecs like >>> msmpeg4*/wmv*/mpeg1/2/4/h263/h264 mbtype and qp vissualization >>> need codecview to be extended or versions around 3.4 which >>> implemented it differently Implementing vissualization as done >>> currently with sidedata and codecview is simple and efficient. >>> It also would allow exporting the data to json by writing a >>> codec2json filter in place of codecview Also all decoders >>> already have all this data parsed and available so its simpler >>> than trying to do it in a decoder independant way I would thus >>> suggest implementations of this for modern codecs to follow the >>> same path as the existing code. thx >> >> Thanks for the helpful pointers! I will work on the codec2json >> filter. Looking at the code, I see where I can access sidedata but >> extracting qb table seems to fail. (in codecview.c l.233: >> ff_qp_table_extract() return 0 and qp_table is empty) (I use >> ./ffmpeg -flags2 +export_mvs -i input.mp4 -vf codecview=qp=1 >> output.mp4 -y) Is is qp extraction not implemented yet? Or is it >> because I have h264 video? If it's not implemented, I'm curious >> why there’s already code that appears to handle it. > > look at ff_print_debug_info2() theres probably something missing > The QP and MB type code was changed from being inside arrays of > pictures to sidedata. Something likely was lost/forgotten in the > process -debug qp works with h264 so likely teh export into sidedata > is not fully implemented Yes, this is exactly what is happening. After some research, I have found: `// FIXME qscale / qp ... stuff` in libavcodec/h264_slice.c, line 1871 and also in libavfilter/qp_table.h: 34 /** 35 * Normalize the qscale factor 36 * FIXME Add support for other values of enum AVVideoEncParamsType 37 * besides AV_VIDEO_ENC_PARAMS_MPEG2. 38 */ 39 static inline int ff_norm_qscale(int qscale, enum AVVideoEncParamsType type) 40 { 41 switch (type) { 42 case AV_VIDEO_ENC_PARAMS_MPEG2: return qscale >> 1; 43 } 44 return qscale; 45 } So if I understand correctly, QP tables are not attached to the frames except for MPEG2. This has been left as a FIXME for other codecs. Should I extend it to work for H.264, and maybe later for other codecs, thus removing the first FIXME and partially fixing the second? Or is this too specific and too complicated to maintain if it needs to be added for every codec? Thx, Timothée _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files 2025-05-26 18:09 ` Timothée @ 2025-05-26 18:57 ` Ronald S. Bultje 0 siblings, 0 replies; 13+ messages in thread From: Ronald S. Bultje @ 2025-05-26 18:57 UTC (permalink / raw) To: FFmpeg development discussions and patches Hi, On Mon, May 26, 2025 at 2:09 PM Timothée < timothee.informatique@regaud-chapuy.fr> wrote: > On 2025-05-23T13:55:57.000+02:00, Michael Niedermayer > <michael@niedermayer.cc> wrote: > > > On Fri, May 23, 2025 at 11:33:40AM +0200, Timothée wrote: > > > >> On 2025-05-23T02:57:36.000+02:00, Michael Niedermayer > >> <michael@niedermayer.cc> wrote: > >> > >>> On Fri, May 23, 2025 at 02:45:59AM +0200, Michael Niedermayer > >>> wrote: > >>> > >>>> Hi Ronald On Thu, May 22, 2025 at 07:59:06AM -0400, Ronald S. > >>>> Bultje wrote: > >>>> > >>>>> Hi, On Wed, May 21, 2025 at 9:34 AM Timothée < > >>>>> timothee.informatique@regaud-chapuy.fr> wrote: > >>>>> > >>>>>> Hello, I am interested in expanding ffmpeg's capabilities > >>>>>> to extract low-level data from video codecs. Specifically, > >>>>>> I'd like to implement functionality that would allow > >>>>>> exporting frame data, macroblock information, quantization > >>>>>> tables, and similar codec-specific elements to binary > >>>>>> files for further analysis. After searching through the > >>>>>> documentation and existing features, I haven't found > >>>>>> similar functionality, though I may have missed something. > >>>>>> Has this been implemented before, or are there related > >>>>>> features I should examine? > >>>>> > >>>>> Some older codecs implement minor variants for this, e.g. > >>>>> grep for AV_FRAME_DATA_MOTION_VECTORS, which attaches a > >>>>> frame's motion vectors to the picture data. I believe > >>>>> there's an example app and possibly a filter to overlay MVs > >>>>> on top of the video frame based on this concept. You could > >>>>> extend this to cover other (macro)block info. There used to > >>>>> be a variant of this for quant-tables also but I can't find > >>>>> it, maybe it was removed. > >>>> > >>>> For motion vectors: ./ffplay -flags2 +export_mvs -i > >>>> matrixbench_mpeg2.mpg -vf codecview=mv=pf+bf+bb For macroblock > >>>> segmentation and type vissualization + also motion vectors: > >>>> ffplay-3.4.13 -debug vis_mb_type matrixbench_mpeg2.mpg -vf > >>>> codecview=mv=pf+bf+bb For QP vissualization + also motion > >>>> vectors: ffplay-3.4.13 -debug vis_qp matrixbench_mpeg2.mpg -vf > >>>> codecview=mv=pf+bf+bb For qp values dumped on the console > >>>> ./ffplay -debug qp -i matrixbench_mpeg2.mpg > >>> > >>> And this can easily be extended to other codecs, ATM it should > >>> work with all 16x16 MB based codecs like > >>> msmpeg4*/wmv*/mpeg1/2/4/h263/h264 mbtype and qp vissualization > >>> need codecview to be extended or versions around 3.4 which > >>> implemented it differently Implementing vissualization as done > >>> currently with sidedata and codecview is simple and efficient. > >>> It also would allow exporting the data to json by writing a > >>> codec2json filter in place of codecview Also all decoders > >>> already have all this data parsed and available so its simpler > >>> than trying to do it in a decoder independant way I would thus > >>> suggest implementations of this for modern codecs to follow the > >>> same path as the existing code. thx > >> > >> Thanks for the helpful pointers! I will work on the codec2json > >> filter. Looking at the code, I see where I can access sidedata but > >> extracting qb table seems to fail. (in codecview.c l.233: > >> ff_qp_table_extract() return 0 and qp_table is empty) (I use > >> ./ffmpeg -flags2 +export_mvs -i input.mp4 -vf codecview=qp=1 > >> output.mp4 -y) Is is qp extraction not implemented yet? Or is it > >> because I have h264 video? If it's not implemented, I'm curious > >> why there’s already code that appears to handle it. > > > > look at ff_print_debug_info2() theres probably something missing > > The QP and MB type code was changed from being inside arrays of > > pictures to sidedata. Something likely was lost/forgotten in the > > process -debug qp works with h264 so likely teh export into sidedata > > is not fully implemented > > Yes, this is exactly what is happening. > > After some research, I have found: `// FIXME qscale / qp ... stuff` in > libavcodec/h264_slice.c, line 1871 > > and also in libavfilter/qp_table.h: > 34 /** > 35 * Normalize the qscale factor > 36 * FIXME Add support for other values of enum AVVideoEncParamsType > 37 * besides AV_VIDEO_ENC_PARAMS_MPEG2. > 38 */ > 39 static inline int ff_norm_qscale(int qscale, enum > AVVideoEncParamsType type) > 40 { > 41 switch (type) { > 42 case AV_VIDEO_ENC_PARAMS_MPEG2: return qscale >> 1; > 43 } > 44 return qscale; > 45 } > > So if I understand correctly, QP tables are not attached to the frames > except for MPEG2. This has been left as a FIXME for other codecs. > Should I extend it to work for H.264, and maybe later for other > codecs, thus removing the first FIXME and partially fixing the second? > Or is this too specific and too complicated to maintain if it needs to > be added for every codec? I think it's fine to add it one codec at a time. Ronald _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files 2025-05-21 13:34 [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files Timothée 2025-05-22 11:59 ` Ronald S. Bultje @ 2025-06-06 19:32 ` Tomas Härdin 1 sibling, 0 replies; 13+ messages in thread From: Tomas Härdin @ 2025-06-06 19:32 UTC (permalink / raw) To: FFmpeg development discussions and patches ons 2025-05-21 klockan 15:34 +0200 skrev Timothée: > Hello, > > I am interested in expanding ffmpeg's capabilities to extract > low-level data from video codecs. Specifically, I'd like to implement > functionality that would allow exporting frame data, macroblock > information, quantization tables, and similar codec-specific elements > to binary files for further analysis. So you want to convert data from one binary format to another? A text format seems more sensible if you're going through that effort /Tomas _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-06-06 19:32 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-05-21 13:34 [FFmpeg-devel] [FEATURE PROPOSAL] Extracting codec-level data to binary files Timothée 2025-05-22 11:59 ` Ronald S. Bultje 2025-05-22 12:32 ` Ramiro Polla 2025-05-22 17:02 ` Timothée 2025-05-22 17:43 ` Ramiro Polla 2025-05-22 20:27 ` Ronald S. Bultje 2025-05-23 0:45 ` Michael Niedermayer 2025-05-23 0:57 ` Michael Niedermayer 2025-05-23 9:33 ` Timothée 2025-05-23 11:55 ` Michael Niedermayer 2025-05-26 18:09 ` Timothée 2025-05-26 18:57 ` Ronald S. Bultje 2025-06-06 19:32 ` Tomas Härdin
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git