0

I recorded some video-game footage in 320x200 and then upscaled it to 1920x1440 using ffmpeg (nearest-neighbor, lossless libx264).

Screenshots of the upscaled footage have pixel-perfect color matching the original source.

However, when I import this footage into a video editor, and then immediately export it using a lossless format... color-banding occurs.

I tried 3 different video editors (kdenlive, vsdc, shotcut). I tried five different lossless codecs (ffv1, h.264, huffyuv, utvideo, lossless jpeg). Nothing seems to work.

Any advice or suggestions would be very much appreciated.


FFMPEG comparison between Input Source and VSDC Lossless JPEG Output (which gave best results, but not perfect...)

ffmpeg -i input.mp4 -i output.avi
ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190807
  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. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:11.98, start: 0.000000, bitrate: 425 kb/s
    Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), gbrp(tv, gbr/unknown/unknown), 1920x1440, 373 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 41 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, avi, from 'output.avi':
  Metadata:
    date            : 2019-08-17
    title           : input
    encoder         : msl
  Duration: 00:00:12.00, start: 0.000000, bitrate: 126738 kb/s
    Stream #1:0: Video: jpegls (MJLS / 0x534C4A4D), rgb24(bt470bg/unknown/unknown), 1920x1440, lossless, 126664 kb/s, 60 fps, 60 tbr, 60 tbn, 60 tbc
    Stream #1:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, fltp, 224 kb/s
At least one output file must be specified
2
  • Share the result of ffmpeg -i input -i output
    – Gyan
    Aug 16 '19 at 14:31
  • @Gyan - Added to my post.
    – Anon
    Aug 16 '19 at 15:45
0

At least using Shotcut, you can get lossless output at minimum file size using the FFV1 codec.

  1. In the export window, choose the lossless/FFV1 preset.

  2. Click the Advanced button at the bottom.

  3. Go to the Codec tab, and set the GOP to 250 frames.

  4. Go to the Other tab, delete everything there and type the following:

     coder=1
     context=1
     pix_fmt=bgr0
     mlt_image_format=rgb24
    

Source: https://forum.shotcut.org/t/lossless-annoyances/18344/2


Edit (June 2021)

The newer versions of Shotcut have better options for lossless encoding with smaller output file size. Here are the steps:

  1. Click the Settings menu > Video Mode > Custom > Add..., then set Colorspace to BT.709 and click OK.

  2. In the Export window, choose any preset and click the Advanced button at the bottom.

  3. In the Codec tab, set Codec to libx264rgb, set Rate control to Quality-based VBR, set Quality to 100%, and set GOP to 250.

  4. In the Other tab, delete everything and paste the following:

     pix_fmt=bgr24
     mlt_image_format=rgb24
     qp=0
    

When you're done you can save these settings for later use; click the + button at the bottom of the Presets list and choose a name for your custom preset.

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.