lisamelton / other_video_transcoding

Other tools to transcode videos.
MIT License
543 stars 24 forks source link

FFMPEG issue with Videotoolbox when transcoding 10bit video track #106

Open eugeniosz opened 3 years ago

eugeniosz commented 3 years ago

Hi. I post this here even though I think this could a FFMPEG issue. Applying the other transcode command: other-transcode --hevc --10-bit --crop auto --add-audio all --surround-bitrate 384 /Volumes/MyMovies/HDR10bit_movie.mkv generate the command: ffmpeg -loglevel error -stats -i /Volumes/MyMovies/HDR10bit_movie.mkv -map 0:0 -c:v hevc_videotoolbox -pix_fmt:v yuv420p10le -b:v 8000k -color_primaries:v bt2020 -color_trc:v smpte2084 -colorspace:v bt2020nc -metadata:s:v title\= -disposition:v default -map 0:1 -c:a:0 ac3 -b:a:0 384k -metadata:s:a:0 title\= -disposition:a:0 default -map 0:2 -c:a:1 aac_at -aac_at_mode:a:1 cvbr -b:a:1 256k -ac:a:1 2 -metadata:s:a:1 title\= -disposition:a:1 0 -map 0:3 -c:a:2 aac_at -aac_at_mode:a:2 cvbr -b:a:2 256k -ac:a:2 2 -metadata:s:a:2 title\= -disposition:a:2 0 -sn -metadata:g title\= -default_mode passthrough HDR10bit_movie.mkv it fails with the following: Transcoding... [hevc_videotoolbox @ 0x7fe04d04ee00] Transfer function smpte2084 is not supported. Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height /usr/local/bin/other-transcode: transcoding failed:

Also trying with Handbrake (nightly build with H.265 10bit Videotoolbox) it fails.

Thanks for your project!

lisamelton commented 3 years ago

@eugeniosz You are very welcome for the software. Thanks for using it.

Normally FFmpeg and VideoToolbox can fail when trying to convert a 8-bit video to 10-bit, but a 10-bit-to-10bit conversion should work.

Let me ask the Video Transcoding Hivemind™ if they've seen this before. Stay tuned...

rhapsodians commented 3 years ago

@eugeniosz @donmelton

Hi all, I've just tested the command above on my 2018 i7 Mac mini (which can output 10-bit from VideoToolbox as opposed to many other older Intel chips which cannot).

My source was Soul (2020) - 4K version with a 10-bit video track. The test command run was: other-transcode --hevc --10-bit --add-audio all --surround-bitrate 384 --duration 00:01:00 /Volumes/4K/Soul\ \(2020\).mkv. I'm running ffmpeg 4.3.2 from Homebrew.

other-transcode --hevc --10-bit --add-audio all --surround-bitrate 384 --duration 00:01:00 /Volumes/4K/Soul\ \(2020\).mkv 
Verifying "ffprobe" availability...
Verifying "ffmpeg" availability...
Verifying "mkvpropedit" availability...
Finding encoders...
Trying "hevc_videotoolbox" video encoder...
Getting muxer capabilities...
Scanning media...
duration = 00:01:00
Stream mapping:
 0 = hevc_videotoolbox / 8000 Kbps
 1 = ac3 / 384 Kbps
 2 = aac_at / 256 Kbps / stereo
 3 = aac_at / 256 Kbps / stereo
 4 = aac_at / 256 Kbps / stereo
 5 = aac_at / 256 Kbps / stereo
 6 = aac_at / 256 Kbps
 7 = aac_at / 256 Kbps
Command line:
ffmpeg -loglevel error -stats -t 60 -i /Volumes/4K/Soul\ \(2020\).mkv -map 0:0 -c:v hevc_videotoolbox -pix_fmt:v yuv420p10le -b:v 8000k -color_primaries:v bt2020 -color_trc:v smpte2084 -colorspace:v bt2020nc -metadata:s:v title\= -disposition:v default -map 0:1 -c:a:0 ac3 -b:a:0 384k -metadata:s:a:0 title\= -disposition:a:0 default -map 0:2 -c:a:1 aac_at -aac_at_mode:a:1 cvbr -b:a:1 256k -ac:a:1 2 -metadata:s:a:1 title\= -disposition:a:1 0 -map 0:3 -c:a:2 aac_at -aac_at_mode:a:2 cvbr -b:a:2 256k -ac:a:2 2 -metadata:s:a:2 title\= -disposition:a:2 0 -map 0:4 -c:a:3 aac_at -aac_at_mode:a:3 cvbr -b:a:3 256k -ac:a:3 2 -metadata:s:a:3 title\= -disposition:a:3 0 -map 0:5 -c:a:4 aac_at -aac_at_mode:a:4 cvbr -b:a:4 256k -ac:a:4 2 -metadata:s:a:4 title\= -disposition:a:4 0 -map 0:6 -c:a:5 aac_at -aac_at_mode:a:5 cvbr -b:a:5 256k -metadata:s:a:5 title\= -disposition:a:5 0 -map 0:7 -c:a:6 aac_at -aac_at_mode:a:6 cvbr -b:a:6 256k -metadata:s:a:6 title\= -disposition:a:6 0 -sn -metadata:g title\= -default_mode passthrough Soul\ \(2020\).mkv
Transcoding...
frame= 1439 fps= 26 q=-0.0 Lsize=   73831kB time=00:01:00.03 bitrate=10075.2kbits/s speed=1.07x    
Assembling `.log` file...
Adding track statistics...
The file is being analyzed.
The file is read in order to create track statistics.
Progress: 100%
The changes are written to the file.
Done.

