-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconverter.py
More file actions
52 lines (44 loc) · 1.54 KB
/
converter.py
File metadata and controls
52 lines (44 loc) · 1.54 KB
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
50
51
52
import os
import subprocess
def h264format_conv(file_path):
"""
Converts a TikTok video to H.264 (MP4) format using FFmpeg.
"""
if not os.path.exists(file_path):
print(f"File not found: {file_path}")
return None
output_file = f"h264_{os.path.basename(file_path)}"
cmd = [
"ffmpeg", "-i", file_path, "-c:v", "libx264", "-c:a", "aac", "-strict", "experimental", output_file
]
try:
subprocess.run(cmd, check=True)
print(f"Converted file saved as: {output_file}")
return output_file
except subprocess.CalledProcessError as e:
print(f"FFmpeg conversion error: {e}")
return None
except FileNotFoundError:
print("FFmpeg not found. Please install FFmpeg and try again.")
return None
def conv60fps(file_path):
"""
Converts a YouTube video to 60 FPS using FFmpeg.
"""
if not os.path.exists(file_path):
print(f"File not found: {file_path}")
return None
output_file = f"converted {os.path.basename(file_path)}"
cmd = [
"ffmpeg", "-i", file_path, "-filter:v", "fps=fps=60", "-c:a", "copy", output_file
]
try:
subprocess.run(cmd, check=True)
print(f"Converted to 60 FPS: {output_file}")
return output_file
except subprocess.CalledProcessError as e:
print(f"Conversion error: {e}")
return None
except FileNotFoundError:
print("FFmpeg not found. Ensure it is installed.")
return None