1

I am using FFMPEG in a VFX workflow to convert .png sequences to Avid friendly DNxHD. Today I ran into a situation where a video file I created had quite a bit of banding in Avid when it should not have. Long story short I found that when I'm encoding via FFMPEG it looks quite crappy compared to Adobe Media Encoder or just importing the image sequence straight into Avid. I've double checked that the codec settings are consistent across all encoders, but for whatever reason FFMPEG just looks terrible compared to the other two (banding and compression artifacts).

So my question is if I'm doing something wrong that is limiting the bitrate? I can't see anything wrong with my code and I get no errors. Here's the command I'm using to drive FFMPEG, items in quotation are variables I feed into it:

FFMPEG.exe -y -r 23.976 -start_number "startFrame" -i "inFile" -vcodec dnxhd -b:v 175M -vf colormatrix=bt601:bt709 "outFile"

And here's the output:

2017-07-03 15:32:23:  0: STDOUT: ffmpeg version N-73361-g03b2b40 Copyright (c) 2000-2015 the FFmpeg developers
2017-07-03 15:32:23:  0: STDOUT:   built with gcc 4.9.2 (GCC)
2017-07-03 15:32:23:  0: STDOUT:   configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
2017-07-03 15:32:23:  0: STDOUT:   libavutil      54. 27.100 / 54. 27.100
2017-07-03 15:32:23:  0: STDOUT:   libavcodec     56. 46.100 / 56. 46.100
2017-07-03 15:32:23:  0: STDOUT:   libavformat    56. 40.100 / 56. 40.100
2017-07-03 15:32:23:  0: STDOUT:   libavdevice    56.  4.100 / 56.  4.100
2017-07-03 15:32:23:  0: STDOUT:   libavfilter     5. 19.100 /  5. 19.100
2017-07-03 15:32:23:  0: STDOUT:   libswscale      3.  1.101 /  3.  1.101
2017-07-03 15:32:23:  0: STDOUT:   libswresample   1.  2.100 /  1.  2.100
2017-07-03 15:32:23:  0: STDOUT:   libpostproc    53.  3.100 / 53.  3.100
2017-07-03 15:32:23:  0: STDOUT: Input #0, image2, from 'INPUT FILE_%04d.png':
2017-07-03 15:32:23:  0: STDOUT:   Duration: 00:00:05.92, start: 0.000000, bitrate: N/A
2017-07-03 15:32:23:  0: STDOUT:     Stream #0:0: Video: png, rgb24(pc), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
2017-07-03 15:32:23:  0: STDOUT: Output #0, mov, to 'OUTPUT FILE':
2017-07-03 15:32:23:  0: STDOUT:   Metadata:
2017-07-03 15:32:23:  0: STDOUT:     encoder         : Lavf56.40.100
2017-07-03 15:32:23:  0: STDOUT:     Stream #0:0: Video: dnxhd (AVdn / 0x6E645641), yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-1024, 175000 kb/s, 23.98 fps, 11988 tbn, 23.98 tbc
2017-07-03 15:32:23:  0: STDOUT:     Metadata:
2017-07-03 15:32:23:  0: STDOUT:       encoder         : Lavc56.46.100 dnxhd
2017-07-03 15:32:23:  0: STDOUT: Stream mapping:
2017-07-03 15:32:23:  0: STDOUT:   Stream #0:0 -> #0:0 (png (native) -> dnxhd (native))
2017-07-03 15:32:23:  0: STDOUT: Press [q] to stop, [?] for help
2017-07-03 15:32:24:  0: STDOUT: frame=   11 fps=0.0 q=1.0 size=    9856kB time=00:00:00.45 bitrate=175985.3kbits/s    
2017-07-03 15:32:24:  0: STDOUT: frame=   25 fps= 24 q=1.0 size=   22400kB time=00:00:01.04 bitrate=175984.9kbits/s    
2017-07-03 15:32:25:  0: STDOUT: frame=   39 fps= 25 q=1.0 size=   34944kB time=00:00:01.62 bitrate=175984.7kbits/s    
2017-07-03 15:32:25:  0: STDOUT: frame=   51 fps= 24 q=1.0 size=   45696kB time=00:00:02.12 bitrate=175984.8kbits/s    
2017-07-03 15:32:26:  0: STDOUT: frame=   65 fps= 24 q=1.0 size=   58240kB time=00:00:02.71 bitrate=175984.7kbits/s    
2017-07-03 15:32:27:  0: STDOUT: frame=   79 fps= 25 q=1.0 size=   70784kB time=00:00:03.29 bitrate=175984.7kbits/s    
2017-07-03 15:32:27:  0: STDOUT: frame=   93 fps= 25 q=1.0 size=   83328kB time=00:00:03.87 bitrate=175984.7kbits/s    
2017-07-03 15:32:28:  0: STDOUT: frame=  108 fps= 25 q=1.0 size=   96768kB time=00:00:04.50 bitrate=175984.7kbits/s    
2017-07-03 15:32:28:  0: STDOUT: frame=  122 fps= 25 q=1.0 size=  109312kB time=00:00:05.08 bitrate=175984.7kbits/s    
2017-07-03 15:32:29:  0: STDOUT: frame=  139 fps= 26 q=1.0 size=  124544kB time=00:00:05.79 bitrate=175984.7kbits/s    
2017-07-03 15:32:29:  0: STDOUT: frame=  148 fps= 26 q=1.0 Lsize=  132609kB time=00:00:06.17 bitrate=175986.5kbits/s    
2017-07-03 15:32:29:  0: STDOUT: video:132608kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.001087%

