gianni-rosato / aviator

A lightweight, Flatpak-first, easy-to-use GUI utility for encoding with SVT-AV1 & Opus.
GNU General Public License v3.0
172 stars 15 forks source link

Transcode fails when converting audio from Dolby TrueHD to Opus #55

Closed TriVoxel closed 8 months ago

TriVoxel commented 11 months ago

Description

HEVC/H.265 video files with audio being converted from Dolby TrueHD to Opus fails silently, and CPU usage doesn't even budge. If I select "copy audio", it works fine.

Steps to reproduce

  1. Open source video with Dolby TrueHD audio
  2. In audio tab, set quality for Opus
  3. Convert file
  4. See error

Aviator does not tell user when the conversion fails, the loading bar just sits still. Aviator needs to turn off the loading bar and present a toast notification informing the user of an error, perhaps with a button to copy the error text to clipboard?! That would be cool!

Error logs

['ffmpeg', '-nostdin', '-hide_banner', '-loglevel', 'info', '-y', '-i', '/path/to/source.mkv', '-y', '-y', '-map', '0:v', '-c:v', 'libsvtav1', '-crf', '32', '-preset', '6', '-pix_fmt', 'yuv420p10le', '-svtav1-params', 'film-grain=0:input-depth=10:tune=2:enable-qm=1:keyint=300:scd=1:enable-overlays=1:aq-mode=2:scm=2:irefresh-type=2:film-grain-denoise=0', '-map', '0:a?', '-c:a', 'libopus', '-b:a', '90K', '-y', '-y', '-ac', '0', '-map', '0:s?', '-c:s', 'copy', '-metadata', 'comment="Encoded with Aviator"', '/path/to/output.mkv']
0/100
Exception in thread Thread-1 (run_in_thread):
Traceback (most recent call last):
  File "/usr/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "/app/lib/python3.11/site-packages/aviator/__init__.py", line 437, in run_in_thread
    for progress in self.process.run_command_with_progress():
  File "/app/lib/python3.11/site-packages/ffmpeg_progress_yield/ffmpeg_progress_yield.py", line 129, in run_command_with_progress
    raise RuntimeError(f"Error running command {self.cmd}: {_pretty_stderr}")
