Skip to content

Commit

Permalink
Fix parsing of output with -psnr on and add 640k audio bitrate (#287)
Browse files Browse the repository at this point in the history
* Adding #195 640kbps audio (thanks to ObviousInRetrospect and Harybo)
* Fixing status parser when using -psnr (thanks to ObviousInRetrospect)

Co-authored-by: ObviousInRetrospect <42229858+obviousinretrospect@users.noreply.github.com>
  • Loading branch information
ObviousInRetrospect and ObviousInRetrospect authored Jan 20, 2022
1 parent e48bdd0 commit c7e2572
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 41 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

## Version 4.5.2

* Adding #195 640kbps audio (thanks to ObviousInRetrospect and Harybo)
* Fixing #272 Codec drop down size fix (thanks to kachijs)
* Fixing #278 FastFlix occasionally getting stuck on a single video in a queue (thanks to kamild_)
* Fixing build for 3.10 by updating to PySide6 6.2.2.1 (thanks to Nhunz)
* Fixing status parser when using -psnr (thanks to ObviousInRetrospect)

## Version 4.5.1

Expand Down
45 changes: 10 additions & 35 deletions fastflix/widgets/panels/audio_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,33 +176,7 @@ def init_conversion(self):

self.widgets.convert_bitrate = QtWidgets.QComboBox()
self.widgets.convert_bitrate.setFixedWidth(70)

self.widgets.convert_bitrate.addItems(
[f"{x}k" for x in range(16 * self.channels, (256 * self.channels) + 1, 16 * self.channels)]
if self.channels
else [
"32k",
"64k",
"96k",
"128k",
"160k",
"192k",
"224k",
"256k",
"320k",
"512K",
"768k",
"896k",
"1024k",
"1152k",
"1280k",
"1408k",
"1536k",
"1664k",
"1792k",
"1920k",
]
)
self.widgets.convert_bitrate.addItems(self.get_conversion_bitrates())
self.widgets.convert_bitrate.setCurrentIndex(3)
self.widgets.convert_bitrate.setDisabled(True)

Expand All @@ -216,6 +190,14 @@ def init_conversion(self):

return layout

def get_conversion_bitrates(self, channels=None):
if not channels:
channels = self.channels or 2
bitrates = [x for x in range(16 * channels, (256 * channels) + 1, 16 * channels)]
if channels > 1:
bitrates.append(640)
return [f"{x}k" for x in sorted(set(bitrates))]

def update_enable(self):
enabled = self.widgets.enable_check.isChecked()
self.widgets.track_number.setText(f"{self.index}:{self.outdex}" if enabled else "❌")
Expand All @@ -228,14 +210,7 @@ def update_downmix(self):
else self.channels
)
self.widgets.convert_bitrate.clear()
if channels > 0:
self.widgets.convert_bitrate.addItems(
[f"{x}k" for x in range(16 * channels, (256 * channels) + 1, 16 * channels)]
)
else:
self.widgets.convert_bitrate.addItems(
[f"{x}k" for x in range(16 * self.channels, (256 * self.channels) + 1, 16 * self.channels)]
)
self.widgets.convert_bitrate.addItems(self.get_conversion_bitrates(channels))
self.widgets.convert_bitrate.setCurrentIndex(3)
self.page_update()

Expand Down
14 changes: 8 additions & 6 deletions fastflix/widgets/panels/status_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,14 @@ def update_text(self, msg):
return
if msg.startswith("frame="):
try:
output = []
for i in (x.strip().split() for x in msg.split("=")):
output.extend(i)

frame = dict(zip(output[0::2], output[1::2]))

frame = {}
output = [i for i in (x.strip().split() for x in msg.split("="))]
output[-1].append([]) # no final value
for i in range(0, len(output) - 1):
frame[output[i][-1]] = output[i + 1][:-1]
for k in frame:
if len(frame[k]) == 1:
frame[k] = frame[k][0]
self.status_panel.speed.emit(f"{frame.get('time', '')}|{frame.get('speed', '').rstrip('x')}")
self.status_panel.bitrate.emit(frame.get("bitrate", ""))
except Exception:
Expand Down

0 comments on commit c7e2572

Please sign in to comment.