Skip to content

Commit

Permalink
Version 5.7.2 (#572)
Browse files Browse the repository at this point in the history
* Fixing audio quality targeting to be enabled properly for ffmpeg
* Fixing #570 Changing audio language does not work (thanks to danielly2020)
* Fixing Setting audio track title does not work (thanks to Horatio on Discord)
* Fixing #571 AttributeError: 'NoneType' object has no attribute 'lower' (thanks to 'Dude' mikeSGman)
* Removing builds for MacOS 11 as Github has deprecated it
  • Loading branch information
cdgriffith authored Jul 1, 2024
1 parent c1a0a56 commit 7f49304
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build-nix:
strategy:
matrix:
os: [ ubuntu-20.04, ubuntu-22.04, macos-12, macos-11 ]
os: [ ubuntu-20.04, ubuntu-22.04, macos-12 ]
runs-on: ${{ matrix.os }}

steps:
Expand Down
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## Version 5.7.2

* Fixing audio quality targeting to be enabled properly for ffmpeg
* Fixing #570 Changing audio language does not work (thanks to danielly2020)
* Fixing Setting audio track title does not work (thanks to Horatio on Discord)
* Fixing #571 AttributeError: 'NoneType' object has no attribute 'lower' (thanks to 'Dude' mikeSGman)
* Removing builds for MacOS 11 as Github has deprecated it

## Version 5.7.1

* Fixing profile audio box not being able to select pattern match
Expand Down
47 changes: 39 additions & 8 deletions fastflix/encoders/common/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@
lossless = ["flac", "truehd", "alac", "tta", "wavpack", "mlp"]


def audio_quality_converter(quality, codec, channels=2, track_number=1):
base = [120, 96, 72, 48, 24, 24, 16, 8, 8, 8][quality]

match codec:
case "libopus":
return f" -vbr:{track_number} on -b:{track_number} {base * channels}k "
case "aac":
return f" -q:{track_number} {[2, 1.8, 1.6, 1.4, 1.2, 1, 0.8, 0.6, 0.4, 0.2][quality]} "
case "libfdk_aac":
return f" -q:{track_number} {[1, 1, 2, 2, 3, 3, 4, 4, 5, 5][quality]} "
case "libvorbis" | "vorbis":
return f" -q:{track_number} {[10, 9, 8, 7, 6, 5, 4, 3, 2, 1][quality]} "
case "libmp3lame" | "mp3":
return f" -q:{track_number} {quality} "
case "ac3" | "eac3" | "truehd":
return f" -b:{track_number} {base * channels * 4}k "
case _:
return f" -b:{track_number} {base * channels}k "


def build_audio(audio_tracks, audio_file_index=0):
command_list = []
for track in audio_tracks:
Expand All @@ -52,15 +72,23 @@ def build_audio(audio_tracks, audio_file_index=0):
if track.downmix
else ""
)
channel_layout = f'-filter:{track.outdex} aformat=channel_layouts="{track.raw_info.channel_layout}"'

bitrate = ""
if track.conversion_codec not in lossless:
conversion_bitrate = (
track.conversion_bitrate
if track.conversion_bitrate.lower().endswith(("k", "m", "g", "kb", "mb", "gb"))
else f"{track.conversion_bitrate}k"
)
channel_layout = f'-filter:{track.outdex} aformat=channel_layouts="{track.raw_info.channel_layout}"'
bitrate = f"-b:{track.outdex} {conversion_bitrate} {channel_layout}"
if track.conversion_bitrate:
conversion_bitrate = (
track.conversion_bitrate
if track.conversion_bitrate.lower().endswith(("k", "m", "g", "kb", "mb", "gb"))
else f"{track.conversion_bitrate}k"
)

bitrate = f"-b:{track.outdex} {conversion_bitrate} {channel_layout}"
else:
bitrate = audio_quality_converter(
track.conversion_aq, track.conversion_codec, track.raw_info.get("channels"), track.outdex
)

