ffmpeg-python icon indicating copy to clipboard operation
ffmpeg-python copied to clipboard

how to combine audio and video together

Open princemdavi opened this issue 3 years ago • 2 comments

Hello i am developing a yotube downloader and when i am downloading youtube videos with high resolutions, there is no audio there, so i am downloading the audio and the video seperately. What i want is to merge them into one file but i am unable to do that. I don't know the command to use in order for me to merge the audio and the video

princemdavi avatar Sep 27 '21 04:09 princemdavi

Did you sove this?

tamararobin1982 avatar Mar 16 '22 08:03 tamararobin1982

given videofilepath as your downloaded video stream and audiofilepath as your downloaded audio stream I chose mkv as the output container format as it supports anything this code makes ffmpeg merge audio and video together without re-encoding

outputstream = ffmpeg.output(ffmpeg.input(videofilepath), ffmpeg.input(audiofilepath), './myoutputvideofile.mkv', vcodec='copy', acodec='copy')
ffmpeg.run(outputstream, quiet=False) # or quiet=True if you don't want ffmpeg to write anything to stdout

lazydm745 avatar Apr 10 '22 19:04 lazydm745