https://bugs.kde.org/show_bug.cgi?id=462049

            Bug ID: 462049
           Summary: Rendering quality of H.264 videos using libx264 is
                    consistently lower than the equivalent ffmpeg
                    encoding, even with the same reported encoding
                    settings by MediaInfo
    Classification: Applications
           Product: kdenlive
           Version: 22.08.3
          Platform: Appimage
                OS: Linux
            Status: REPORTED
          Severity: major
          Priority: NOR
         Component: Video Display & Export
          Assignee: j...@kdenlive.org
          Reporter: fuza-...@proton.me
  Target Milestone: ---

SUMMARY

Rendering quality of H.264 videos using libx264 is consistently lower than an
equivalent encoding with ffmpeg, even with the same reported encoding settings
by MediaInfo.

The same behavior occurs on multiple versions of Kdenlive, specified below.


STEPS TO REPRODUCE
1. Open Kdenlive
2. Click the "Add Clip or Folder..." button in the Project Bin
3. Select the source video file and press the "OK" button to add the clip
4. When prompted to switch to clip profile, click the "Switch" button
5. Click and drag the video from the "Clip Monitor" to the "V1" timeline below
all the way to the left and release
6. Click the "Project" menu, and then the "Render..." option to open the
"Rendering" window
7. (For 22.08.3) Create a custom preset by clicking the "Create new preset"
button, type "Custom" for the "Group" field, "H.264" for the "Preset name"
field, select "matroska" in the "Container" drop-down menu, then click the
"Edit Render Preset" button in the lower left corner of the window to display a
textbox right above it, delete the text in it and replace it with the following
line:
f=matroska vcodec=libx264 crf=%quality an=1 audio_off=1

In the "Other" tab, copy and paste the following list in the "Speed options"
textbox:
preset=veryslow
preset=slower
preset=slow
preset=medium
preset=fast
preset=faster
preset=veryfast
preset=superfast
preset=ultrafast

Then click the "OK" button in the lower right corner of the window to save the
custom preset. For following tries in which the parameters need to be changed,
the custom preset can be edited by selecting it and clicking the "Edit preset"
button.
8. In the "Rendering" window choose an appropriate path and name the filename
for the video "kdenlive-output-video.mkv" in the "Output file" field, then
select the newly created custom preset "H.264" from the "Custom" group in the
"Presets" list, then check the "More options" checkbox to display the options
panel on the right side of the window
9. Check the "Custom Quality" checkbox to enable the quality slider, be aware
of the "Encoder" section under it with its own "Speed" slider, next choose
whatever custom quality and encoder speed you want adjusting their sliders
accordingly but making note of the values of your choices reflected in the
textbox at the bottom of the right side panel, in this case, "crf" for quality
and "preset" for encoding speed. Then click the button "Render to File" to
start rendering the video
10. Wait until the rendering job finishes in the "Job Queue" tab
11. Video rendered. Click the "Close" button in the "Rendering" window to close
it, and close Kdenlive
12. Create a video encoding with the ffmpeg command-line software using the
following command, replacing source.ext with the source video file used in step
3, and "??" from the -crf option and "???" from the -preset option with the
corresponding values chosen in step 8:
ffmpeg -i source.ext -map 0:v:0 -c:v libx264 -crf ?? -preset ???
ffmpeg-output-video.mkv

13. Optional but recommended step. Use the mkvpropedit utility from the
MKVToolNix software to normalize the properties of the Matroska video files for
easier comparison in the next step. Use the following command for the two newly
created videos to do so:
mkvpropedit video.mkv --add-track-statistics-tags

14. Use the MediaInfo software to generate logs of the newly created videos,
kdenlive-output-video.mkv and ffmpeg-output-video.mkv. Compare both MediaInfo
logs and make sure that every property relevant for video quality matches in
both logs, specially the encoding settings. If they don't match, adjust the
ffmpeg command in step 12 and repeat from there until they match. Related notes
for this below.
15. Repeat all the steps choosing different source videos, settings for
quality, preset, and other related parameters (but keeping them the same for
Kdenlive and ffmpeg) as necessary.


Notes:
Using the same quality (crf) and preset parameters in Kdenlive and ffmpeg
sometimes result in a few different encoding settings in the MediaInfo logs. To
keep them the same, it helps to be more specific in the rendering/encoding
parameters, for example, with an additional "tune" parameter. If the test is
done with animated content, the "animation" tune would be appropriate:
f=matroska vcodec=libx264 crf=%quality tune=animation an=1 audio_off=1
ffmpeg -i source.ext -map 0:v:0 -c:v libx264 -crf ?? -preset ??? -tune
animation ffmpeg-output-video.mkv

Alternatively, specifying the encoding parameters in ffmpeg is easy. For
example, if kdenlive-output-video.mkv is reported to have a encoding parameter
qpmax=69 and ffmpeg-output-video.mkv is reported to have qpmax=81, you can
adjust the ffmpeg command to the following:
ffmpeg -i source.ext -map 0:v:0 -c:v libx264 -crf ?? -preset ???  -x264-params
qpmax=69 ffmpeg-output-video.mkv


OBSERVED RESULT

Despite sharing the same encoding settings, the video rendered by Kdenlive is
consistently lower to slightly lower quality than the same video encoded with
ffmpeg. 


EXPECTED RESULT

Sharing the same encoding settings, the videos produced by Kdenlive and ffmpeg
are the same, or almost the same quality.


SOFTWARE/OS VERSIONS

OS:
- Ubuntu 20.04.5 LTS 64-bit
Kdenlive:
- 22.04.3 (MLT 7.8.0, Ubuntu repositories)
- 22.08.3 (MLT 7.10.0, AppImage)
- 22.11.80/22.12 Beta1 (MLT 7.11.0, AppImage)
- 23.03.70 rev. d592484a4 (MLT 7.11.0, AppImage)
ffmpeg:
- 4.2.7
- N-108288-gdb73ae0dc1 (built from source on Sept 22nd 2022 )


ADDITIONAL INFORMATION

For more context:
https://www.reddit.com/r/kdenlive/comments/yxz3iv/comment/iwtw5ms/?utm_source=reddit&utm_medium=web2x&context=3

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to