Lossless h.264 video output not lossless because 4:2:0 chroma subsampling is applied. #61569

Closed
opened 2019-02-15 11:14:01 +01:00 by Eduardo Guerras · 6 comments

System Information
Operating system:
Graphics card:

Blender Version
Broken:
(example: 2.79b release)
(example: 2.80, edbf15d3c0, blender2.8, 2018-11-28, as found on the splash screen)
Worked: (optional)

Tested only from the VSE and Blender 2.79b. Rendering to lossless h.264 applies 4:2:0 subsampling. This is not a problem for videos that are originally 4:2:0 as is the usual case. However if your footage is, e.g. 4:2:2 (usually the case with analog capture cards) the output will be downsampled to 4:2:0 and hence not lossless.

This happens only with lossless h.264. The other lossless output formats (i.e. HuffYUV and FFmpeg #1) do not suffer this problem.

Exact steps for others to reproduce the error

  1. Import this example image to the VSE:
    http://www.ozone3d.net/public/jegx/201412/chroma-subsampling-test-4k-tv.png

  2. Extend it as a video strip to an arbitrary length, e.g. 10 seconds, and adjust the start and end frames accordingly.

  3. In the properties ares, unfold ENCODING, choose container Matroska, Codec: H.264, Output quality: LOSSLESS

  4. Then choose in Render menu, RENDER ANIMATION.

  5. Watch the rendered video and see how the chroma has been subsampled and the characters appear blurry.

  6. Redo steps 3 to 5 but choosing Codec: HuffYUV, and watch how the results are satisfactory and no subsampling is applied in the output video.

**System Information** Operating system: Graphics card: **Blender Version** Broken: (example: 2.79b release) (example: 2.80, edbf15d3c044, blender2.8, 2018-11-28, as found on the splash screen) Worked: (optional) Tested only from the VSE and Blender 2.79b. Rendering to lossless h.264 applies 4:2:0 subsampling. This is not a problem for videos that are originally 4:2:0 as is the usual case. However if your footage is, e.g. 4:2:2 (usually the case with analog capture cards) the output will be downsampled to 4:2:0 and hence not lossless. This happens only with lossless h.264. The other lossless output formats (i.e. HuffYUV and FFmpeg #1) do not suffer this problem. **Exact steps for others to reproduce the error** 1. Import this example image to the VSE: http://www.ozone3d.net/public/jegx/201412/chroma-subsampling-test-4k-tv.png 2. Extend it as a video strip to an arbitrary length, e.g. 10 seconds, and adjust the start and end frames accordingly. 3. In the properties ares, unfold ENCODING, choose container Matroska, Codec: H.264, Output quality: LOSSLESS 4. Then choose in Render menu, RENDER ANIMATION. 5. Watch the rendered video and see how the chroma has been subsampled and the characters appear blurry. 6. Redo steps 3 to 5 but choosing Codec: HuffYUV, and watch how the results are satisfactory and no subsampling is applied in the output video.

Added subscriber: @eguerras-2

Added subscriber: @eguerras-2

Added subscribers: @iss, @ZedDB

Added subscribers: @iss, @ZedDB

@iss is this for you?

@iss is this for you?

Added subscriber: @Sergey

Added subscriber: @Sergey

@Sergey would be better to decide what to do with this.

We are converting all color formats to RGBA using ffmpeg's swscale with flags SWS_FAST_BILINEAR | SWS_PRINT_INFO | SWS_FULL_CHR_H_INT

I am not very experienced with FFMPEG. After quick google I got this clue:
From https://github.com/FFmpeg/FFmpeg/blob/master/doc/swscale.txt

Input to YUV Converter
When the input to the main path is not planar 8 bits per component YUV or 8-bit gray, it is converted to planar 8-bit YUV. Two sets of converters
exist for this currently: One performs horizontal downscaling by 2 before the conversion, the other leaves the full chroma resolution, but is slightly slower. The scaler will try to preserve full chroma when the output uses it. It is possible to force full chroma with SWS_FULL_CHR_H_INP even for cases where the scaler thinks it is useless.

similar tasks: #57397 (in video editor, clips get blurred) #60947 (FFMpeg color offset)

@Sergey would be better to decide what to do with this. We are converting all color formats to RGBA using ffmpeg's swscale with flags SWS_FAST_BILINEAR | SWS_PRINT_INFO | SWS_FULL_CHR_H_INT I am not very experienced with FFMPEG. After quick google I got this clue: From https://github.com/FFmpeg/FFmpeg/blob/master/doc/swscale.txt ``` Input to YUV Converter When the input to the main path is not planar 8 bits per component YUV or 8-bit gray, it is converted to planar 8-bit YUV. Two sets of converters exist for this currently: One performs horizontal downscaling by 2 before the conversion, the other leaves the full chroma resolution, but is slightly slower. The scaler will try to preserve full chroma when the output uses it. It is possible to force full chroma with SWS_FULL_CHR_H_INP even for cases where the scaler thinks it is useless. ``` similar tasks: #57397 (in video editor, clips get blurred) #60947 (FFMpeg color offset)

Closed as duplicate of #57397

Closed as duplicate of #57397
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#61569
No description provided.