cmxl / FFmpeg.NET

.NET wrapper for common ffmpeg tasks
MIT License
611 stars 99 forks source link

How add Audio Track to Video? #5

Closed WaGi-Coding closed 5 years ago

WaGi-Coding commented 5 years ago

Hello i want to use this inside my Youtube Downloader to add an Audio Track to a Video so they could download with highest resolution + audio. How to do this? (without mixing, the audio should be a seperate track if opening the video in Vegas or similar)

WaGi-Coding commented 5 years ago

In console i can do it with: .\ffmpeg -i v.mp4 -i a.wav -c:v copy -map 0:v:0 -map 1:a:0 -shortest new.mp4

cmxl commented 5 years ago

Hi @WaGi-Coding,

Try the custom arguments as posted here: https://github.com/cmxl/FFmpeg.NET/issues/6#issuecomment-461322619

cmxl commented 5 years ago

I just verified with a sample console application that the following will work for your case:

var ffmpeg = new Engine(@"..\..\..\..\..\lib\ffmpeg\v4\ffmpeg.exe");
await ffmpeg.ExecuteAsync(@"-i C:\Temp\a.mp4 -i C:\Temp\a.wav -c:v copy -map 0:v:0 -map 1:a:0 -shortest C:\Temp\new.mp4");

You need to adjust the paths for sure. In every event that ffmpeg raises Input and Output properties will be null though.