initial commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*~
|
||||
14
README.md
Normal file
14
README.md
Normal file
@@ -0,0 +1,14 @@
|
||||
pickstreams
|
||||
===========
|
||||
|
||||
a frontend to ffprobe that:
|
||||
|
||||
1. produces less-verbose output with only the fields you need
|
||||
2. optionally filters by audio and subtitle languages
|
||||
|
||||
Usage:
|
||||
|
||||
pickstreams.py <file> <audio_lang> <sub_lang>
|
||||
|
||||
If audio_lang is left empty, all audio strrams are shown. If sub_lang is
|
||||
left empty, all subtitle streams are shown.
|
||||
53
pickstreams.py
Executable file
53
pickstreams.py
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
from pprint import pprint
|
||||
|
||||
streams=json.loads(subprocess.run(["ffprobe", "-v", "error", "-show_streams", "-print_format", "json", sys.argv[1]], capture_output=True).stdout.decode("utf-8"))["streams"]
|
||||
for i in streams:
|
||||
matched=True
|
||||
match i["codec_type"]:
|
||||
case "video":
|
||||
out=str(i["index"])+" "+i["codec_type"]+" "+i["codec_name"]+" "+str(i["width"])+" "+str(i["height"])+" "+i["pix_fmt"]+" "+i["r_frame_rate"]
|
||||
try:
|
||||
out=out+" "+str(int(i["bit_rate"])/1000)
|
||||
except KeyError:
|
||||
try:
|
||||
out=out+" "+str(int(i["tags"]["BPS"])/1000)
|
||||
except KeyError:
|
||||
out=out+" unknown"
|
||||
case "audio":
|
||||
try:
|
||||
if sys.argv[2]!="" and sys.argv[2]!=i["tags"]["language"]:
|
||||
matched=False
|
||||
except:
|
||||
pass
|
||||
out=str(i["index"])+" "+i["codec_type"]+" "+i["codec_name"]+" "+str(i["sample_rate"])+" "+i["channel_layout"]
|
||||
try:
|
||||
out=out+" "+str(int(i["bit_rate"])/1000)
|
||||
except KeyError:
|
||||
try:
|
||||
out=out+" "+str(int(i["tags"]["BPS"])/1000)
|
||||
except KeyError:
|
||||
out=out+" unknown"
|
||||
out=out+" "+i["tags"]["language"]
|
||||
if i["disposition"]["default"]==1:
|
||||
out=out+" default"
|
||||
case "subtitle":
|
||||
out=str(i["index"])+" "+i["codec_type"]+" "+i["codec_name"]+" "+i["tags"]["language"]
|
||||
if i["disposition"]["default"]==1:
|
||||
out=out+" default"
|
||||
if i["disposition"]["hearing_impaired"]==1:
|
||||
out=out+" hi"
|
||||
try:
|
||||
if i["tags"]["title"].find("SDH")!=-1:
|
||||
out=out+" hi"
|
||||
except KeyError:
|
||||
pass
|
||||
case _:
|
||||
out=str(i["index"])+" "+i["codec_type"]+" "+i["codec_name"]
|
||||
if matched==True:
|
||||
print(out)
|
||||
Reference in New Issue
Block a user