Question

I have 2 files. Both are the same length (in seconds):

  1. a video file (H.264, .mov)
  2. an audio file (PCM, .wav)

How do I use the NAudio .NET library in my C# application to overwrite the audio of file #1 with the audio from file #2? I want to write the final result to disk as a new video file.

I believe this is possible using the Media Foundation capabilities of NAudio 1.7, but I can't figure out how to modify the audio stream of a video file and re-save the video.

Was it helpful?

Solution

I'm afraid this is not possible with NAudio 1.7. NAudio has interop wrappers for a large percentage of the Media Foundation API, but the focus of the MediaFoundationReader and MediaFoundationEncoder classes is just on the audio. It should be possible with Media Foundation, so if you can find a C++ sample that does this with the MF API, you could recreate it in C# using the interop wrappers from NAudio. Alternatively you could try using a different managed Media Foundation library, such as Media Foundation .NET

OTHER TIPS

You can use FFMPEG to do that. Call FFMPEG from c# and find the command to merge Video with Audio.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top