private void ConvertZoomVideoFile(ConversionConfiguration config, bool preview) { string args = "-i \"" + config.SlideVideoPath + "\" " + "-f mp4 -vcodec libx264 -crf 23 -preset veryfast -tune stillimage -profile:v baseline -level 3.0 -pix_fmt yuv420p -r 30 " + (preview ? " -t 10 " : "") + "\"" + Path.Combine(config.OutputDirectory, "slides.mp4") + "\" "; _logger.LogInformation("Execute ffmpeg: {0}", args); Process p = FFmpegHelper.FFmpeg(args, false); p.Start(); p.WaitForExit(); }
private void ConvertVideoFiles(ConversionConfiguration config, bool preview) { var lenSlideVideo = FFmpegHelper.GetMediaLength(config.SlideVideoPath); var lenTHVideo = FFmpegHelper.GetMediaLength(config.TalkingHeadVideoPath); var trimTHVideo = lenTHVideo - lenSlideVideo; // normalize audio var audioLevels = FFmpegHelper.GetAudioLevels(config.TalkingHeadVideoPath); string audioFilter = "[1:a]"; if (audioLevels != null) { audioFilter = $"[1:a]loudnorm=I=-23:LRA=11:tp=-1:measured_I={audioLevels.Input_I}:measured_LRA={audioLevels.Input_Lra}:measured_tp={audioLevels.Input_Tp}:measured_thresh={audioLevels.Input_Thresh}:offset={audioLevels.Target_Offset}:linear=true[1a];[1a]"; } // run processing string args = "-i \"" + config.SlideVideoPath + "\" " + "-i \"" + config.TalkingHeadVideoPath + "\" " + "-i \"" + config.RecordingStyle.TargetDimension.Background + "\" " + // video filters "-filter_complex " + "\"" + "[1:v]trim=start=" + trimTHVideo.TotalSeconds.ToString("0.00000", CultureInfo.InvariantCulture) + ",setpts=PTS-STARTPTS[1v];" + audioFilter + "atrim=start=" + trimTHVideo.TotalSeconds.ToString("0.00000", CultureInfo.InvariantCulture) + ",asetpts=PTS-STARTPTS,asplit=2[1a1][1a2];" + config.RecordingStyle.getFFmpegFilterString() + "\" " + "-map \"[slides1]\" -f mp4 -vcodec libx264 -crf 23 -preset veryfast -tune stillimage -profile:v baseline -level 3.0 -pix_fmt yuv420p -r 30 " + (preview ? " -t 10 " : "") + "\"" + Path.Combine(config.OutputDirectory, "slides.mp4") + "\" " + "-map \"[th_ck_ct]\" -map \"[1a1]\" -f mp4 -vcodec libx264 -crf 23 -preset veryfast -profile:v baseline -level 3.0 -pix_fmt yuv420p -r 30 -acodec aac -b:a 192k " + (preview ? " -t 10 " : "") + "\"" + Path.Combine(config.OutputDirectory, "talkinghead.mp4") + "\" " + "-map \"[stage]\" -map \"[1a2]\" -f mp4 -vcodec libx264 -crf 23 -preset veryfast -profile:v baseline -level 3.0 -pix_fmt yuv420p -r 30 -acodec aac -b:a 192k " + (preview ? " -t 10 " : "") + "\"" + Path.Combine(config.OutputDirectory, "stage.mp4") + "\" "; _logger.LogInformation("Execute ffmpeg: {0}", args); Process p = FFmpegHelper.FFmpeg(args, false); p.Start(); p.WaitForExit(); }