command_list.append(f"-c:{track.outdex} {track.conversion_codec} {bitrate} {downmix}")

if getattr(track, "dispositions", None):
Expand All @@ -73,4 +101,7 @@ def build_audio(audio_tracks, audio_file_index=0):
else:
command_list.append(f"-disposition:{track.outdex} 0")

return " ".join(command_list)
end_command = " ".join(command_list)
if " truehd " or " opus " in end_command:
end_command += " -strict -2 "
return end_command
24 changes: 23 additions & 1 deletion fastflix/encoders/common/encc_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@
logger = logging.getLogger("fastflix")


def audio_quality_converter(quality, codec, channels=2, track_number=1):
base = [120, 96, 72, 48, 24, 24, 16, 8, 8, 8][quality]

match codec:
case "libopus":
return f" --audio-bitrate {track_number}?{base * channels}k "
case "aac":
return f" --audio-quality {track_number}?{[2, 1.8, 1.6, 1.4, 1.2, 1, 0.8, 0.6, 0.4, 0.2][quality]} "
case "libfdk_aac":
return f" --audio-quality {track_number}?{[1, 1, 2, 2, 3, 3, 4, 4, 5, 5][quality]} "
case "libvorbis" | "vorbis":
return f" --audio-quality {track_number}?{[10, 9, 8, 7, 6, 5, 4, 3, 2, 1][quality]} "
case "libmp3lame" | "mp3":
return f" --audio-quality {track_number}?{quality} "
case "ac3" | "eac3" | "truehd":
return f" --audio-bitrate {track_number}?{base * channels * 4}k "
case _:
return f" --audio-bitrate {track_number}?{base * channels}k "


def rigaya_avformat_reader(fastflix: FastFlix) -> str:
# Avisynth reader avs
# VapourSynth reader vpy
Expand Down Expand Up @@ -108,7 +128,9 @@ def build_audio(audio_tracks: list[AudioTrack], audio_streams):
)
bitrate = f"--audio-bitrate {audio_id}?{conversion_bitrate} "
else:
bitrate = f"--audio-quality {audio_id}?{track.conversion_aq} "
bitrate = audio_quality_converter(
track.conversion_aq, track.conversion_codec, track.raw_info.get("channels"), audio_id
)
command_list.append(
f"{downmix} --audio-codec {audio_id}?{track.conversion_codec} {bitrate} "
f"--audio-metadata {audio_id}?clear"
Expand Down
4 changes: 2 additions & 2 deletions fastflix/ff_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def get_queue(queue_file: Path) -> list[Video]:
video["video_settings"]["output_path"] = Path(video["video_settings"]["output_path"])
encoder_settings = video["video_settings"]["video_encoder_settings"]
ves = [x(**encoder_settings) for x in setting_types.values() if x().name == encoder_settings["name"]][0]
audio = [AudioTrack(**x) for x in video["audio_tracks"]]
subtitles = [SubtitleTrack(**x) for x in video["subtitle_tracks"]]
# audio = [AudioTrack(**x) for x in video["audio_tracks"]]
# subtitles = [SubtitleTrack(**x) for x in video["subtitle_tracks"]]
attachments = []
for x in video["attachment_tracks"]:
try:
Expand Down
2 changes: 1 addition & 1 deletion fastflix/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__version__ = "5.7.1"
__version__ = "5.7.2"
__author__ = "Chris Griffith"
2 changes: 2 additions & 0 deletions fastflix/widgets/panels/audio_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ def update_enable(self):
# self.parent.parent.subtitles.reorder()

def page_update(self):
self.app.fastflix.current_video.audio_tracks[self.index].title = self.title
self.app.fastflix.current_video.audio_tracks[self.index].language = self.language
if not self.loading:
self.check_conversion_button()
return self.parent.main.page_update(build_thumbnail=False)
Expand Down

0 comments on commit 7f49304

Please sign in to comment.