Skip to content

Commit

Permalink
dnxhr auto profile
Browse files Browse the repository at this point in the history
  • Loading branch information
porzione committed Jul 21, 2024
1 parent 4faa39b commit e04d685
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
8 changes: 6 additions & 2 deletions cpmyvideos.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ def copy(src, dst):
base_name = os.path.splitext(filename)[0]
if args.fnparams:
if args.fmt == 'dnxhr':
dnxp = args.dnx or enc_dnxhr.DEFAULT_PROFILE
if args.dnx:
dnxp = args.dnx
else:
idx = f'{mi.color_format}:{mi.bit_depth}'
dnxp = enc_dnxhr.PROFILES_AUTO[idx]
base_name += f'_{args.fmt}_{dnxp}'
else:
base_name += f'_{args.fmt}_{args.enc}'
Expand Down Expand Up @@ -229,7 +233,7 @@ def copy(src, dst):
debug.append(f'crf: {crf}')
if args.preset:
debug.append(f'preset: {args.preset}')
if args.fmt == 'dnxhr' and dnxp:
if args.fmt == 'dnxhr' and args.dnx:
debug.append(f'DNxHR profile: {dnxp}')
print('\n'.join(map(lambda s: f'> {s}', debug)))
mi.print()
Expand Down
14 changes: 8 additions & 6 deletions enc_dnxhr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
Avid DNXHR
https://dovidenko.com/2019/999/ffmpeg-dnxhd-dnxhr-mxf-proxies-and-optimized-media.html
https://avidtech.my.salesforce-sites.com/pkb/articles/en_US/White_Paper/DNxHR-Codec-Bandwidth-Specifications
https://avidtech.my.salesforce-sites.com/pkb/articles/en_US/Knowledge/DNxHR-Codec-Bandwidth-Specifications
https://kb.avid.com/pkb/articles/en_US/Knowledge/Avid-Qualified-Video-Rates-Rasters-and-Codecs-for-Pro-Tools
https://web.archive.org/web/20240110012221/https://avidtech.my.salesforce-sites.com/pkb/articles/en_US/White_Paper/DNxHR-Codec-Bandwidth-Specifications
https://web.archive.org/web/20240511153722/https://avidtech.my.salesforce-sites.com/pkb/articles/en_US/Knowledge/DNxHR-Codec-Bandwidth-Specifications?retURL=%2Fpkb%2Farticles%2Fen_US%2FWhite_Paper%2FDNxHR-Codec-Bandwidth-Specifications&popup=true
Supported pixel formats: yuv422p yuv422p10le yuv444p10le gbrp10le
"""
PROFILES = {
Expand All @@ -17,12 +14,17 @@
'hqx': 'yuv422p10le', # UHD/4K Broadcast-quality. 5.5:1
'444': 'yuv444p10le', # Cinema-quality. 4.5:1
}
DEFAULT_PROFILE = 'hqx'
PROFILES_AUTO = {
'yuv420:8': 'hq',
'yuv422:8': 'hq',
'yuv420:10': 'hqx',
'yuv422:10': 'hqx',
}

class Encoder:

def __init__(self, vid):
self.profile = vid.dnx if vid.dnx else DEFAULT_PROFILE
self.profile = vid.dnx if vid.dnx else PROFILES_AUTO[vid.idx()]
self.params = {
'c:v': 'dnxhd',
'profile:v': f'dnxhr_{self.profile}'
Expand Down

0 comments on commit e04d685

Please sign in to comment.