FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
NullVideoTranslator/utils.py at main · NullCoreDeveloper/NullVideoTranslator · GitHub
NullCoreDeveloper
/
NullVideoTranslator
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
NullVideoTranslator
/
utils.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
37 lines (35 loc) · 1.44 KB
Breadcrumbs
NullVideoTranslator
/
utils.py
Copy path
File metadata and controls
executable file
·
37 lines (35 loc) · 1.44 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
ffmpeg
import
os
def
extract_audio
(
video_path
,
output_path
):
"""Extracts audio from video file."""
try
:
print
(
f"Extracting audio from
{
video_path
}
to
{
output_path
}
..."
)
(
ffmpeg
.
input
(
video_path
)
.
output
(
output_path
,
acodec
=
'pcm_s16le'
,
ac
=
2
,
ar
=
'44100'
)
.
run
(
overwrite_output
=
True
,
capture_stdout
=
True
,
capture_stderr
=
True
)
)
print
(
f"Audio extracted successfully."
)
except
ffmpeg
.
Error
as
e
:
print
(
f"Error extracting audio:
{
e
.
stderr
.
decode
()
}
"
)
raise
def
combine_audio_video
(
video_path
,
audio_path
,
output_path
):
"""Combines video (visuals only) with new audio."""
try
:
print
(
f"Combining video
{
video_path
}
and audio
{
audio_path
}
into
{
output_path
}
..."
)
video
=
ffmpeg
.
input
(
video_path
)
audio
=
ffmpeg
.
input
(
audio_path
)
# Use video['v'] to select video stream, or just video if we map explicitly
# ffmpeg-python input object doesn't have .v attribute directly sometimes?
# Let's use video['v'] which is safer.
stream_v
=
video
[
'v'
]
(
ffmpeg
.
output
(
stream_v
,
audio
,
output_path
,
vcodec
=
'copy'
,
acodec
=
'aac'
)
.
run
(
overwrite_output
=
True
,
capture_stdout
=
True
,
capture_stderr
=
True
)
)
print
(
f"Video created successfully."
)
except
ffmpeg
.
Error
as
e
:
print
(
f"Error combining audio and video:
{
e
.
stderr
.
decode
()
}
"
)
raise
Back
|
FazBrowse Home
|
New Git URL