1

I could use some help on this. I'd like to overlay an audio.mp3 file (or any other format for that matter) onto a video.

I'm using the free version of Expression Encoder 4, and so all my video outputs are wmv. Thing is, I don't know how to add an audio file to the video MediaItem. I tried something like this, but it didn't add the audio on the result:

MediaItem videoTrack = new MediaItem(@"path\to\videofile.wmv");
videoTrack.OutputFormat = new WindowsMediaOutputFormat();
videoTrack.OutputFormat.VideoProfile = new AdvancedVC1VideoProfile();
MediaItem audioTrack = new MediaItem(@"path\to\audio.mp3");
videoTrack.OutputFormat.AudioProfile = audioTrack.SourceAudioProfile;
job.MediaItems.Add(videoTrack);
job.Encode();

And when that didn't work (perhaps because a profile alone is just metadata, and not the audio file itself), then I tried to overlay the audio the way I would overlay an image onto the video, by doing this:

MediaItem videoTrack = new MediaItem(@"path\to\videofile.wmv");
string overlayFilename = @"path\to\audio.mp3";
videoTrack.OverlayFileName = overlayFilename;
job.MediaItems.Add(videoTrack);
job.Encode();

This failed too, with an error this time saying that the overlay item needs to have video stream or something (I guess ExEncoder expected that overlay to be a video file). Some help would be greatly appreciated. This really shouldn't be this difficult for a powerful product like ExEncoder 4.

JettK
  • 43
  • 6

1 Answers1

1

MediaItem Also has a property Called AudioOverlayFileName - you should set that one if you want to overlay only audio!

Itay Gal
  • 303
  • 2
  • 8
  • It seems like it worked for the owner, but not for me. In my case, I had a video file with no audio, and two audio files with no video. My expected result was a .mp4 file with all of those items in it. The output I was getting when using this solution was just video. Maybe I did something wrong? Anyways, I recommend using the `FFMpegConverter` class in `NReco.VideoConverter`. All you need to do is call `FFMpegConverter.Invoke("");` with one of the commands found here: http://stackoverflow.com/a/11783474 – Micah Vertal Jul 09 '16 at 03:29