Skip to content

Commit

Permalink
FFMPEG Validation
Browse files Browse the repository at this point in the history
  • Loading branch information
saulhidalgoaular committed Apr 4, 2024
1 parent 2ecbb24 commit 412bbee
Show file tree
Hide file tree
Showing 2 changed files with 1,732 additions and 1,315 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
Expand Down Expand Up @@ -367,20 +368,11 @@ private void startVideoRecording()
{
try
{

final IPreferenceStore preferenceStore = CorePlugin.getDefault()
.getPreferenceStore();

final boolean recordingEnabled = preferenceStore.getBoolean(P_ENABLE);

if (!recordingEnabled)
if (screenRecorder != null)
{
return;
screenRecorder.start();
}

createScreenRecorder(preferenceStore);
screenRecorder.start();

}
catch (final Exception ee)
{
Expand Down Expand Up @@ -614,10 +606,10 @@ else if (DEBRIEF_S_WINDOW.equals(preferenceStore.getString(
else if (DEBRIEF_PLOT_WINDOW.equals(preferenceStore.getString(
P_SCREEN_AREA)))
{

}
return areaToRecord;

return areaToRecord;
}

/**
Expand Down Expand Up @@ -710,10 +702,80 @@ private void stopVideoRecording()
}
}

/**
* Creates the screen recorder, or makes sure to set it as null if the screen recording option
* is disabled.
*
* @throws IOException
* @throws AWTException
*/
public void createVideoRecorder() throws IOException, AWTException
{
final IPreferenceStore preferenceStore = CorePlugin.getDefault()
.getPreferenceStore();

final boolean recordingEnabled = preferenceStore.getBoolean(P_ENABLE);

if (!recordingEnabled)
{
screenRecorder = null;
return;
}

createScreenRecorder(preferenceStore);
}

public boolean validateFFMPEG()
{
if (screenRecorder == null)
{
// if the video recording is enabled, we don't need to check it
return true;
}

if (screenRecorder.conversionEnabled() && !screenRecorder
.validateFfmpeg())
{
// ffpmeg seems to be missing.
return false;
}

// We don't need a conversion.
return true;
}

private boolean isRecording = true;

@Override
public void widgetSelected(final SelectionEvent e)
{
final boolean isRecording = _recordButton.getSelection();
if (isRecording)
{
try
{
createVideoRecorder();

if (!validateFFMPEG())
{
throw new Exception(
"FFMPEG seems missing. Please go to the Preferences section,"
+ " inside Video Capture Preference, and Specify the path"
+ " to where the FFMPEG executable is located.");
}
}
catch (Exception e1)
{
final MessageBox messageBox = new MessageBox(getViewSite().getShell(),
SWT.ERROR | SWT.OK);
messageBox.setMessage(e1.getMessage());
messageBox.setText("Video Recording Exception");
messageBox.open();

e1.printStackTrace();
return;
}
}

_playing = false;
if (menu != null)
{
Expand All @@ -722,6 +784,7 @@ public void widgetSelected(final SelectionEvent e)

if (isRecording)
{

startPlaying();

setVCREnabled(false);
Expand Down Expand Up @@ -759,7 +822,7 @@ public void run()
});

stopPlaying();

if (isVideoRecording)
{
stopVideoRecording();
Expand All @@ -770,6 +833,9 @@ public void run()
stopPptxRecording(getTimeProvider().getTime());
}
}

// We change the state only if we ended successfully.
isRecording = !isRecording;
}
}

Expand Down

0 comments on commit 412bbee

Please sign in to comment.