Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpacifico authored Sep 12, 2024
1 parent 82755df commit fb206e7
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 15 deletions.
21 changes: 19 additions & 2 deletions src/application/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public class Settings {
private JLabel lblScaleMode = new JLabel(Shutter.language.getProperty("lblScaleMode"));
public static JComboBox<String> comboScale = new JComboBox<String>(new String [] {"fast_bilinear", "bilinear", "bicubic", "neighbor", "area", "gauss", "sinc", "lanczos", "spline"});
public static JCheckBox btnNoUpscale = new JCheckBox(Shutter.language.getProperty("btnNoUpscale"));
public static JCheckBox btnPreviewOutput = new JCheckBox(Shutter.language.getProperty("btnPreviewOutput"));
private JLabel lblSyncMode = new JLabel(Shutter.language.getProperty("lblSyncMode"));
public static JComboBox<String> comboSync = new JComboBox<String>(new String [] {"auto", "passthrough", "cfr", "vfr", "drop"});
private JLabel lblLanguage = new JLabel(Shutter.language.getProperty("lblLanguage"));
Expand Down Expand Up @@ -153,6 +154,7 @@ public Settings() {
btnLoadPreset.setName("btnLoadPreset");
comboLoadPreset.setName("comboLoadPreset");
btnNoUpscale.setName("btnNoUpscale");
btnPreviewOutput.setName("btnPreviewOutput");
btnWaitFileComplete.setName("btnWaitFileComplete");
btnDisableAnimations.setName("btnDisableAnimations");
btnDisableSound.setName("btnDisableSound");
Expand All @@ -172,7 +174,7 @@ public Settings() {
txtImageDuration.setName("txtImageDuration");
comboLanguage.setName("comboLanguage");

frame.setSize(370, 720);
frame.setSize(370, 740);
if (Shutter.getLanguage.equals(Locale.of("ru").getDisplayLanguage()) || Shutter.getLanguage.equals(Locale.of("uk").getDisplayLanguage()))
{
frame.setSize(frame.getWidth() + 30, frame.getHeight());
Expand Down Expand Up @@ -478,8 +480,23 @@ public void actionPerformed(ActionEvent arg0) {

});

btnPreviewOutput.setFont(new Font(Shutter.freeSansFont, Font.PLAIN, 12));
btnPreviewOutput.setBounds(12, btnNoUpscale.getLocation().y + btnNoUpscale.getHeight() + 10, btnPreviewOutput.getPreferredSize().width, 16);
frame.getContentPane().add(btnPreviewOutput);

btnPreviewOutput.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {

VideoPlayer.playerSetTime(VideoPlayer.playerCurrentFrame); //Use VideoPlayer.resizeAll and reload the frame
VideoPlayer.resizeAll();
}

});

lblScaleMode.setFont(new Font(Shutter.freeSansFont, Font.PLAIN, 12));
lblScaleMode.setBounds(12, btnNoUpscale.getLocation().y + btnNoUpscale.getHeight() + 10, lblScaleMode.getPreferredSize().width, 16);
lblScaleMode.setBounds(12, btnPreviewOutput.getLocation().y + btnPreviewOutput.getHeight() + 10, lblScaleMode.getPreferredSize().width, 16);
frame.getContentPane().add(lblScaleMode);

comboScale.setFont(new Font(Shutter.freeSansFont, Font.PLAIN, 10));
Expand Down
42 changes: 37 additions & 5 deletions src/application/Shutter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3093,11 +3093,23 @@ public void actionPerformed(ActionEvent e) {
FFMPEG.writer.close();
} catch (IOException er) {}

do {
try {
Thread.sleep(10);
} catch (InterruptedException e1) {}
} while (FFMPEG.runProcess.isAlive());
Thread wait = new Thread(new Runnable() {

@Override
public void run() {

do {
try {
frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
btnStart.setEnabled(false);
Thread.sleep(10);
} catch (InterruptedException e1) {}
} while (FFMPEG.runProcess.isAlive());

frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
});
wait.start();
}

if (DCRAW.runProcess != null)
Expand Down Expand Up @@ -16840,6 +16852,20 @@ public void componentHidden ( ComponentEvent e )
debitVideo.setBounds(92, textH.getY() + textH.getHeight() + 5, 93, 22);
grpBitrate.add(debitVideo);

debitVideo.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent ac) {

if (Settings.btnPreviewOutput.isSelected() && VideoEncoders.setCodec() != "")
{
VideoPlayer.playerSetTime(VideoPlayer.playerCurrentFrame); //Use VideoPlayer.resizeAll and reload the frame
VideoPlayer.resizeAll();
}
}

});

lblKbsH264 = new JLabel("kb/s");
lblKbsH264.setFont(new Font(freeSansFont, Font.PLAIN, 12));
lblKbsH264.setBounds(188, debitVideo.getY() + 3, 33, 16);
Expand Down Expand Up @@ -17109,6 +17135,12 @@ public void actionPerformed(ActionEvent arg0) {
caseForcePreset.setEnabled(true);
}
}

if (Settings.btnPreviewOutput.isSelected() && VideoEncoders.setCodec() != "")
{
VideoPlayer.playerSetTime(VideoPlayer.playerCurrentFrame); //Use VideoPlayer.resizeAll and reload the frame
VideoPlayer.resizeAll();
}
}

});
Expand Down
45 changes: 39 additions & 6 deletions src/application/VideoPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@

