@@ -14,6 +14,7 @@ def parse_args() -> argparse.Namespace:
14
14
parser .add_argument ("--always-split" , action = "store_true" )
15
15
parser .add_argument ("--split-longer-than" )
16
16
parser .add_argument ("--min-split-segment" , default = DEFAULT_MIN_SPLIT )
17
+ parser .add_argument ("--delete-video" , action = "store_true" )
17
18
parser .add_argument ("--dry-run" , action = "store_true" )
18
19
parser .add_argument ("--verbose" , "-v" , action = "count" , default = 0 )
19
20
@@ -33,6 +34,7 @@ def process_path(
33
34
split_longer_than = None ,
34
35
min_split_segment = nums .human_to_seconds (DEFAULT_MIN_SPLIT ),
35
36
dry_run = False ,
37
+ delete_video = False ,
36
38
):
37
39
path = Path (path )
38
40
ffprobe_cmd = ["ffprobe" , "-v" , "error" , "-print_format" , "json" , "-show_format" , "-show_streams" , path ]
@@ -43,6 +45,7 @@ def process_path(
43
45
print ("No stream found:" , path )
44
46
return path
45
47
audio_stream = next ((stream for stream in info ["streams" ] if stream ["codec_type" ] == "audio" ), None )
48
+ video_stream = next ((stream for stream in info ["streams" ] if stream ["codec_type" ] == "video" ), None )
46
49
if not audio_stream :
47
50
print ("No audio stream found:" , path )
48
51
return path
@@ -121,7 +124,10 @@ def process_path(
121
124
print (cmd )
122
125
else :
123
126
subprocess .check_call (cmd , shell = True )
124
- if is_split :
127
+ if video_stream :
128
+ if delete_video :
129
+ path .unlink () # Remove original
130
+ elif is_split :
125
131
path .unlink () # Remove original
126
132
else :
127
133
if output_path .stat ().st_size > path .stat ().st_size :
@@ -144,6 +150,7 @@ def process_audio():
144
150
always_split = args .always_split ,
145
151
split_longer_than = args .split_longer_than ,
146
152
min_split_segment = args .min_split_segment ,
153
+ delete_video = args .delete_video ,
147
154
dry_run = args .dry_run ,
148
155
)
149
156
except Exception :
0 commit comments