[FFmpeg-user] PSNR for lossless JPEG2000 doesn't match

Elliott Balsley elliottbalsley at gmail.com
Tue Jul 16 22:00:50 EEST 2019


Hello.  I’m trying to encode a v210 AVI to lossless JPEG2000.  I believe libopenjpeg defaults to the lossless profile.  When I use -psnr while encoding, it shows inf, that’s good.  But when I run -filter_complex psnr on the encoded file it shows different values.

From the documentation, I know the output of the psnr filter averages the MSE of all frames.  I don’t know how the -psnr flag works, is that also an average, or is just showing the PSNR of one frame?

Full command-line output below, first from the encode, then from the comparison.

D:\temp>ffmpeg -i 1920x1080p23.97_YUV422_Legal_60s.avi -c:v libopenjpeg -psnr -an openjpeg.mxf
ffmpeg version N-94303-g7cb4f8c962 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190716
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 30.100 / 56. 30.100
  libavcodec     58. 53.101 / 58. 53.101
  libavformat    58. 28.102 / 58. 28.102
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 56.101 /  7. 56.101
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
[avi @ 0000018978058c80] non-interleaved AVI
[avi @ 0000018978058c80] Stream #0: not enough frames to estimate rate; consider increasing probesize
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, avi, from '1920x1080p23.97_YUV422_Legal_60s.avi':
  Duration: 00:01:00.06, start: 0.000000, bitrate: 1063058 kb/s
    Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p10le, 1920x1080, 1061360 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
    Stream #0:1: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (v210 (native) -> jpeg2000 (libopenjpeg))
Press [q] to stop, [?] for help
[mxf @ 000001897805a1c0] 417083/10000000 input time base matched 1001/24000 container time base
Output #0, mxf, to 'openjpeg.mxf':
  Metadata:
    encoder         : Lavf58.28.102
    Stream #0:0: Video: jpeg2000 (libopenjpeg), yuv422p10le, 1920x1080, q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn, 23.98 tbc
    Metadata:
      encoder         : Lavc58.53.101 libopenjpeg
frame= 1440 fps=6.8 q=-0.0 LPSNR=Y:inf U:inf V:inf *:inf size= 2861957kB time=00:01:00.06 bitrate=390362.1kbits/s speed=0.285x
video:2860792kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.040706%




D:\temp>ffmpeg -i 1920x1080p23.97_YUV422_Legal_60s.avi -i openjpeg.mxf -an -filter_complex "psnr" -f null -
ffmpeg version N-94303-g7cb4f8c962 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190716
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 30.100 / 56. 30.100
  libavcodec     58. 53.101 / 58. 53.101
  libavformat    58. 28.102 / 58. 28.102
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 56.101 /  7. 56.101
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
[avi @ 0000022c13af98c0] non-interleaved AVI
[avi @ 0000022c13af98c0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, avi, from '1920x1080p23.97_YUV422_Legal_60s.avi':
  Duration: 00:01:00.06, start: 0.000000, bitrate: 1063058 kb/s
    Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p10le, 1920x1080, 1061360 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
    Stream #0:1: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s
Input #1, mxf, from 'openjpeg.mxf':
  Metadata:
    operational_pattern_ul: 060e2b34.04010101.0d010201.01010900
    uid             : adab4424-2f25-4dc7-92ff-29bd000c0000
    generation_uid  : adab4424-2f25-4dc7-92ff-29bd000c0001
    company_name    : FFmpeg
    product_name    : OP1a Muxer
    product_version : 58.28.102
    product_uid     : adab4424-2f25-4dc7-92ff-29bd000c0002
    material_package_umid: 0x060A2B340101010501010D001309998F529471341F09998F00529471341F0900
    timecode        : 00:00:00:00
  Duration: 00:01:00.06, start: 0.000000, bitrate: 390362 kb/s
    Stream #1:0: Video: jpeg2000, yuv422p10le(progressive), 1920x1080, lossless, 23.98 tbr, 23.98 tbn, 23.98 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D001309998F529471341F09998F00529471341F0901
Stream mapping:
  Stream #0:0 (v210) -> psnr:main
  Stream #1:0 (jpeg2000) -> psnr:reference
  psnr -> Stream #0:0 (wrapped_avframe)
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf58.28.102
    Stream #0:0: Video: wrapped_avframe, yuv422p10le, 1920x1080, q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn, 23.98 tbc (default)
    Metadata:
      encoder         : Lavc58.53.101 wrapped_avframe
[null @ 0000022c17ceec40] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1439 >= 1439
frame= 1441 fps= 19 q=-0.0 Lsize=N/A time=00:01:00.05 bitrate=N/A speed=0.776x
video:754kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_psnr_0 @ 0000022c29ab7680] PSNR y:30.477769 u:37.424566 v:37.127359 average:32.663307 min:26.866594 max:inf


More information about the ffmpeg-user mailing list