From be477197cc6c88faba5458e07f03a89ea6bf5cf4 Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Wed, 9 Dec 2020 17:07:41 +0100 Subject: [PATCH] Support specifying output encoding for ffmpeg and ffprobe output Former-commit-id: a4aba666cda695e71a2252be78741aebeb5a844f --- FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs | 9 ++++++++- FFMpegCore/FFMpeg/FFMpegOptions.cs | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs b/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs index 5961ed3..e9369a5 100644 --- a/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs +++ b/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs @@ -130,7 +130,14 @@ private Instance PrepareInstance(out CancellationTokenSource cancellationTokenSo { FFMpegHelper.RootExceptionCheck(); FFMpegHelper.VerifyFFMpegExists(); - var instance = new Instance(FFMpegOptions.Options.FFmpegBinary(), _ffMpegArguments.Text); + var startInfo = new ProcessStartInfo + { + FileName = FFMpegOptions.Options.FFmpegBinary(), + Arguments = _ffMpegArguments.Text, + StandardOutputEncoding = FFMpegOptions.Options.Encoding, + StandardErrorEncoding = FFMpegOptions.Options.Encoding, + }; + var instance = new Instance(startInfo); cancellationTokenSource = new CancellationTokenSource(); if (_onTimeProgress != null || (_onPercentageProgress != null && _totalTimespan != null)) diff --git a/FFMpegCore/FFMpeg/FFMpegOptions.cs b/FFMpegCore/FFMpeg/FFMpegOptions.cs index 947f942..5bdb3a9 100644 --- a/FFMpegCore/FFMpeg/FFMpegOptions.cs +++ b/FFMpegCore/FFMpeg/FFMpegOptions.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; namespace FFMpegCore @@ -48,6 +49,7 @@ static FFMpegOptions() public Dictionary ExtensionOverrides { get; private set; } = new Dictionary(); public bool UseCache { get; set; } = true; + public Encoding Encoding { get; set; } = Encoding.Default; private static string FFBinary(string name) {