Skip to content

Commit

Permalink
Add mediasize tool
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiX committed Mar 14, 2024
1 parent 431192e commit ac8738f
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions bin/mediasize
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/python3

import sys
from pathlib import Path

from pymediainfo import MediaInfo
from rich.console import Console
from rich.progress import track
from rich.table import Column, Table

table = Table(Column(header="Name", max_width=100), Column(header="Duration", justify="right"), "FR",
"Dimensions", Column(header="kBitrate/s", justify="right"), "Audio", box=None)

for file in track(sys.argv[1:], description="Reading...", transient=True):
path = Path(file)
if not path.is_file():
continue
info = MediaInfo.parse(path)
g = info.general_tracks[0]
row = [g.complete_name, g.other_duration[0] if g.other_duration else ""]
if info.video_tracks:
v = info.video_tracks[0]
row.extend((
v.frame_rate,
f'{v.width}x{v.height}',
))
else:
row.extend(('', ''))
kbits = g.overall_bit_rate / 1024
row.extend((
f'{kbits:.2f}',
",".join(
t.other_language[-2] if t.other_language else "unk"
for t in info.audio_tracks)
)
)
table.add_row(*row)

console = Console()
console.print(table)

0 comments on commit ac8738f

Please sign in to comment.