[FFmpeg-user] How to specify custom quantization matrix via command line

Robert Krüger krueger at lesspain.de
Fri Sep 20 23:25:36 CEST 2013


On Fri, Sep 20, 2013 at 5:13 PM, Robert Krüger <krueger at lesspain.de> wrote:
> On Fri, Sep 20, 2013 at 3:53 PM, Andrey Aleksandrovich
> <andrey.aleksandrovich at googlemail.com> wrote:
>> It's interesting too for me.
>> I know that '-mpeg_quant 1' specify MPEG matrix (default is h.263).
>> But how to set custom?
>>
>> On 9/19/13, Robert Krüger <krueger at lesspain.de> wrote:
>>> Hi,
>>>
>>> I am quite sure there used to be a command line option for specifying
>>> a custom quantization matrix at least for mpeg-like codecs. I checked
>>> ffmpeg -h full and the online docs and I have not been able to find
>>> it. Was that removed at some point?
>>>
>
> OK, found it now. It's -intra_matrix
>
> However, it does not seem to change anything. I tried a number of
> combinations with -q:v and -b (my goal being to push the quality
> higher for mjpeg)
>
> I added -intra_matrix
> 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
> just for testing but all files were the same as without that argument.
>
> One example:
>
> ffmpeg -i ~/samples/cameras/panasonic/gh1/panasonic_gh1_1080_50i_15s.MTS
> -an -c:v mjpeg -q:v 1 -intra_matrix
> 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
> ~/tmp/q1-qmat1.mov
> ffmpeg version N-56463-g20101f4 Copyright (c) 2000-2013 the FFmpeg developers
>   built on Sep 19 2013 20:18:44 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
>   configuration:
>   libavutil      52. 44.100 / 52. 44.100
>   libavcodec     55. 33.100 / 55. 33.100
>   libavformat    55. 18.100 / 55. 18.100
>   libavdevice    55.  3.100 / 55.  3.100
>   libavfilter     3. 86.102 /  3. 86.102
>   libswscale      2.  5.100 /  2.  5.100
>   libswresample   0. 17.103 /  0. 17.103
> Input #0, mpegts, from
> '/Users/krueger/samples/cameras/panasonic/gh1/panasonic_gh1_1080_50i_15s.MTS':
>   Duration: 00:00:15.58, start: 0.385567, bitrate: 9613 kb/s
>   Program 1
>     Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448),
> yuv420p(tv), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50
> tbc
>     Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz,
> stereo, fltp, 192 kb/s
> [swscaler @ 0x7fa9b2801c00] deprecated pixel format used, make sure
> you did set range correctly
> Output #0, mov, to '/Users/krueger/tmp/q1-qmat1.mov':
>   Metadata:
>     encoder         : Lavf55.18.100
>     Stream #0:0: Video: mjpeg (jpeg / 0x6765706A), yuvj420p, 1920x1080
> [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 12800 tbn, 25 tbc
> Stream mapping:
>   Stream #0:0 -> #0:0 (h264 -> mjpeg)
> Press [q] to stop, [?] for help
> frame=  390 fps= 84 q=0.0 Lsize=   24962kB time=00:00:15.60
> bitrate=13108.4kbits/s
> video:24960kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.009758%
>
> The result was the same as without the matrix. I also tried with -b:v
> 100M and without anything but no sign of the matrix changing anything.

I checked in the debugger. The intra matrix used in the encoder is not
the one I specify in the command line, which is consistent with the
results.


More information about the ffmpeg-user mailing list