From 5e353d3e6622ef898f97c8cbcb7e6c62c96dab6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E5=BD=AA?= <1315508912@qq.com> Date: Wed, 27 Dec 2023 14:39:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=AA=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E9=9F=B3=E9=A2=91=E6=97=A0=E6=B3=95=E6=B7=B7=E6=B5=81?= =?UTF-8?q?=20Fixes=20#10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownKyi.Core/FFMpeg/FFMpeg.cs | 29 ++++++++++++++++++++++++++--- README.md | 4 ++-- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/DownKyi.Core/FFMpeg/FFMpeg.cs b/DownKyi.Core/FFMpeg/FFMpeg.cs index b4e72fd..ecff8d9 100644 --- a/DownKyi.Core/FFMpeg/FFMpeg.cs +++ b/DownKyi.Core/FFMpeg/FFMpeg.cs @@ -32,15 +32,38 @@ public class FFMpeg public bool MergeVideo(string audio, string video, string destVideo) { if (!File.Exists(audio) && !File.Exists(video)) return false; - FFMpegArguments + + var arguments = FFMpegArguments .FromFileInput(audio) .AddFileInput(video) .OutputToFile(destVideo, true, options => options + .WithCustomArgument("-strict -2") .WithAudioCodec("copy") .WithVideoCodec("copy") .ForceFormat("mp4") - ) - .NotifyOnError(s => LogManager.Debug("ffmpeg", s)) + ); + if (audio == null || !File.Exists(audio)) + { + arguments = FFMpegArguments.FromFileInput(video).OutputToFile( + destVideo, + true, + options => options.WithCustomArgument("-strict -2").WithVideoCodec("copy").WithAudioCodec("copy").ForceFormat("mp4") + ); + } + + if (video == null || !File.Exists(video)) + { + arguments = FFMpegArguments.FromFileInput(audio).OutputToFile( + destVideo, + true, + options => options.WithCustomArgument("-strict -2").DisableChannel(Channel.Video).WithAudioCodec("copy") + ); + } + + LogManager.Debug(Tag, arguments.Arguments); + + arguments + .NotifyOnError(s => LogManager.Debug(Tag, s)) .ProcessSynchronously(); try { diff --git a/README.md b/README.md index 3314839..7f3db12 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ [![GitHub Repo stars](https://img.shields.io/github/stars/yaobiao131/downkyicore)](https://github.com/yaobiao131/downkyicore/stargazers) [![GitHub forks](https://img.shields.io/github/forks/yaobiao131/downkyicore)](https://github.com/yaobiao131/downkyicore/network) -[![GitHub forks](https://img.shields.io/github/issues/yaobiao131/downkyicore)](https://github.com/yaobiao131/downkyicore/issues) -[![GitHub forks](https://img.shields.io/github/license/yaobiao131/downkyicore)](https://github.com/yaobiao131/downkyicore/blob/main/LICENSE) +[![GitHub issues](https://img.shields.io/github/issues/yaobiao131/downkyicore)](https://github.com/yaobiao131/downkyicore/issues) +[![LICENSE](https://img.shields.io/github/license/yaobiao131/downkyicore)](https://github.com/yaobiao131/downkyicore/blob/main/LICENSE)