mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
groking the ffprobe tarot cards
This commit is contained in:
parent
7b54a63396
commit
bf99445377
|
@ -48,6 +48,7 @@ def ffprobe(abspath):
|
||||||
def parse_ffprobe(txt):
|
def parse_ffprobe(txt):
|
||||||
"""ffprobe -show_format -show_streams"""
|
"""ffprobe -show_format -show_streams"""
|
||||||
streams = []
|
streams = []
|
||||||
|
fmt = {}
|
||||||
g = None
|
g = None
|
||||||
for ln in [x.rstrip("\r") for x in txt.split("\n")]:
|
for ln in [x.rstrip("\r") for x in txt.split("\n")]:
|
||||||
try:
|
try:
|
||||||
|
@ -63,8 +64,9 @@ def parse_ffprobe(txt):
|
||||||
|
|
||||||
if ln == "[FORMAT]":
|
if ln == "[FORMAT]":
|
||||||
g = {"codec_type": "format"} # heh
|
g = {"codec_type": "format"} # heh
|
||||||
streams.append(g)
|
fmt = g
|
||||||
|
|
||||||
|
streams = [fmt] + streams
|
||||||
ret = {} # processed
|
ret = {} # processed
|
||||||
md = {} # raw tags
|
md = {} # raw tags
|
||||||
|
|
||||||
|
@ -87,9 +89,9 @@ def parse_ffprobe(txt):
|
||||||
]
|
]
|
||||||
|
|
||||||
if typ == "video":
|
if typ == "video":
|
||||||
if strm.get("DISPOSITION:attached_pic") == "1" or strm.get(
|
if strm.get("DISPOSITION:attached_pic") == "1" or fmt.get(
|
||||||
"duration_ts"
|
"format_name"
|
||||||
) in ["1", "N/A"]:
|
) in ["mp3", "ogg", "flac"]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
kvm = [
|
kvm = [
|
||||||
|
@ -123,6 +125,9 @@ def parse_ffprobe(txt):
|
||||||
else:
|
else:
|
||||||
ret[rk] = v
|
ret[rk] = v
|
||||||
|
|
||||||
|
if ret.get("vc") == "ansi": # shellscript
|
||||||
|
return {}, {}
|
||||||
|
|
||||||
for strm in streams:
|
for strm in streams:
|
||||||
for k, v in strm.items():
|
for k, v in strm.items():
|
||||||
if not k.startswith("TAG:"):
|
if not k.startswith("TAG:"):
|
||||||
|
@ -147,7 +152,7 @@ def parse_ffprobe(txt):
|
||||||
fa, fb = fps.split("/")
|
fa, fb = fps.split("/")
|
||||||
fps = int(fa) * 1.0 / int(fb)
|
fps = int(fa) * 1.0 / int(fb)
|
||||||
|
|
||||||
if fps < 1000:
|
if fps < 1000 and fmt.get("format_name") not in ["image2", "png_pipe"]:
|
||||||
ret[".fps"] = round(fps, 3)
|
ret[".fps"] = round(fps, 3)
|
||||||
else:
|
else:
|
||||||
del ret[".fps"]
|
del ret[".fps"]
|
||||||
|
|
Loading…
Reference in a new issue