Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge audio and video file #281

Open
ravimodha-tudip521 opened this issue Oct 23, 2019 · 2 comments
Open

Merge audio and video file #281

ravimodha-tudip521 opened this issue Oct 23, 2019 · 2 comments

Comments

@ravimodha-tudip521
Copy link

ravimodha-tudip521 commented Oct 23, 2019

Hello @kkroening ,

How can I add multiple audio files to the video at a specific time using this brilliant lib?

Please help

@spirulence
Copy link

spirulence commented Oct 27, 2019

@ravimodha-tudip521 hello! You're probably looking for something like this:

import ffmpeg


input_video = ffmpeg.input("../resources/video_with_audio.mp4")
added_audio = ffmpeg.input("../resources/dance_beat.ogg").audio.filter('adelay', "1500|1500")

merged_audio = ffmpeg.filter([input_video.audio, added_audio], 'amix')

(
    ffmpeg
    .concat(input_video, merged_audio, v=1, a=1)
    .output("mix_delayed_audio.mp4")
    .run(overwrite_output=True)
)

https://github.com/spirulence/ffmpeg-issues/blob/master/281-merge-audio-at-specific-time/281.py

You have some source video that's already got audio in it, and you want to mix in a particular snippet of audio at a particular time.

The above code applies adelay to delay the audio you're mixing in to start at a certain time (in milliseconds) and then applies amix to add it to the audio already present in the video.

You can also use amerge instead of amix, but your video might cut off early in that case and you have no control over the resulting volume.

@MrSlagovich
Copy link

Hey there @spirulence i was wondering if you knew how to replace the audio of a video? i have 1 video and one audio track and i wish to overwrite the audio of the video with the separate file. and have the track loop untill the video is finished. If you could help me i'd be very grateful, cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants