//音视频合成
        public static async Task <string> addaudio(string videoPath, string audioPath)
        {
            string outputPath = Path.ChangeExtension(Path.GetTempFileName(), ".mp4");
            await Conversion.AddAudio(videoPath, audioPath, outputPath).Start();

            return(outputPath);
        }
Example #2
0
        /// <summary>
        /// Extrahiert das Audio aus dem nicht adaptiven Video und fügt es mit dem adaptiven Video zusammen
        /// </summary>
        /// <param name="inputAudioVideo">Nicht adaptives Video, was das Audio enthält</param>
        /// <param name="inputVideo">Adaptives Video, mit dem das Audio kombiniert werden soll</param>
        /// <param name="output">Ausgabedatei für das Ergebnis</param>
        /// <param name="workDir">Aktuelles Verzeichnis (um eine temporäre Datei anzulegen)</param>
        private async void MergeConversion(string inputAudioVideo, string inputVideo, string output, string workDir)
        {
            string tempAudioFile = workDir + "temp.mp3";
            await FFmpeg.GetLatestVersion();

            await Conversion.ExtractAudio(inputAudioVideo, tempAudioFile).Start();

            await Conversion.AddAudio(inputVideo, tempAudioFile, output).Start();
        }
Example #3
0
        internal void AddAudioToVideo()
        {
            ///TODO write progress
            ///TODO move this away from FFMpeg to native

            //Concat the audio and video
            var tempAudio = options.temp_dir + @"\" + "finalAudio.wav";

            var conv = Conversion.AddAudio(tempVideo, tempAudio, options.output_file);

            conv.Start().Wait();
        }
        public async Task AddAudio()
        {
            string output = Path.ChangeExtension(Path.GetTempFileName(), FileExtensions.Mp4);

            IConversionResult result = await Conversion.AddAudio(Resources.Mp4, Resources.Mp3, output)
                                       .Start().ConfigureAwait(false);

            Assert.True(result.Success);
            IMediaInfo mediaInfo = await MediaInfo.Get(output).ConfigureAwait(false);

            Assert.Single(mediaInfo.AudioStreams);
            Assert.Equal("aac", mediaInfo.AudioStreams.First()
                         .Format);
            Assert.Single(mediaInfo.VideoStreams);
            Assert.Equal(TimeSpan.FromSeconds(13), mediaInfo.Duration);
        }