mirror of
https://github.com/ychalier/datamoshing.git
synced 2026-01-23 02:31:18 +01:00
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
"""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)
|