Compare commits

..

2 Commits

Author SHA1 Message Date
Alexandru Pisarenco 26a634864d Tweak high end bitrates to lower
5 years ago
Alexandru Pisarenco c95b48be07 Fix preset with normal aspect ratio
5 years ago

@ -202,15 +202,24 @@ class MediaInfo:
self.keep_display_aspect = 0.95 < self.resolution.ratio / self.display_aspect_ratio.ratio < 1.05
if not self.keep_display_aspect:
if self.keep_display_aspect:
self.display_width = float(self.resolution.width)
self.pixel_aspect_ratio = Ratio(1, 1)
else:
self.display_width = self.resolution.height * self.display_aspect_ratio.ratio
self.pixel_aspect_ratio = self.display_aspect_ratio
else:
self.display_width = float(self.resolution.width)
self.pixel_aspect_ratio = Ratio(
self.display_aspect_ratio.x,
self.resolution.width
)
@property
def tracks(self) -> List[AudioInfo]:
result = []
for audio in self.audio:
track = AudioInfo(audio)
result.append(track)
return result
@property
def menu(self) -> MenuInfo:
return MenuInfo(self.menu_data or { self.duration: "Chapter 1" }, duration=self.duration)
@property
def output_bitrate(self) -> int:
@ -218,27 +227,16 @@ class MediaInfo:
translations = [
Translation(0, 800, 0.5, 200, 600),
Translation(800, 1500, 0.4, 400, 800),
Translation(1500, 99999999999, 0.33, 600, 1200),
Translation(1500, 99999999999, 0.33, 600, 2500),
]
else:
translations = [
Translation(0, 800, 0.7, 450, 700),
Translation(800, 1500, 0.6, 550, 1000),
Translation(1500, 99999999999, 0.45, 800, 5000),
Translation(1500, 4000, 0.45, 800, 2500),
Translation(4000, 99999999999, 0.33, 2000, 5000),
]
bitrate = self.bitrate
for t in translations:
if t.start <= bitrate < t.end:
return int(min(t.max_br, max(t.min_br, bitrate * t.multiplier)))
@property
def tracks(self) -> List[AudioInfo]:
result = []
for audio in self.audio:
track = AudioInfo(audio)
result.append(track)
return result
@property
def menu(self) -> MenuInfo:
return MenuInfo(self.menu_data or { self.duration: "Chapter 1" }, duration=self.duration)

@ -15,3 +15,19 @@ def test_square_source():
assert info.resolution == Resolution(576, 576)
assert info.pixel_aspect_ratio == Ratio(16, 9)
def test_normal_source():
info = MediaInfo()
info.general = {
}
info.video = {
"Width": 1920,
"Height": 1080,
"DisplayAspectRatio": 1.778
}
info.determine_aspect_properties()
assert info.resolution == Resolution(1920, 1080)
assert info.pixel_aspect_ratio == Ratio(1, 1)

Loading…
Cancel
Save