Elapsed time: 00:00:56

And the output definitely created a 10-bit transcode as you can see below from MediaInfo:

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main@L5.1@Main
Codec ID                                 : V_MPEGH/ISO/HEVC
Duration                                 : 1 min 0 s
Bit rate                                 : 8 004 kb/s
Width                                    : 3 840 pixels
Height                                   : 2 160 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 23.976 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
Bits/(Pixel*Frame)                       : 0.040
Stream size                              : 57.3 MiB (79%)
Writing library                          : Lavc58.91.100 hevc_videotoolbox
Language                                 : English
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.2020
Transfer characteristics                 : PQ
Matrix coefficients                      : BT.2020 non-constant

Without knowing your Mac, we need to check the following:

My guess at this stage is the first one above ... Intel Mac version & (possible lack of) 10-bit VT support Thanks, Joe

lisamelton commented 3 years ago

@rhapsodians Thanks for the testing and feedback, sir! 👍

eugeniosz commented 3 years ago

@eugeniosz Without knowing your Mac, we need to check the following:

  • Can your Intel Mac actually output 10-bit even from source? From my testing, the Mac mini (2018) and later Macs can but M1 Macs do not support 10-bit output. I'm not sure when the Macs started being 10-bit output capable so worth checking.
  • Is your input truly 10-bit? If you drag-drop the source onto MediaInfo, you should see a "Bit Depth: 10-bit" (as above but from the source). For example: my iPhone 11 Pro is set to 4K/60fps but it's only an 8-bit output. I don't know if the iPhone 12 models upgrade the bit-depth. But the real test would be a 4K movie rip like Soul 4K above.

My guess at this stage is the first one above ... Intel Mac version & (possible lack of) 10-bit VT support Thanks, Joe

Hi Joe, Thanks for your answer. Below more info, I use an iMac 2019 with i9-9900K and AMD Radeon Vega 48 64GB RAM

Video track media info:
{
"@type": "Video",
"StreamOrder": "0",
"ID": "1",
"UniqueID": "13470081048869518320",
"Format": "HEVC",
"Format_Profile": "Main 10",
"Format_Level": "5",
"Format_Tier": "High",
"HDR_Format": "SMPTE ST 2086",
"HDR_Format_Compatibility": "HDR10",
"CodecID": "V_MPEGH/ISO/HEVC",
"Duration": "1572.655000000",
"BitRate": "24574412",
"Width": "3840",
"Height": "1920",
"Sampled_Width": "3840",
"Sampled_Height": "1920",
"PixelAspectRatio": "1.000",
"DisplayAspectRatio": "2.000",
"FrameRate_Mode": "CFR",
"FrameRate": "23.976",
"FrameCount": "37706",
"ColorSpace": "YUV",
"ChromaSubsampling": "4:2:0",
"ChromaSubsampling_Position": "Type 2",
"BitDepth": "10",
"Delay": "0.000",
"StreamSize": "4830884120",
"Language": "en",
"Default": "Yes",
"Forced": "No",
"colour_description_present": "Yes",
"colour_description_present_Source": "Stream",
"colour_range": "Limited",
"colour_range_Source": "Stream",
"colour_primaries": "BT.2020",
"colour_primaries_Source": "Stream",
"transfer_characteristics": "PQ",
"transfer_characteristics_Source": "Stream",
"matrix_coefficients": "BT.2020 non-constant",
"matrix_coefficients_Source": "Stream",
"MasteringDisplay_ColorPrimaries": "Display P3",
"MasteringDisplay_ColorPrimaries_Source": "Stream",
"MasteringDisplay_Luminance": "min: 0.0050 cd/m2, max: 1000 cd/m2",
"MasteringDisplay_Luminance_Source": "Stream",
"MaxCLL": "186 cd/m2",
"MaxCLL_Source": "Stream",
"MaxFALL": "26 cd/m2",
"MaxFALL_Source": "Stream"
},

_ffmpeg_90001_93456.mkv.log