mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-28 15:02:35 +01:00
Fix a few issues with "Generate blank video" - thx OmrSi :)
This commit is contained in:
parent
cbfd2b2e71
commit
6ce83a5603
@ -5,6 +5,7 @@ using Nikse.SubtitleEdit.Logic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Eventing.Reader;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
@ -232,10 +233,18 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
if (_numberOfAudioTracks == 0 && MessageBox.Show(LanguageSettings.Current.AddWaveform.NoAudioTracksFoundGenerateEmptyWaveform, LanguageSettings.Current.General.Title, MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
|
||||
if (_numberOfAudioTracks == 0)
|
||||
{
|
||||
MakeEmptyWaveFile();
|
||||
DialogResult = DialogResult.OK;
|
||||
if (MessageBox.Show(LanguageSettings.Current.AddWaveform.NoAudioTracksFoundGenerateEmptyWaveform, LanguageSettings.Current.General.Title, MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
|
||||
{
|
||||
MakeEmptyWaveFile();
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -249,10 +258,18 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (targetFileInfo.Length <= 200)
|
||||
{
|
||||
if (_numberOfAudioTracks == 0 && MessageBox.Show(LanguageSettings.Current.AddWaveform.NoAudioTracksFoundGenerateEmptyWaveform, LanguageSettings.Current.General.Title, MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
|
||||
if (_numberOfAudioTracks == 0)
|
||||
{
|
||||
MakeEmptyWaveFile();
|
||||
DialogResult = DialogResult.OK;
|
||||
if (MessageBox.Show(LanguageSettings.Current.AddWaveform.NoAudioTracksFoundGenerateEmptyWaveform, LanguageSettings.Current.General.Title, MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
|
||||
{
|
||||
MakeEmptyWaveFile();
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -390,7 +407,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
_peakWaveFileName = peakWaveFileName;
|
||||
_spectrogramDirectory = spectrogramFolder;
|
||||
_spectrogramDirectory = spectrogramFolder;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -9,7 +9,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
|
||||
public string VideoFileName { get; private set; }
|
||||
private bool _abort { get; set; }
|
||||
private bool _abort;
|
||||
|
||||
public GenerateVideo(Subtitle subtitle)
|
||||
{
|
||||
|
@ -25705,9 +25705,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
generateTextFromCurrentVideoToolStripMenuItem.Visible = Directory.Exists(Path.Combine(Configuration.DataDirectory, "pocketsphinx"));
|
||||
|
||||
generateBlankVideoToolStripMenuItem.Enabled = !Configuration.IsRunningOnWindows ||
|
||||
!string.IsNullOrWhiteSpace(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation);
|
||||
}
|
||||
|
||||
private void ChooseAudioTrack(object sender, EventArgs e)
|
||||
@ -31317,6 +31314,26 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void generateBlankVideoToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Configuration.IsRunningOnWindows && (string.IsNullOrWhiteSpace(Configuration.Settings.General.FFmpegLocation) || !File.Exists(Configuration.Settings.General.FFmpegLocation)))
|
||||
{
|
||||
if (MessageBox.Show(LanguageSettings.Current.Settings.DownloadFFmpeg, "Subtitle Edit", MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using (var form = new DownloadFfmpeg())
|
||||
{
|
||||
if (form.ShowDialog(this) == DialogResult.OK && !string.IsNullOrEmpty(form.FFmpegPath))
|
||||
{
|
||||
Configuration.Settings.General.FFmpegLocation = form.FFmpegPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (var form = new GenerateVideo(_subtitle))
|
||||
{
|
||||
var result = form.ShowDialog(this);
|
||||
@ -31325,7 +31342,48 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
OpenVideo(form.VideoFileName);
|
||||
if (!string.IsNullOrEmpty(VideoFileName) && _videoInfo != null && _videoInfo.Width == 0 && _videoInfo.Height == 0)
|
||||
{
|
||||
// if audio only, then keep the current waveform/specgtrogram - but still load the new video
|
||||
|
||||
var peakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(VideoFileName);
|
||||
var spectrogramFolder = WavePeakGenerator.SpectrogramDrawer.GetSpectrogramFolder(VideoFileName);
|
||||
OpenVideo(form.VideoFileName);
|
||||
var newPeakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(VideoFileName);
|
||||
var newSpectrogramFolder = WavePeakGenerator.SpectrogramDrawer.GetSpectrogramFolder(VideoFileName);
|
||||
if (File.Exists(peakWaveFileName) && !File.Exists(newPeakWaveFileName))
|
||||
{
|
||||
timerWaveform.Stop();
|
||||
File.Copy(peakWaveFileName, newPeakWaveFileName);
|
||||
|
||||
foreach (var fileName in Directory.GetFiles(spectrogramFolder))
|
||||
{
|
||||
if (!Directory.Exists(newSpectrogramFolder))
|
||||
{
|
||||
Directory.CreateDirectory(newSpectrogramFolder);
|
||||
}
|
||||
|
||||
var dest = Path.Combine(newSpectrogramFolder, Path.GetFileName(fileName));
|
||||
if (!File.Exists(dest))
|
||||
{
|
||||
File.Copy(fileName, dest);
|
||||
}
|
||||
}
|
||||
|
||||
audioVisualizer.ZoomFactor = 1.0;
|
||||
audioVisualizer.VerticalZoomFactor = 1.0;
|
||||
SelectZoomTextInComboBox();
|
||||
audioVisualizer.WavePeaks = WavePeakData.FromDisk(newPeakWaveFileName);
|
||||
audioVisualizer.SetSpectrogram(SpectrogramData.FromDisk(newSpectrogramFolder));
|
||||
audioVisualizer.SceneChanges = new List<double>();
|
||||
SetWaveformPosition(0, 0, 0);
|
||||
timerWaveform.Start();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OpenVideo(form.VideoFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user