Add mpv log setting

Default if false (off)
This commit is contained in:
Nikolaj Olsson 2020-11-07 09:02:20 +01:00
parent f143b8ff4c
commit 5ce4a1ffc3
3 changed files with 25 additions and 7 deletions

View File

@ -3,7 +3,7 @@
3.5.18 (xth November 2020) BETA
* NEW:
* Add "Measurement converter" - thx OmrSi
* Add waveform multi- track support - thx OmrSi
* Add waveform multi-audio-track support - thx OmrSi
* Add import/export of shortcuts
* Add "Matroska chapter support" - thx OmrSi
* Add subtitle format XMP - thx Tore
@ -30,6 +30,7 @@
* Allow for .mpg/.mpeg transport stream file extension in "Batch convert"
* Add some more EBU STL validation - thx Valentina
* Improve Korean auto detect in PAC - thx andrewburnheimer
* Add MpvLogging setting
* FIXED:
* Fix crash in export image with font tag - thx Jake
* Fix batch convert of Blu-ray sup file to VobSub - thx John

View File

@ -1115,6 +1115,7 @@ $HorzAlign = Center
public string MpvVideoOutputWindows { get; set; }
public string MpvVideoOutputLinux { get; set; }
public string MpvExtraOption { get; set; }
public bool MpvLogging { get; set; }
public bool MpvHandlesPreviewText { get; set; }
public string MpcHcLocation { get; set; }
public string MkvMergeLocation { get; set; }
@ -3302,6 +3303,12 @@ $HorzAlign = Center
settings.General.MpvExtraOption = subNode.InnerText.Trim();
}
subNode = node.SelectSingleNode("MpvLogging");
if (subNode != null)
{
settings.General.MpvLogging = Convert.ToBoolean(subNode.InnerText.Trim());
}
subNode = node.SelectSingleNode("MpvHandlesPreviewText");
if (subNode != null)
{
@ -7712,6 +7719,7 @@ $HorzAlign = Center
textWriter.WriteElementString("MpvVideoOutputWindows", settings.General.MpvVideoOutputWindows);
textWriter.WriteElementString("MpvVideoOutputLinux", settings.General.MpvVideoOutputLinux);
textWriter.WriteElementString("MpvExtraOption", settings.General.MpvExtraOption);
textWriter.WriteElementString("MpvLogging", settings.General.MpvLogging.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("MpvHandlesPreviewText", settings.General.MpvHandlesPreviewText.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("MpcHcLocation", settings.General.MpcHcLocation);
textWriter.WriteElementString("MkvMergeLocation", settings.General.MkvMergeLocation);

View File

@ -64,7 +64,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
private IntPtr _mpvHandle;
private Timer _videoLoadedTimer;
private double? _pausePosition; // Hack to hold precise seeking when paused
private string _secondSubtitleFileName;
private string _secondSubtitleFileName;
public override event EventHandler OnVideoLoaded;
public override event EventHandler OnVideoEnded;
@ -359,9 +359,15 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
{
var lpBuffer = IntPtr.Zero;
_mpvGetPropertyString(_mpvHandle, GetUtf8Bytes("aid"), MpvFormatString, ref lpBuffer);
int id = int.Parse(Marshal.PtrToStringAnsi(lpBuffer));
int idx = _audioTrackIds.FindIndex(x => x.Key == id);
int number = AudioTracks.Count > 1 && idx != -1 ? idx : 0;
var numberString = Marshal.PtrToStringAnsi(lpBuffer);
if (string.IsNullOrEmpty(numberString))
{
return 0;
}
var id = int.Parse(numberString);
var idx = _audioTrackIds.FindIndex(x => x.Key == id);
var number = AudioTracks.Count > 1 && idx != -1 ? idx : 0;
_mpvFree(lpBuffer);
return number;
}
@ -504,8 +510,11 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
}
_mpvHandle = _mpvCreate.Invoke();
//var logFileName = Path.Combine(Configuration.DataDirectory, "mpv-log-" + Guid.NewGuid() + ".txt");
//_mpvSetOptionString(_mpvHandle, GetUtf8Bytes("log-file"), GetUtf8Bytes(logFileName));
if (Configuration.Settings.General.MpvLogging)
{
var logFileName = Path.Combine(Configuration.DataDirectory, "mpv-log-" + Guid.NewGuid() + ".txt");
_mpvSetOptionString(_mpvHandle, GetUtf8Bytes("log-file"), GetUtf8Bytes(logFileName));
}
}
else if (!Directory.Exists(videoFileName))
{