RuntimeError: Error running command ['ffmpeg', '-nostdin', '-hide_banner', '-loglevel', 'info', '-y', '-i', '/path/to/source.mkv', '-y', '-y', '-map', '0:v', '-c:v', 'libsvtav1', '-crf', '32', '-preset', '6', '-pix_fmt', 'yuv420p10le', '-svtav1-params', 'film-grain=0:input-depth=10:tune=2:enable-qm=1:keyint=300:scd=1:enable-overlays=1:aq-mode=2:scm=2:irefresh-type=2:film-grain-denoise=0', '-map', '0:a?', '-c:a', 'libopus', '-b:a', '90K', '-y', '-y', '-ac', '0', '-map', '0:s?', '-c:s', 'copy', '-metadata', 'comment="Encoded with Aviator"', '/path/to/output.mkv']: [matroska,webm @ 0x55f91b26adc0] Could not find codec parameters for stream 4 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[matroska,webm @ 0x55f91b26adc0] Could not find codec parameters for stream 5 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[matroska,webm @ 0x55f91b26adc0] Could not find codec parameters for stream 6 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[matroska,webm @ 0x55f91b26adc0] Could not find codec parameters for stream 7 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
[matroska,webm @ 0x55f91b26adc0] Could not find codec parameters for stream 8 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, matroska,webm, from '/path/to/source.mkv':
Metadata:
encoder         : libebml v1.4.2 + libmatroska v1.6.4
creation_time   : 2022-12-14T10:06:03.000000Z
Duration: 01:40:32.24, start: 0.000000, bitrate: 18715 kb/s
Chapters:
Chapter #0:0: start 0.000000, end 481.458000
Metadata:
title           : Chapter 01
Chapter #0:1: start 481.458000, end 961.250000
Metadata:
title           : Chapter 02
Chapter #0:2: start 961.250000, end 1444.125000
Metadata:
title           : Chapter 03
Chapter #0:3: start 1444.125000, end 1954.458000
Metadata:
title           : Chapter 04
Chapter #0:4: start 1954.458000, end 2399.083000
Metadata:
title           : Chapter 05
Chapter #0:5: start 2399.083000, end 2832.792000
Metadata:
title           : Chapter 06
Chapter #0:6: start 2832.792000, end 3353.000000
Metadata:
title           : Chapter 07
Chapter #0:7: start 3353.000000, end 3843.583000
Metadata:
title           : Chapter 08
Chapter #0:8: start 3843.583000, end 4259.583000
Metadata:
title           : Chapter 09
Chapter #0:9: start 4259.583000, end 4788.667000
Metadata:
title           : Chapter 10
Chapter #0:10: start 4788.667000, end 5313.000000
Metadata:
title           : Chapter 11
Chapter #0:11: start 5313.000000, end 6031.208000
Metadata:
title           : Chapter 12
Chapter #0:12: start 6031.208000, end 6032.244000
Metadata:
title           : Chapter 13
Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x2076 [SAR 1:1 DAR 320:173], 24 fps, 24 tbr, 1k tbn (default)
Metadata:
BPS             : 13908696
DURATION        : 01:40:32.167000000
NUMBER_OF_FRAMES: 144772
NUMBER_OF_BYTES : 10487447402
_STATISTICS_WRITING_APP: mkvmerge v70.0.0 ('Caught A Lite Sneeze') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2022-12-14 10:06:03
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Side data:
DOVI configuration record: version: 1.0, profile: 8, level: 6, rpu flag: 1, el flag: 0, bl flag: 1, compatibility id: 1
Stream #0:1(eng): Audio: truehd, 48000 Hz, 7.1, s32 (24 bit) (default)
Metadata:
BPS             : 4219104
DURATION        : 01:40:32.167000000
NUMBER_OF_FRAMES: 7238600
NUMBER_OF_BYTES : 3181293018
_STATISTICS_WRITING_APP: mkvmerge v70.0.0 ('Caught A Lite Sneeze') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2022-12-14 10:06:03
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:2(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s (default)
Metadata:
BPS             : 384000
DURATION        : 01:40:32.192000000
NUMBER_OF_FRAMES: 188506
NUMBER_OF_BYTES : 289545216
_STATISTICS_WRITING_APP: mkvmerge v70.0.0 ('Caught A Lite Sneeze') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2022-12-14 10:06:03
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:3(eng): Audio: aac (LC), 48000 Hz, stereo, fltp
Metadata:
title           : Commentary
BPS             : 96654
DURATION        : 01:40:32.235000000
NUMBER_OF_FRAMES: 282761
NUMBER_OF_BYTES : 72880622
_STATISTICS_WRITING_APP: mkvmerge v70.0.0 ('Caught A Lite Sneeze') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2022-12-14 10:06:03
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:4(eng): Subtitle: hdmv_pgs_subtitle
Metadata:
title           : English SDH
BPS             : 28450
DURATION        : 01:40:11.791000000
NUMBER_OF_FRAMES: 2782
NUMBER_OF_BYTES : 21380013
_STATISTICS_WRITING_APP: mkvmerge v70.0.0 ('Caught A Lite Sneeze') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2022-12-14 10:06:03
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:5(spa): Subtitle: hdmv_pgs_subtitle
Metadata:
title           : Spanish
BPS             : 21831
DURATION        : 01:37:44.541000000
NUMBER_OF_FRAMES: 1738
NUMBER_OF_BYTES : 16004306
_STATISTICS_WRITING_APP: mkvmerge v70.0.0 ('Caught A Lite Sneeze') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2022-12-14 10:06:03
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:6(fre): Subtitle: hdmv_pgs_subtitle
Metadata:
title           : French
BPS             : 24388
DURATION        : 01:37:44.459000000
NUMBER_OF_FRAMES: 1736
NUMBER_OF_BYTES : 17878023
_STATISTICS_WRITING_APP: mkvmerge v70.0.0 ('Caught A Lite Sneeze') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2022-12-14 10:06:03
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:7(spa): Subtitle: hdmv_pgs_subtitle
Metadata:
title           : Spanish
BPS             : 666
DURATION        : 01:37:44.416000000
NUMBER_OF_FRAMES: 52
NUMBER_OF_BYTES : 488805
_STATISTICS_WRITING_APP: mkvmerge v70.0.0 ('Caught A Lite Sneeze') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2022-12-14 10:06:03
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:8(fre): Subtitle: hdmv_pgs_subtitle
Metadata:
title           : French
BPS             : 615
DURATION        : 01:37:44.417000000
NUMBER_OF_FRAMES: 56
NUMBER_OF_BYTES : 450984
_STATISTICS_WRITING_APP: mkvmerge v70.0.0 ('Caught A Lite Sneeze') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2022-12-14 10:06:03
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream mapping:
Stream #0:0 -> #0:0 (hevc (native) -> av1 (libsvtav1))
Stream #0:1 -> #0:1 (truehd (native) -> opus (libopus))
Stream #0:2 -> #0:2 (ac3 (native) -> opus (libopus))
Stream #0:3 -> #0:3 (aac (native) -> opus (libopus))
Stream #0:4 -> #0:4 (copy)
Stream #0:5 -> #0:5 (copy)
Stream #0:6 -> #0:6 (copy)
Stream #0:7 -> #0:7 (copy)
Stream #0:8 -> #0:8 (copy)
[libopus @ 0x55f91b2e61c0] Invalid channel layout 5.1(side) for specified mapping family -1.
[aost#0:2/libopus @ 0x55f91b2e5cc0] Error initializing output stream: Error while opening encoder for output stream #0:2 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
gianni-rosato commented 11 months ago

This bitstream contains a 5.1(side) mapped audio stream, which may be causing the issue since Aviator reencodes all audio tracks. FFmpeg libopus notoriously fails on 5.1(side) tracks. Have you tried setting the "Downmix to Stereo" option?

agressiv commented 11 months ago

You should remap the 5.1(side) to 5.1 for libopus, and can be done with a simple channelmap filter:

-filter:a channelmap=FL-FL|FR-FR|FC-FC|LFE-LFE|SL-BL|SR-BR:5.1"

TriVoxel commented 11 months ago

This bitstream contains a 5.1(side) mapped audio stream, which may be causing the issue since Aviator reencodes all audio tracks. FFmpeg libopus notoriously fails on 5.1(side) tracks. Have you tried setting the "Downmix to Stereo" option?

Sometimes this works, but it seldom does.

gianni-rosato commented 8 months ago

80e320ae6d1ab94c8718076fe3aa392edc2e2760