import com.formdev.flatlaf.extras.FlatSVGIcon;

import functions.VideoEncoders;
import library.DCRAW;
import library.FFMPEG;
import library.FFPROBE;
Expand Down Expand Up @@ -153,6 +154,7 @@ public class VideoPlayer {
private static boolean previewUpscale = false;
public static boolean fullscreenPlayer = false;
private static Thread mouseClickThread;
private static String freezeFrame = "";

//Buttons & Checkboxes
public static JLabel btnPreview;
Expand Down Expand Up @@ -891,8 +893,8 @@ public static void playerRepaint() {
}

public static boolean playerIsPlaying() {
if (playerVideo != null && playerVideo.isAlive() && btnPlay.getName().equals("pause"))

if (btnPlay.getName().equals("pause"))
{
return true;
}
Expand All @@ -901,7 +903,7 @@ public static boolean playerIsPlaying() {
}

public static void playerSetTime(float time) {

if ((setTime == null || setTime.isAlive() == false) && (frameVideo != null || playerCurrentFrame > 0) && playerThread != null && Shutter.doNotLoadImage == false && time < totalFrames - 2 && videoPath != null)
{
setTime = new Thread(new Runnable() {
Expand All @@ -922,7 +924,7 @@ public void run() {
{
preview = null;
}
else if (FFPROBE.audioOnly == false && (mouseIsPressed || frameControl) && playerIsPlaying() == false && playerCurrentFrame != time && (Timecode.isNonDropFrame() == false || mouseIsPressed))
else if (FFPROBE.audioOnly == false && (mouseIsPressed || frameControl) && playerIsPlaying() == false && playerCurrentFrame != time && (Timecode.isNonDropFrame() == false || mouseIsPressed) && freezeFrame == "")
{
useBuffer = true;
}
Expand Down Expand Up @@ -1061,7 +1063,7 @@ else if (framesToSkip != 0 || (framesToSkip == 0 && mouseIsPressed == false)) //
}

} while (frameIsComplete == false);

if (playback && mouseIsPressed == false)
{
playerLoop = true;
Expand Down Expand Up @@ -1892,6 +1894,10 @@ public static String setVideoCommand(float inputTime, int width, int height, boo

//Deinterlacer
String yadif = AdvancedFeatures.setDeinterlace(true);
if (mouseIsPressed)
{
yadif = "";
}

//Speed slider
String speed = "";
Expand Down Expand Up @@ -1989,9 +1995,36 @@ else if (System.getProperty("os.name").contains("Mac"))
}

String extension = videoPath.substring(videoPath.lastIndexOf("."));

int framesToSkip = (int) ((float) slider.getValue() - playerCurrentFrame);

String cmd = gpuDecoding + Colorimetry.setInputCodec(extension) + " -strict -2 -v quiet -hide_banner -ss " + (long) (inputTime * inputFramerateMS) + "ms" + concat + " -i " + '"' + video + '"' + setFilter(yadif, speed, false) + " -r " + FFPROBE.currentFPS + " -c:v bmp -an -f image2pipe -";
if (mouseIsPressed && (framesToSkip > 60 || framesToSkip < 0))
{
freezeFrame = " -frames:v 1";
}
else
freezeFrame = "";

String codec = "";
if (Settings.btnPreviewOutput.isSelected() && VideoEncoders.setCodec() != ""
&& Shutter.comboFonctions.getSelectedItem().toString().equals("DNxHD") == false
&& Shutter.comboFonctions.getSelectedItem().toString().equals("DVD") == false
&& Shutter.comboFonctions.getSelectedItem().toString().equals("QT Animation") == false
&& Shutter.comboFonctions.getSelectedItem().toString().equals("GoPro CineForm") == false
&& Shutter.comboFonctions.getSelectedItem().toString().equals("AVC-Intra 100") == false)
{
String format = "matroska";

if (Shutter.comboFonctions.getSelectedItem().toString().equals("XAVC"))
{
format = "mxf";
}

codec = VideoEncoders.setCodec() + VideoEncoders.setBitrate() + AdvancedFeatures.setPreset() + freezeFrame + " -an -f " + format + " pipe:1 | " + PathToFFMPEG + " -v quiet -hide_banner -i pipe:0";
}

String cmd = gpuDecoding + Colorimetry.setInputCodec(extension) + " -strict -2 -v quiet -hide_banner -ss " + (long) (inputTime * inputFramerateMS) + "ms" + concat + " -i " + '"' + video + '"' + setFilter(yadif, speed, false) + " -r " + FFPROBE.currentFPS + codec + freezeFrame + " -c:v bmp -an -f image2pipe -";

if (Shutter.inputDeviceIsRunning)
{
cmd = " -strict -2 -v quiet -hide_banner " + RecordInputDevice.setInputDevices() + setFilter(yadif, speed, false) + " -c:v bmp -an -f image2pipe -";
Expand Down
4 changes: 2 additions & 2 deletions src/functions/VideoEncoders.java
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ else if (comboResolution.getSelectedItem().toString().contains("x"))

}

private static String setCodec() {
public static String setCodec() {

switch (comboFonctions.getSelectedItem().toString())
{
Expand Down Expand Up @@ -1655,7 +1655,7 @@ else if ("H.266".equals(comboFonctions.getSelectedItem().toString()))
return "";
}

private static String setBitrate() {
public static String setBitrate() {

FunctionUtils.setVideoBitrate();

Expand Down

0 comments on commit fb206e7

Please sign in to comment.