The codec settings are Avid DNxHD 175, 23.976, 8bpc.

Before: Before transcode After: After transcode

Any ideas?

  • First step is to always use a recent ffmpeg: yours is old. You can find links to static builds for Linux, macOS, or Windows at the FFmpeg Download page. Change -r 23.976 to -framerate 24000/1001 or -framerate ntsc-film. Show info from an AME produced DNxHD file so we can compare. – llogan Jul 4 '17 at 5:21
  • Thanks for the comment, I did try the newest ffmpeg (latest build as of yesterday) and got the exact same results. Why change the framerate? I'll give it a shot but I can't see why that would make a difference. What AME info do you need? – Spencer Jul 4 '17 at 21:15
  • The frame rate stuff is unrelated but I thought I would point it out anyway. The image format demuxer uses -framerate instead of -r. IIRC, there are some practical differences. 23.976 is not accurate if you want "NTSC film" frame rate. For such a short input is doesn't make a difference, but over time you can end up with fewer frames with the approximated value. The output of ffmpeg -i input will show info, and ffprobe -loglevel error -show_streams -show_format input will provide more details. – llogan Jul 5 '17 at 0:05
  • Why are you limiting bitrate with -b:v ? And use colormatrix filter? Could you upload somewhere single image that introduces banding so I can reproduce this? – Paul B. Mahol Jul 6 '17 at 10:21
  • Our editing department works at 175, rec709 (hence the color matrix). I edited my post with a sample image before and after, the before I roughly matched to rec709 with just a levels adjustment. – Spencer Jul 7 '17 at 3:26
1

You get banding because of colormatrix filter. Better use colorspace filter, and use it if really needed, when source is really not in rec709.

  • Thanks Paul, I've been reading through the documentation and seems like you are correct that this should be a better conversion. Can you give me a practical example of how to use it? I can't find much online and I tried "colorspace=bt709" as the manual suggest but it gives me an error. – Spencer Jul 14 '17 at 19:28
  • What error you get? – Paul B. Mahol Jul 15 '17 at 20:21
  • [AVFilterGraph @ 0000000004cca820] No such filter: 'colorspace'. Here's the command I'm using: ffmpeg -r 23.976 -i inputfile -vcodec dnxhd -b:v 175M -vf colorspace=bt709 outputfile. Sorry if I'm mising something stupid, I find the documentation very hard to actually put to use... – Spencer Jul 15 '17 at 21:00
  • In reading through the log I do see that ffmepg correctly gets the .png sequence as rgb: "...Stream #0:0: Video: png, rgb24(pc)..." so I theoretically should just be able to specify the output colorspace and it would work right? – Spencer Jul 15 '17 at 21:05
  • When doing rgb->yuv you need to set color matrix with scale or zscale filter instead. – Paul B. Mahol Jul 16 '17 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.