@@ -32,15 +32,39 @@ def main():
3232 # so that the name of reference frames matches the index when accessing that
3333 # frame in the Python decoder.
3434 frame_name = f"{ frame :06d} "
35- cmd = f"""ffmpeg -y -i { VIDEO_PATH } -map 0:{ stream } -vf select=eq(n\\ ,{ frame } ) -vsync vfr -q:v 2 { VIDEO_PATH } .stream{ stream } .frame{ frame_name } .bmp"""
36- subprocess .run (cmd .split (), check = True )
35+ cmd = [
36+ "ffmpeg" ,
37+ "-y" ,
38+ "-i" ,
39+ VIDEO_PATH ,
40+ "-map" ,
41+ f"0:{ stream } " ,
42+ "-vf" ,
43+ f"select=eq(n\\ ,{ frame } )" ,
44+ "-vsync" ,
45+ "vfr" ,
46+ "-q:v" ,
47+ "2" ,
48+ f"{ VIDEO_PATH } .stream{ stream } .frame{ frame_name } .bmp" ,
49+ ]
50+ subprocess .run (cmd , check = True )
3751
3852 # Extract individual frames at specific timestamps, including the last frame of the video.
39- seek_ts = [6.0 , 6.1 , 10.0 , 12.979633 ]
40- ts_name = [f"{ seek_ts :06f} " for seek_ts in seek_ts ]
41- for ts , name in zip (seek_ts , ts_name ):
42- cmd = f"ffmpeg -y -ss { ts } -i { VIDEO_PATH } -frames:v 1 { VIDEO_PATH } .time{ name } .bmp"
43- subprocess .run (cmd .split (), check = True )
53+ seek_timestamp = [6.0 , 6.1 , 10.0 , 12.979633 ]
54+ timestamp_name = [f"{ seek_timestamp :06f} " for seek_timestamp in seek_timestamp ]
55+ for timestamp , name in zip (seek_timestamp , timestamp_name ):
56+ cmd = [
57+ "ffmpeg" ,
58+ "-y" ,
59+ "-ss" ,
60+ str (timestamp ),
61+ "-i" ,
62+ VIDEO_PATH ,
63+ "-frames:v" ,
64+ "1" ,
65+ f"{ VIDEO_PATH } .time{ name } .bmp" ,
66+ ]
67+ subprocess .run (cmd , check = True )
4468
4569 # This video was generated by running the following:
4670 # conda install -c conda-forge x265
@@ -51,8 +75,20 @@ def main():
5175 FRAMES = [5 ]
5276 for frame in FRAMES :
5377 frame_name = f"{ frame :06d} "
54- cmd = f"""ffmpeg -y -i { VIDEO_PATH } -vf select=eq(n\\ ,{ frame } ) -vsync vfr -q:v 2 { VIDEO_PATH } .stream0.frame{ frame_name } .bmp"""
55- subprocess .run (cmd .split (), check = True )
78+ cmd = [
79+ "ffmpeg" ,
80+ "-y" ,
81+ "-i" ,
82+ VIDEO_PATH ,
83+ "-vf" ,
84+ f"select=eq(n\\ ,{ frame } )" ,
85+ "-vsync" ,
86+ "vfr" ,
87+ "-q:v" ,
88+ "2" ,
89+ f"{ VIDEO_PATH } .stream0.frame{ frame_name } .bmp" ,
90+ ]
91+ subprocess .run (cmd , check = True )
5692
5793 # This video was generated by running the following:
5894 # ffmpeg -f lavfi -i testsrc=duration=5:size=640x360:rate=25,format=yuv420p -c:v libaom-av1 -crf 30 -colorspace bt709 -color_primaries bt709 -color_trc bt709 av1_video.mkv
@@ -62,8 +98,20 @@ def main():
6298
6399 for frame in FRAMES :
64100 frame_name = f"{ frame :06d} "
65- cmd = f"""ffmpeg -y -i { VIDEO_PATH } -vf select=eq(n\\ ,{ frame } ) -vsync vfr -q:v 2 { VIDEO_PATH } .stream0.frame{ frame_name } .bmp"""
66- subprocess .run (cmd .split (), check = True )
101+ cmd = [
102+ "ffmpeg" ,
103+ "-y" ,
104+ "-i" ,
105+ VIDEO_PATH ,
106+ "-vf" ,
107+ f"select=eq(n\\ ,{ frame } )" ,
108+ "-vsync" ,
109+ "vfr" ,
110+ "-q:v" ,
111+ "2" ,
112+ f"{ VIDEO_PATH } .stream0.frame{ frame_name } .bmp" ,
113+ ]
114+ subprocess .run (cmd , check = True )
67115
68116 for bmp in [f for f in os .listdir (RESOURCES_DIR ) if f .endswith (".bmp" )]:
69117 bmp_path = os .path .join (RESOURCES_DIR , bmp )
0 commit comments