Spaces:
Running
Running
add audio to video with no audio
Browse files- addAudio.py +17 -0
addAudio.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import subprocess,platform
|
2 |
+
from pydub import AudioSegment
|
3 |
+
input_audio_path_and_name = "room-ambience.wav"
|
4 |
+
input_video_path_and_name = "ref_videos/Liv.mp4"
|
5 |
+
output_video_path_and_name= "Liv_room_ambience.mp4"
|
6 |
+
|
7 |
+
sound = AudioSegment.from_mp3("room-ambience.mp3")
|
8 |
+
|
9 |
+
# Get the duration in seconds
|
10 |
+
sound_duration = sound.duration_seconds
|
11 |
+
print("sound_duration"+str(sound_duration))
|
12 |
+
sound.export("room-ambience.wav", format="wav")
|
13 |
+
|
14 |
+
|
15 |
+
command = 'ffmpeg -y -i {} -i {} -strict -2 -q:v 1 -shortest {}'.format(input_audio_path_and_name, input_video_path_and_name,
|
16 |
+
output_video_path_and_name)
|
17 |
+
subprocess.call(command, shell=platform.system() != 'Windows')
|