mirror of
https://github.com/ychalier/datamoshing.git
synced 2026-01-24 19:21:29 +01:00
Merge branch 'main' of ssh://github.com/ychalier/datamoshing
This commit is contained in:
35
analyze.py
Normal file
35
analyze.py
Normal file
@@ -0,0 +1,35 @@
|
||||
"""Print the type of frames for a given video
|
||||
"""
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def analyze(input_path: Path):
|
||||
output = subprocess.check_output(
|
||||
[
|
||||
"ffprobe",
|
||||
"-v",
|
||||
"quiet",
|
||||
"-pretty",
|
||||
"-print_format",
|
||||
"json",
|
||||
"-show_entries",
|
||||
"format=size,bit_rate:frame=coded_picture_number,pkt_pts_time,pkt_pts,pkt_dts_time,pkt_dts,pkt_duration_time,pict_type,interlaced_frame,top_field_first,repeat_pict,width,height,sample_aspect_ratio,display_aspect_ratio,r_frame_rate,avg_frame_rate,time_base,pkt_size",
|
||||
"-select_streams",
|
||||
"v:0",
|
||||
input_path
|
||||
],
|
||||
)
|
||||
data = json.loads(output)
|
||||
for frame in data["frames"]:
|
||||
print(frame["coded_picture_number"], frame["pict_type"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("input_path", type=Path)
|
||||
args = parser.parse_args()
|
||||
analyze(args.input_path)
|
||||
Reference in New Issue
Block a user