简体   繁体   中英

Expression Encoder SDK - How to add audio track on a video

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.

MediaItem还具有一个称为AudioOverlayFileName的属性-如果要仅覆盖音频,则应设置该属性!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM