fix: 修复只下载音频无法混流 Fixes #10

This commit is contained in:
姚彪
2023-12-27 14:39:20 +08:00
parent cab30243a0
commit 5e353d3e66
2 changed files with 28 additions and 5 deletions

View File

@@ -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
{

View File

@@ -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)
</div>