-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflv2mp4.py
49 lines (37 loc) · 863 Bytes
/
flv2mp4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'''
ArgParser Part
'''
import argparse
parser = argparse.ArgumentParser('Convert flv to mp4')
parser.add_argument('-folder', metavar='"..."',type=str, required=True, help='input the videos folder.')
args = parser.parse_args()
'''
FFmpeg Part
'''
import ffmpeg
import os
folder = os.path.abspath(args.folder)
print(f'Executing Script in "{folder}"')
for file in os.listdir(folder):
if file.split('.')[-1] == 'flv':
file_name = file[:-4]
print(f'Dealing with file : "{file}"')
file_path = os.path.abspath(f'{folder}/{file}')
task = ffmpeg.input(file_path)
task = ffmpeg.output(
task,
f'{folder}/{file_name}.mp4',
loglevel='error',
y=None,
stats=None,
acodec='copy',
vcodec='copy'
)
ffmpeg.run(task)
'''
Console command:
ffmpeg \
-i [input video] \
-c copy \
[output video]
'''