[longomatch] Move remux step the ProjectsManager
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Move remux step the ProjectsManager
- Date: Sun, 10 Nov 2013 17:49:56 +0000 (UTC)
commit 64e2aba2a87145fadcc16f85c2d74dfebba13ff6
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sun Nov 10 18:48:07 2013 +0100
Move remux step the ProjectsManager
Do the remuxing in the Services side instead of the GUI side.
This also helps on doing the remux when the capturer and the player
are closed and the output file is not opened and can be safely
moved for the remux in Windows
LongoMatch.Core/Interfaces/GUI/ICapturer.cs | 2 +-
LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs | 2 +
LongoMatch.GUI.Multimedia/Gui/CapturerBin.cs | 46 +-----------------
LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs | 2 +
LongoMatch.GUI/Gui/GUIToolkit.cs | 6 ++
LongoMatch.Services/Services/ProjectsManager.cs | 50 ++++++++++++++++++--
6 files changed, 58 insertions(+), 50 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/GUI/ICapturer.cs b/LongoMatch.Core/Interfaces/GUI/ICapturer.cs
index 0dd159e..28d46be 100644
--- a/LongoMatch.Core/Interfaces/GUI/ICapturer.cs
+++ b/LongoMatch.Core/Interfaces/GUI/ICapturer.cs
@@ -31,7 +31,7 @@ namespace LongoMatch.Interfaces.GUI
string Logo {set;}
int CurrentTime {get;}
bool Capturing {get;}
- CaptureSettings CaptureProperties {set;}
+ CaptureSettings CaptureProperties {set; get;}
Image CurrentMiniatureFrame {get;}
void Start();
diff --git a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
index e6af4d1..0adb8d7 100644
--- a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
@@ -76,6 +76,8 @@ namespace LongoMatch.Interfaces.GUI
void TagPlay(Play play, Categories categories, TeamTemplate local, TeamTemplate visitor, bool
showAllTags);
void DrawingTool(Image pixbuf, Play play, int stopTime);
+
+ string RemuxFile (string filePath, string outputFile, VideoMuxerType muxer);
}
}
diff --git a/LongoMatch.GUI.Multimedia/Gui/CapturerBin.cs b/LongoMatch.GUI.Multimedia/Gui/CapturerBin.cs
index a65f951..597201e 100644
--- a/LongoMatch.GUI.Multimedia/Gui/CapturerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/CapturerBin.cs
@@ -111,6 +111,8 @@ namespace LongoMatch.Gui
public CaptureSettings CaptureProperties {
set {
captureProps = value;
+ } get {
+ return captureProps;
}
}
@@ -261,55 +263,11 @@ namespace LongoMatch.Gui
pausebutton.Visible = false;
stopbutton.Visible = false;
- if (capturerType == CapturerType.Live)
- RemuxOutputFile (captureProps.EncodingSettings);
-
if(CaptureFinished != null)
CaptureFinished(this, new EventArgs());
}
}
- void RemuxOutputFile (EncodingSettings settings) {
- VideoMuxerType muxer;
-
- /* We need to remux to the original format */
- muxer = settings.EncodingProfile.Muxer;
- if (muxer == VideoMuxerType.Avi || muxer == VideoMuxerType.Mp4) {
- string outFile = settings.OutputFile;
- string tmpFile = settings.OutputFile;
-
- while (System.IO.File.Exists (tmpFile)) {
- tmpFile = tmpFile + ".tmp";
- }
-
- try {
- System.IO.File.Move (outFile, tmpFile);
- } catch (Exception ex) {
- /* Try to fix "Sharing violation on path" in windows
- * wait a bit more until the file lock is released */
- Log.Exception (ex);
- System.Threading.Thread.Sleep (5 * 1000);
- try {
- System.IO.File.Move (outFile, tmpFile);
- } catch (Exception ex2) {
- Log.Exception (ex2);
- /* It failed again, just skip remuxing */
- return;
- }
- }
- Remuxer remuxer = new Remuxer(PreviewMediaFile.DiscoverFile(tmpFile),
- outFile, muxer);
-
- /* Remuxing suceed, delete old file */
- if (remuxer.Remux(this.Toplevel as Gtk.Window) == outFile) {
- System.IO.File.Delete (tmpFile);
- } else {
- System.IO.File.Delete (outFile);
- System.IO.File.Move (tmpFile, outFile);
- }
- }
- }
-
protected virtual void OnTick(int ellapsedTime) {
timelabel.Markup = String.Format("<span font=\"20px bold\">Time --> {0}</span> ",
TimeString.MSecondsToSecondsString(CurrentTime));
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
b/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
index 3be2392..6f13d35 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
@@ -137,6 +137,8 @@ namespace LongoMatch.Gui
set {
captureSettings = value;
capturerbin.CaptureProperties = value;
+ } get {
+ return captureSettings;
}
}
diff --git a/LongoMatch.GUI/Gui/GUIToolkit.cs b/LongoMatch.GUI/Gui/GUIToolkit.cs
index 638ff41..2c3c180 100644
--- a/LongoMatch.GUI/Gui/GUIToolkit.cs
+++ b/LongoMatch.GUI/Gui/GUIToolkit.cs
@@ -361,6 +361,12 @@ namespace LongoMatch.Gui
System.GC.Collect();
}
+ public string RemuxFile (string inputFile, string outputFile, VideoMuxerType muxer) {
+ Remuxer remuxer = new Remuxer (PreviewMediaFile.DiscoverFile(inputFile),
+ outputFile, muxer);
+ return remuxer.Remux (mainWindow as Gtk.Window);
+ }
+
}
}
diff --git a/LongoMatch.Services/Services/ProjectsManager.cs b/LongoMatch.Services/Services/ProjectsManager.cs
index 3df2c43..cc57c21 100644
--- a/LongoMatch.Services/Services/ProjectsManager.cs
+++ b/LongoMatch.Services/Services/ProjectsManager.cs
@@ -91,16 +91,56 @@ namespace LongoMatch.Services
OpenedProjectChanged(OpenedProject, OpenedProjectType, PlaysFilter);
}
+ void RemuxOutputFile (EncodingSettings settings) {
+ VideoMuxerType muxer;
+
+ /* We need to remux to the original format */
+ muxer = settings.EncodingProfile.Muxer;
+ if (muxer == VideoMuxerType.Avi || muxer == VideoMuxerType.Mp4) {
+ string outFile = settings.OutputFile;
+ string tmpFile = settings.OutputFile;
+
+ while (System.IO.File.Exists (tmpFile)) {
+ tmpFile = tmpFile + ".tmp";
+ }
+
+ Log.Debug ("Remuxing file tmp: " + tmpFile + " out: " + outFile);
+
+ try {
+ System.IO.File.Move (outFile, tmpFile);
+ } catch (Exception ex) {
+ /* Try to fix "Sharing violation on path" in windows
+ * wait a bit more until the file lock is released */
+ Log.Exception (ex);
+ System.Threading.Thread.Sleep (5 * 1000);
+ try {
+ System.IO.File.Move (outFile, tmpFile);
+ } catch (Exception ex2) {
+ Log.Exception (ex2);
+ /* It failed again, just skip remuxing */
+ return;
+ }
+ }
+
+ /* Remuxing suceed, delete old file */
+ if (guiToolkit.RemuxFile (tmpFile, outFile, muxer) == outFile) {
+ System.IO.File.Delete (tmpFile);
+ } else {
+ System.IO.File.Delete (outFile);
+ System.IO.File.Move (tmpFile, outFile);
+ }
+ }
+ }
+
private void SaveCaptureProject(Project project) {
string filePath = project.Description.File.FilePath;
- Log.Debug ("Saving capture project: " + project);
-
- /* FIXME: Show message */
- //guiToolkit.InfoMessage(Catalog.GetString("Loading newly created project..."));
-
/* scan the new file to build a new PreviewMediaFile with all the metadata */
try {
+ Log.Debug ("Saving capture project: " + project);
+
+ RemuxOutputFile (Capturer.CaptureProperties.EncodingSettings);
+
Log.Debug("Reloading saved file: " + filePath);
project.Description.File = multimediaToolkit.DiscoverFile(filePath);
foreach (Play play in project.AllPlays ()) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]