diff --git a/src/application/Settings.java b/src/application/Settings.java index 1fc207c4..a5397858 100644 --- a/src/application/Settings.java +++ b/src/application/Settings.java @@ -39,6 +39,7 @@ import java.awt.event.AdjustmentListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; @@ -130,6 +131,8 @@ public class Settings { public static JCheckBox btnDisableVideoPlayer = new JCheckBox(Shutter.language.getProperty("btnDisableVideoPlayer")); public static JCheckBox btnDisableMinimizedWindow = new JCheckBox(Shutter.language.getProperty("btnDisableMinimizedWindow")); public static JTextField txtExclude = new JTextField(); + public static JCheckBox btnCustomFFmpegPath = new JCheckBox(Shutter.language.getProperty("btnCustomFFmpegPath")); + public static JTextField txtCustomFFmpegPath = new JTextField(); private JLabel defaultOutput1 = new JLabel(Shutter.language.getProperty("output") + "1 " + Shutter.language.getProperty("toDefault")); private JLabel defaultOutput2 = new JLabel(Shutter.language.getProperty("output") + "2 " + Shutter.language.getProperty("toDefault")); private JLabel defaultOutput3 = new JLabel(Shutter.language.getProperty("output") + "3 " + Shutter.language.getProperty("toDefault")); @@ -160,6 +163,8 @@ public Settings() { btnDisableVideoPlayer.setName("btnDisableVideoPlayer"); btnDisableMinimizedWindow.setName("btnDisableMinimizedWindow"); btnEmptyListAtEnd.setName("btnEmptyListAtEnd"); + btnCustomFFmpegPath.setName("btnCustomFFmpegPath"); + txtCustomFFmpegPath.setName("txtCustomFFmpegPath"); lblDestination1.setName("lblDestination1"); lblDestination2.setName("lblDestination2"); lblDestination3.setName("lblDestination3"); @@ -172,10 +177,10 @@ public Settings() { txtImageDuration.setName("txtImageDuration"); comboLanguage.setName("comboLanguage"); - frame.setSize(370, 722); + frame.setSize(370, 742); if (Shutter.getLanguage.equals(Locale.of("ru").getDisplayLanguage()) || Shutter.getLanguage.equals(Locale.of("uk").getDisplayLanguage())) { - frame.setSize(frame.getWidth() + 30, frame.getHeight()); + frame.setSize(frame.getWidth() + 50, frame.getHeight()); } frame.getContentPane().setBackground(new Color(30,30,35)); @@ -340,6 +345,7 @@ public void actionPerformed(ActionEvent arg0) { @Override public void actionPerformed(ActionEvent arg0) { + if (btnExclude.isSelected()) { txtExclude.setEnabled(true); @@ -463,8 +469,116 @@ public void actionPerformed(ActionEvent arg0) { comboAction.setEnabled(false); frame.getContentPane().add(comboAction); + btnCustomFFmpegPath.setFont(new Font(Shutter.freeSansFont, Font.PLAIN, 12)); + btnCustomFFmpegPath.setBounds(12, btnEndingAction.getLocation().y + btnEndingAction.getHeight() + 10, btnCustomFFmpegPath.getPreferredSize().width, 16); + frame.getContentPane().add(btnCustomFFmpegPath); + + btnCustomFFmpegPath.addActionListener(new ActionListener(){ + + @Override + public void actionPerformed(ActionEvent arg0) { + + if (btnCustomFFmpegPath.isSelected()) + { + txtCustomFFmpegPath.setEnabled(true); + + if (Settings.txtCustomFFmpegPath.getText().equals("") == false) + { + VideoPlayer.PathToFFMPEG = Settings.txtCustomFFmpegPath.getText(); + } + } + else + { + txtCustomFFmpegPath.setEnabled(false); + + VideoPlayer.PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + + if (System.getProperty("os.name").contains("Windows")) + { + VideoPlayer.PathToFFMPEG = VideoPlayer.PathToFFMPEG.substring(1,VideoPlayer.PathToFFMPEG.length()-1); + VideoPlayer.PathToFFMPEG = VideoPlayer.PathToFFMPEG.substring(0,(int) (VideoPlayer.PathToFFMPEG.lastIndexOf("/"))).replace("%20", " ") + "\\Library\\ffmpeg.exe"; + } + else + { + VideoPlayer.PathToFFMPEG = VideoPlayer.PathToFFMPEG.substring(0,VideoPlayer.PathToFFMPEG.length()-1); + VideoPlayer.PathToFFMPEG = VideoPlayer.PathToFFMPEG.substring(0,(int) (VideoPlayer.PathToFFMPEG.lastIndexOf("/"))).replace("%20", "\\ ") + "/Library/ffmpeg"; + } + } + + if (VideoPlayer.videoPath != null) + { + VideoPlayer.btnStop.doClick(); + } + } + }); + + txtCustomFFmpegPath.setFont(new Font(Shutter.freeSansFont, Font.PLAIN, 12)); + + if (btnCustomFFmpegPath.isSelected()) + { + txtCustomFFmpegPath.setEnabled(true); + } + else + txtCustomFFmpegPath.setEnabled(false); + + txtCustomFFmpegPath.setText("/usr/bin/ffmpeg"); + txtCustomFFmpegPath.setBounds(btnCustomFFmpegPath.getX() + btnCustomFFmpegPath.getWidth() + 6, btnCustomFFmpegPath.getLocation().y - 4, frame.getWidth() - (btnCustomFFmpegPath.getLocation().x + btnCustomFFmpegPath.getWidth()) - 32, 21); + frame.getContentPane().add(txtCustomFFmpegPath); + + txtCustomFFmpegPath.addKeyListener(new KeyListener() { + + @Override + public void keyPressed(KeyEvent arg0) { + } + + @Override + public void keyReleased(KeyEvent e) { + + if (txtCustomFFmpegPath.getText().length() > 0 && e.getKeyCode() == KeyEvent.VK_ENTER) + { + if (btnCustomFFmpegPath.isSelected()) + { + txtCustomFFmpegPath.setEnabled(true); + + if (Settings.txtCustomFFmpegPath.getText().equals("") == false) + { + VideoPlayer.PathToFFMPEG = Settings.txtCustomFFmpegPath.getText(); + } + } + else + { + txtCustomFFmpegPath.setEnabled(false); + + VideoPlayer.PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + + if (System.getProperty("os.name").contains("Windows")) + { + VideoPlayer.PathToFFMPEG = VideoPlayer.PathToFFMPEG.substring(1,VideoPlayer.PathToFFMPEG.length()-1); + VideoPlayer.PathToFFMPEG = VideoPlayer.PathToFFMPEG.substring(0,(int) (VideoPlayer.PathToFFMPEG.lastIndexOf("/"))).replace("%20", " ") + "\\Library\\ffmpeg.exe"; + } + else + { + VideoPlayer.PathToFFMPEG = VideoPlayer.PathToFFMPEG.substring(0,VideoPlayer.PathToFFMPEG.length()-1); + VideoPlayer.PathToFFMPEG = VideoPlayer.PathToFFMPEG.substring(0,(int) (VideoPlayer.PathToFFMPEG.lastIndexOf("/"))).replace("%20", "\\ ") + "/Library/ffmpeg"; + } + } + + if (VideoPlayer.videoPath != null) + { + VideoPlayer.btnStop.doClick(); + } + } + + } + + @Override + public void keyTyped(KeyEvent arg0) { + } + + }); + btnPreviewOutput.setFont(new Font(Shutter.freeSansFont, Font.PLAIN, 12)); - btnPreviewOutput.setBounds(12, btnEndingAction.getLocation().y + btnEndingAction.getHeight() + 10, btnPreviewOutput.getPreferredSize().width, 16); + btnPreviewOutput.setBounds(12, btnCustomFFmpegPath.getLocation().y + btnCustomFFmpegPath.getHeight() + 10, btnPreviewOutput.getPreferredSize().width, 16); frame.getContentPane().add(btnPreviewOutput); btnPreviewOutput.addActionListener(new ActionListener() { @@ -1656,6 +1770,12 @@ else if (eElement.getElementsByTagName("Name").item(0).getFirstChild().getTextCo { videoWebCaseMetadata = Boolean.valueOf(eElement.getElementsByTagName("Value").item(0).getFirstChild().getTextContent()); } + + //customFFmpeg + if (btnCustomFFmpegPath.isSelected() && txtCustomFFmpegPath.getText().equals("") == false) + { + VideoPlayer.PathToFFMPEG = txtCustomFFmpegPath.getText(); + } } } } diff --git a/src/application/Shutter.java b/src/application/Shutter.java index 0832429c..9d524ab2 100644 --- a/src/application/Shutter.java +++ b/src/application/Shutter.java @@ -12140,9 +12140,8 @@ public void actionPerformed(ActionEvent arg0) { JLabel watermarkTopLeft = new JLabel("\u2196"); watermarkTopLeft.setName("watermarkTopLeft"); - watermarkTopLeft.setBackground(new Color(42,42,47)); + watermarkTopLeft.setBackground(new Color(42,42,47,0)); watermarkTopLeft.setHorizontalAlignment(SwingConstants.CENTER); - watermarkTopLeft.setOpaque(true); watermarkTopLeft.setFont(new Font(freeSansFont, Font.PLAIN, 12)); watermarkTopLeft.setSize(28, 16); watermarkTopLeft.setLocation(grpWatermark.getWidth() / 2 - 270 / 2, caseAddWatermark.getY() + caseAddWatermark.getHeight() + 2); @@ -12150,19 +12149,17 @@ public void actionPerformed(ActionEvent arg0) { JLabel watermarkLeft = new JLabel("\u2190"); watermarkLeft.setName("watermarkLeft"); - watermarkLeft.setBackground(new Color(42,42,47)); + watermarkLeft.setBackground(new Color(42,42,47,0)); watermarkLeft.setHorizontalAlignment(SwingConstants.CENTER); - watermarkLeft.setOpaque(true); watermarkLeft.setFont(new Font(freeSansFont, Font.PLAIN, 12)); watermarkLeft.setSize(watermarkTopLeft.getSize()); - watermarkLeft.setLocation(watermarkTopLeft.getX() + watermarkTopLeft.getWidth() + 2, watermarkTopLeft.getY()); + watermarkLeft.setLocation(watermarkTopLeft.getX() + watermarkTopLeft.getWidth() + 2, watermarkTopLeft.getY() - 2); grpWatermark.add(watermarkLeft); JLabel watermarkBottomLeft = new JLabel("\u2199"); watermarkBottomLeft.setName("watermarkBottomLeft"); - watermarkBottomLeft.setBackground(new Color(42,42,47)); + watermarkBottomLeft.setBackground(new Color(42,42,47,0)); watermarkBottomLeft.setHorizontalAlignment(SwingConstants.CENTER); - watermarkBottomLeft.setOpaque(true); watermarkBottomLeft.setFont(new Font(freeSansFont, Font.PLAIN, 12)); watermarkBottomLeft.setSize(watermarkTopLeft.getSize()); watermarkBottomLeft.setLocation(watermarkLeft.getX() + watermarkLeft.getWidth() + 2, watermarkTopLeft.getY()); @@ -12170,9 +12167,8 @@ public void actionPerformed(ActionEvent arg0) { JLabel watermarkTop = new JLabel("\u2191"); watermarkTop.setName("watermarkTop"); - watermarkTop.setBackground(new Color(42,42,47)); + watermarkTop.setBackground(new Color(42,42,47,0)); watermarkTop.setHorizontalAlignment(SwingConstants.CENTER); - watermarkTop.setOpaque(true); watermarkTop.setFont(new Font(freeSansFont, Font.PLAIN, 12)); watermarkTop.setSize(watermarkTopLeft.getSize()); watermarkTop.setLocation(watermarkBottomLeft.getX() + watermarkBottomLeft.getWidth() + 2, watermarkTopLeft.getY()); @@ -12180,19 +12176,17 @@ public void actionPerformed(ActionEvent arg0) { JLabel watermarkCenter = new JLabel("\u2500"); watermarkCenter.setName("watermarkCenter"); - watermarkCenter.setBackground(new Color(42,42,47)); + watermarkCenter.setBackground(new Color(42,42,47,0)); watermarkCenter.setHorizontalAlignment(SwingConstants.CENTER); - watermarkCenter.setOpaque(true); watermarkCenter.setFont(new Font(freeSansFont, Font.PLAIN, 12)); watermarkCenter.setSize(watermarkTopLeft.getSize()); - watermarkCenter.setLocation(watermarkTop.getX() + watermarkTop.getWidth() + 2, watermarkTopLeft.getY()); + watermarkCenter.setLocation(watermarkTop.getX() + watermarkTop.getWidth() + 2, watermarkTopLeft.getY() - 1); grpWatermark.add(watermarkCenter); JLabel watermarkBottom = new JLabel("\u2193"); watermarkBottom.setName("watermarkBottom"); - watermarkBottom.setBackground(new Color(42,42,47)); + watermarkBottom.setBackground(new Color(42,42,47,0)); watermarkBottom.setHorizontalAlignment(SwingConstants.CENTER); - watermarkBottom.setOpaque(true); watermarkBottom.setFont(new Font(freeSansFont, Font.PLAIN, 12)); watermarkBottom.setSize(watermarkTopLeft.getSize()); watermarkBottom.setLocation(watermarkCenter.getX() + watermarkCenter.getWidth() + 2, watermarkTopLeft.getY()); @@ -12200,9 +12194,8 @@ public void actionPerformed(ActionEvent arg0) { JLabel watermarkTopRight = new JLabel("\u2197"); watermarkTopRight.setName("watermarkTopRight"); - watermarkTopRight.setBackground(new Color(42,42,47)); + watermarkTopRight.setBackground(new Color(42,42,47,0)); watermarkTopRight.setHorizontalAlignment(SwingConstants.CENTER); - watermarkTopRight.setOpaque(true); watermarkTopRight.setFont(new Font(freeSansFont, Font.PLAIN, 12)); watermarkTopRight.setSize(watermarkTopLeft.getSize()); watermarkTopRight.setLocation(watermarkBottom.getX() + watermarkBottom.getWidth() + 2, watermarkTopLeft.getY()); @@ -12210,19 +12203,17 @@ public void actionPerformed(ActionEvent arg0) { JLabel watermarkRight = new JLabel("\u2192"); watermarkRight.setName("watermarkRight"); - watermarkRight.setBackground(new Color(42,42,47)); + watermarkRight.setBackground(new Color(42,42,47,0)); watermarkRight.setHorizontalAlignment(SwingConstants.CENTER); - watermarkRight.setOpaque(true); watermarkRight.setFont(new Font(freeSansFont, Font.PLAIN, 12)); watermarkRight.setSize(watermarkTopLeft.getSize()); - watermarkRight.setLocation(watermarkTopRight.getX() + watermarkTopRight.getWidth() + 2, watermarkTopLeft.getY()); + watermarkRight.setLocation(watermarkTopRight.getX() + watermarkTopRight.getWidth() + 2, watermarkTopLeft.getY() - 2); grpWatermark.add(watermarkRight); JLabel watermarkBottomRight = new JLabel("\u2198"); watermarkBottomRight.setName("watermarkBottomRight"); - watermarkBottomRight.setBackground(new Color(42,42,47)); + watermarkBottomRight.setBackground(new Color(42,42,47,0)); watermarkBottomRight.setHorizontalAlignment(SwingConstants.CENTER); - watermarkBottomRight.setOpaque(true); watermarkBottomRight.setFont(new Font(freeSansFont, Font.PLAIN, 12)); watermarkBottomRight.setSize(watermarkTopLeft.getSize()); watermarkBottomRight.setLocation(watermarkRight.getX() + watermarkRight.getWidth() + 2, watermarkTopLeft.getY()); @@ -12265,6 +12256,23 @@ public void mouseReleased(MouseEvent arg0) { watermarkRight.addMouseListener(watermarkPositions); watermarkBottomRight.addMouseListener(watermarkPositions); + JPanel panelForButtons = new JPanel() { + + @Override + public void paintComponent(Graphics g) { + + Graphics2D g2d = (Graphics2D) g; + + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + g2d.setColor(new Color(42,42,47)); + g2d.fillRoundRect(0, 0, (watermarkBottomRight.getX() + watermarkBottomRight.getWidth()) - watermarkTopLeft.getX() + 4, 18, 15, 15); + } + + }; + panelForButtons.setBounds(watermarkTopLeft.getX() - 2, watermarkTopLeft.getY() - 2, (watermarkBottomRight.getX() + watermarkBottomRight.getWidth()) - watermarkTopLeft.getX() + 4, 18); + grpWatermark.add(panelForButtons); + JLabel watermarkPosX = new JLabel(Shutter.language.getProperty("posX")); watermarkPosX.setHorizontalAlignment(SwingConstants.RIGHT); watermarkPosX.setEnabled(false); @@ -19504,6 +19512,7 @@ private static void setGPUOptions() { if ("Apple ProRes".equals(function) && System.getProperty("os.name").contains("Mac") && arch.equals("arm64") || "H.264".equals(function) || "H.265".equals(function) || "H.266".equals(function) || "AV1".equals(function) || System.getProperty("os.name").contains("Windows") && "VP9".equals(function) + || System.getProperty("os.name").contains("Windows") && "FFV1".equals(function) || System.getProperty("os.name").contains("Windows") && language.getProperty("functionPicture").equals(function) && comboFilter.getSelectedItem().toString().equals(".avif")) { lblHWaccel.setVisible(true); @@ -20112,6 +20121,48 @@ else if (language.getProperty("functionInsert").equals(function)) comboFilter.setModel(model); } + //HWaccel + if (action && System.getProperty("os.name").contains("Windows") && "FFV1".equals(function)) + { + Thread hwaccel = new Thread(new Runnable() { + + @Override + public void run() { + + comboAccel.setEnabled(false); + + try { + + FFMPEG.hwaccel("-f lavfi -i nullsrc -t 1 -c:v ffv1_vulkan -s 640x360 -f null -" + '"'); + do { + Thread.sleep(10); + } while (FFMPEG.runProcess.isAlive()); + + if (FFMPEG.error == false) + graphicsAccel.add("Vulkan Video"); + + if (comboAccel.getModel().getSize() != graphicsAccel.size()) + { + comboAccel.setModel(new DefaultComboBoxModel(graphicsAccel.toArray())); + } + + //load hwaccel value after checking gpu capabilities + if (Utils.loadEncFile != null && Utils.hwaccel != "") + { + comboAccel.setSelectedItem(Utils.hwaccel); + } + + } catch (Exception e) {} + + if (comboAccel.getItemCount() > 1) + comboAccel.setEnabled(true); + } + + }); + hwaccel.start(); + + } + //grpSetAudio grpSetAudio.removeAll(); grpSetAudio.add(caseNormalizeAudio); diff --git a/src/application/Utils.java b/src/application/Utils.java index f0594843..489c7ae8 100644 --- a/src/application/Utils.java +++ b/src/application/Utils.java @@ -1997,10 +1997,10 @@ public static void loadThemes() { UIManager.put("ScrollBar.thumbArc", 999); UIManager.put("Button.arc", 15); UIManager.put("CheckBox.arc", 15); - UIManager.put("TextField.arc", 10); - UIManager.put("ProgressBar.arc", 10); - UIManager.put("TextComponent.arc", 10); - UIManager.put("Component.arc", 10); + UIManager.put("TextField.arc", 15); + UIManager.put("ProgressBar.arc", 15); + UIManager.put("TextComponent.arc", 15); + UIManager.put("Component.arc", 15); UIManager.put("PopupMenu.arc", 15); UIManager.put("ScrollPane.arc", 5); @@ -2082,7 +2082,9 @@ public static void loadThemes() { UIManager.put("MenuBar.foreground", new Color(235,235,240)); UIManager.put("PopupMenu.border", BorderFactory.createLineBorder(new Color(30,30,35))); + UIManager.put("PopupMenu.borderColor", new Color(30,30,35)); UIManager.put("PopupMenu.background", new Color(42,42,47)); + UIManager.put("PopupMenu.borderCornerRadius", 15); UIManager.put("Panel.selectionForeground", Color.WHITE); UIManager.put("TextPane.selectionForeground", Color.WHITE); diff --git a/src/application/VideoPlayer.java b/src/application/VideoPlayer.java index 719af7c4..f1288d1c 100644 --- a/src/application/VideoPlayer.java +++ b/src/application/VideoPlayer.java @@ -237,6 +237,11 @@ public VideoPlayer() { PathToFFMPEG = PathToFFMPEG.substring(0,PathToFFMPEG.length()-1); PathToFFMPEG = PathToFFMPEG.substring(0,(int) (PathToFFMPEG.lastIndexOf("/"))).replace("%20", "\\ ") + "/Library/ffmpeg"; } + + if (Settings.btnCustomFFmpegPath.isSelected() && Settings.txtCustomFFmpegPath.getText().equals("") == false) + { + PathToFFMPEG = Settings.txtCustomFFmpegPath.getText(); + } GraphicsConfiguration config = Shutter.frame.getGraphicsConfiguration(); GraphicsDevice myScreen = config.getDevice(); @@ -638,6 +643,7 @@ public static void playerProcess(float inputTime) { //Avoid a crashing issue try { audio = playerAudio.getInputStream(); + audioInputStream = null; audioInputStream = AudioSystem.getAudioInputStream(audio); AudioFormat audioFormat = audioInputStream.getFormat(); DataLine.Info info = new DataLine.Info(SourceDataLine.class,audioFormat); @@ -646,9 +652,7 @@ public static void playerProcess(float inputTime) { line.open(audioFormat); gainControl = (FloatControl) line.getControl(FloatControl.Type.MASTER_GAIN); line.start(); - } catch (Exception e) { - btnStop.doClick(); - } + } catch (Exception e) {} } playerThread = new Thread(new Runnable() { @@ -675,11 +679,11 @@ public void run() { long startTime = System.nanoTime() + (int) ((float) inputFramerateMS * 1000000); if (playerLoop) - { + { try { //Audio volume - if ((casePlaySound.isSelected() && inputTime > 0) || (sliderChange == false && frameControl == false)) + if (audioInputStream != null && ((casePlaySound.isSelected() && inputTime > 0) || (sliderChange == false && frameControl == false))) { closeAudioStream = true; double gain = (double) sliderVolume.getValue() / 100; @@ -752,7 +756,7 @@ else if (playerPlayVideo) } } else - { + { if (line!= null && closeAudioStream && sliderChange == false && frameControl == false) { line.flush(); @@ -774,7 +778,7 @@ else if (playerPlayVideo) videoInputStream.close(); } catch (IOException e) {} - if (audio != null && closeAudioStream) + if (audio != null && audioInputStream != null && closeAudioStream) { try { audio.close(); @@ -2466,7 +2470,7 @@ public void actionPerformed(ActionEvent e) { } else if (btnPlay.getName().equals("play")) - { + { if (bufferedFrames.size() > 0 || preview != null || Shutter.caseAddSubtitles.isSelected() || previousFrame) { if (bufferedFrames.size() > 0 || preview != null || Shutter.caseAddSubtitles.isSelected()) diff --git a/src/functions/VideoEncoders.java b/src/functions/VideoEncoders.java index ecc15d69..a362c9ce 100644 --- a/src/functions/VideoEncoders.java +++ b/src/functions/VideoEncoders.java @@ -1471,7 +1471,13 @@ else if (comboAccel.getSelectedItem().equals(language.getProperty("aucune").toLo case "FFV1": - return " -c:v ffv1 -level 3"; + if (comboAccel.getSelectedItem().equals(language.getProperty("aucune").toLowerCase()) == false) + { + if (comboAccel.getSelectedItem().equals("Vulkan Video")) + return " -c:v ffv1_vulkan"; + } + else + return " -c:v ffv1 -level 3"; case "GoPro CineForm": diff --git a/src/library/FFMPEG.java b/src/library/FFMPEG.java index dd924286..85d797a1 100644 --- a/src/library/FFMPEG.java +++ b/src/library/FFMPEG.java @@ -193,15 +193,11 @@ else if (caseChangeFolder2.isSelected()) public void run() { try { - String PathToFFMPEG; + ProcessBuilder processFFMPEG; if (System.getProperty("os.name").contains("Windows")) - { - PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath(); - PathToFFMPEG = PathToFFMPEG.substring(1,PathToFFMPEG.length()-1); - PathToFFMPEG = PathToFFMPEG.substring(0,(int) (PathToFFMPEG.lastIndexOf("/"))).replace("%20", " ") + "\\Library\\ffmpeg.exe"; - + { if (cmd.contains("image2pipe") || cmd.contains("pipe:1") || cmd.contains("vidstabdetect") || cmd.contains("60000/1001") || cmd.contains("30000/1001") || cmd.contains("24000/1001") || caseEnableColorimetry.isSelected() && Colorimetry.setEQ(true) != "" || caseLUTs.isSelected() && grpColorimetry.isVisible() @@ -211,31 +207,39 @@ public void run() { String pipe = ""; if (cmd.contains("pipe:1")) { - pipe = " | " + '"' + PathToFFMPEG + '"' + " -strict -2 -v quiet -i pipe:0 -an -c:v bmp -f image2pipe -"; + pipe = " | " + '"' + VideoPlayer.PathToFFMPEG + '"' + " -strict -2 -v quiet -i pipe:0 -an -c:v bmp -f image2pipe -"; } - PathToFFMPEG = "Library\\ffmpeg.exe"; - process = Runtime.getRuntime().exec(new String[]{"cmd.exe" , "/c", PathToFFMPEG + " -strict -2 -hide_banner -threads " + Settings.txtThreads.getText() + " " + cmd.replace("PathToFFMPEG", PathToFFMPEG) + pipe}); + VideoPlayer.PathToFFMPEG = "Library\\ffmpeg.exe"; + process = Runtime.getRuntime().exec(new String[]{"cmd.exe" , "/c", VideoPlayer.PathToFFMPEG + " -strict -2 -hide_banner -threads " + Settings.txtThreads.getText() + " " + cmd.replace("PathToFFMPEG", VideoPlayer.PathToFFMPEG) + pipe}); + + //Back to default + if (Settings.btnCustomFFmpegPath.isSelected() && Settings.txtCustomFFmpegPath.getText().equals("") == false) + { + VideoPlayer.PathToFFMPEG = Settings.txtCustomFFmpegPath.getText(); + } + else + { + VideoPlayer.PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + VideoPlayer.PathToFFMPEG = VideoPlayer.PathToFFMPEG.substring(1,VideoPlayer.PathToFFMPEG.length()-1); + VideoPlayer.PathToFFMPEG = VideoPlayer.PathToFFMPEG.substring(0,(int) (VideoPlayer.PathToFFMPEG.lastIndexOf("/"))).replace("%20", " ") + "\\Library\\ffmpeg.exe"; + } } else //Allow to suspend FFmpeg process { - processFFMPEG = new ProcessBuilder('"' + PathToFFMPEG + '"' + " -strict -2 -hide_banner -threads " + Settings.txtThreads.getText() + " " + cmd.replace("PathToFFMPEG", '"' + PathToFFMPEG + '"')); + processFFMPEG = new ProcessBuilder('"' + VideoPlayer.PathToFFMPEG + '"' + " -strict -2 -hide_banner -threads " + Settings.txtThreads.getText() + " " + cmd.replace("PathToFFMPEG", '"' + VideoPlayer.PathToFFMPEG + '"')); process = processFFMPEG.start(); } } else - { - PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath(); - PathToFFMPEG = PathToFFMPEG.substring(0,PathToFFMPEG.length()-1); - PathToFFMPEG = PathToFFMPEG.substring(0,(int) (PathToFFMPEG.lastIndexOf("/"))).replace("%20", "\\ ") + "/Library/ffmpeg"; - + { String pipe = ""; if (cmd.contains("pipe:1")) { - pipe = " | " + PathToFFMPEG + " -strict -2 -v quiet -i pipe:0 -an -c:v bmp -f image2pipe -"; + pipe = " | " + VideoPlayer.PathToFFMPEG + " -strict -2 -v quiet -i pipe:0 -an -c:v bmp -f image2pipe -"; } - processFFMPEG = new ProcessBuilder("/bin/bash", "-c" , PathToFFMPEG + " -strict -2 -hide_banner -threads " + Settings.txtThreads.getText() + " " + cmd.replace("PathToFFMPEG", PathToFFMPEG) + pipe); + processFFMPEG = new ProcessBuilder("/bin/bash", "-c" , VideoPlayer.PathToFFMPEG + " -strict -2 -hide_banner -threads " + Settings.txtThreads.getText() + " " + cmd.replace("PathToFFMPEG", VideoPlayer.PathToFFMPEG) + pipe); process = processFFMPEG.start(); } @@ -591,7 +595,6 @@ public static void toFFPLAY(final String cmd) { try { - String PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath();; ProcessBuilder processFFMPEG; //Image sequence @@ -608,10 +611,7 @@ else if (inputDeviceIsRunning || RecordInputDevice.frame != null && RecordInputD if (System.getProperty("os.name").contains("Windows")) { //VIDEO STREAM - PathToFFMPEG = PathToFFMPEG.substring(1,PathToFFMPEG.length()-1); - PathToFFMPEG = PathToFFMPEG.substring(0,(int) (PathToFFMPEG.lastIndexOf("/"))).replace("%20", " ") + "\\Library\\ffmpeg.exe"; - - ProcessBuilder pbv = new ProcessBuilder("cmd.exe" , "/c", '"' + PathToFFMPEG + '"' + " -strict -2 -hide_banner -threads " + Settings.txtThreads.getText() + " " + cmd + " | " + '"' + PathToFFMPEG + '"' + " -v quiet -i pipe:0" + fps + " -c:v bmp -an -f image2pipe -"); + ProcessBuilder pbv = new ProcessBuilder("cmd.exe" , "/c", '"' + VideoPlayer.PathToFFMPEG + '"' + " -strict -2 -hide_banner -threads " + Settings.txtThreads.getText() + " " + cmd + " | " + '"' + VideoPlayer.PathToFFMPEG + '"' + " -v quiet -i pipe:0" + fps + " -c:v bmp -an -f image2pipe -"); process = pbv.start(); //AUDIO STREAM @@ -628,17 +628,14 @@ else if (inputDeviceIsRunning || RecordInputDevice.frame != null && RecordInputD inputFile = new File(inputFile.getParent().replace("\\", "/") + "/" + inputFile.getName().replace(extension, ".txt")); } - ProcessBuilder pba = new ProcessBuilder("cmd.exe" , "/c", '"' + PathToFFMPEG + '"' + concat + " -v quiet " + InputAndOutput.inPoint + " -i " + '"' + inputFile + '"' + " -vn -c:a pcm_s16le -ar 48k -ac 1 -f wav -"); + ProcessBuilder pba = new ProcessBuilder("cmd.exe" , "/c", '"' + VideoPlayer.PathToFFMPEG + '"' + concat + " -v quiet " + InputAndOutput.inPoint + " -i " + '"' + inputFile + '"' + " -vn -c:a pcm_s16le -ar 48k -ac 1 -f wav -"); processAudio = pba.start(); } } else { - //VIDEO STREAM - PathToFFMPEG = PathToFFMPEG.substring(0,PathToFFMPEG.length()-1); - PathToFFMPEG = PathToFFMPEG.substring(0,(int) (PathToFFMPEG.lastIndexOf("/"))).replace("%20", "\\ ") + "/Library/ffmpeg"; - - processFFMPEG = new ProcessBuilder("/bin/bash", "-c" , PathToFFMPEG + " -strict -2 -hide_banner -threads " + Settings.txtThreads.getText() + " " + cmd + " | " + PathToFFMPEG + " -v quiet -i pipe:0" + fps + " -c:v bmp -an -f image2pipe -"); + //VIDEO STREAM + processFFMPEG = new ProcessBuilder("/bin/bash", "-c" , VideoPlayer.PathToFFMPEG + " -strict -2 -hide_banner -threads " + Settings.txtThreads.getText() + " " + cmd + " | " + VideoPlayer.PathToFFMPEG + " -v quiet -i pipe:0" + fps + " -c:v bmp -an -f image2pipe -"); process = processFFMPEG.start(); //AUDIO STREAM @@ -655,12 +652,12 @@ else if (inputDeviceIsRunning || RecordInputDevice.frame != null && RecordInputD inputFile = new File(inputFile.getParent().replace("\\", "/") + "/" + inputFile.getName().replace(extension, ".txt")); } - ProcessBuilder pba = new ProcessBuilder("/bin/bash", "-c", PathToFFMPEG + concat + " -v quiet " + InputAndOutput.inPoint + " -i " + '"' + inputFile + '"' + " -vn -c:a pcm_s16le -ar 48k -ac 1 -f wav -"); + ProcessBuilder pba = new ProcessBuilder("/bin/bash", "-c", VideoPlayer.PathToFFMPEG + concat + " -v quiet " + InputAndOutput.inPoint + " -i " + '"' + inputFile + '"' + " -vn -c:a pcm_s16le -ar 48k -ac 1 -f wav -"); processAudio = pba.start(); } } - Console.consoleFFPLAY.append(Shutter.language.getProperty("command") + " " + PathToFFMPEG + " -strict -2 -hide_banner -threads " + Settings.txtThreads.getText() + " " + cmd + " | " + PathToFFMPEG + " -v quiet -i pipe:0" + fps + " -c:v bmp -an -f image2pipe -" + System.lineSeparator()); + Console.consoleFFPLAY.append(Shutter.language.getProperty("command") + " " + VideoPlayer.PathToFFMPEG + " -strict -2 -hide_banner -threads " + Settings.txtThreads.getText() + " " + cmd + " | " + VideoPlayer.PathToFFMPEG + " -v quiet -i pipe:0" + fps + " -c:v bmp -an -f image2pipe -" + System.lineSeparator()); JFrame player = new JFrame(); player.getContentPane().setBackground(new Color(42,42,47)); @@ -938,25 +935,15 @@ public void run() { try { - String PathToFFMPEG; ProcessBuilder processFFMPEG; if (System.getProperty("os.name").contains("Windows")) { - PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath(); - PathToFFMPEG = PathToFFMPEG.substring(1,PathToFFMPEG.length()-1); - PathToFFMPEG = PathToFFMPEG.substring(0,(int) (PathToFFMPEG.lastIndexOf("/"))).replace("%20", " ") + "\\Library\\ffmpeg.exe"; - - processFFMPEG = new ProcessBuilder('"' + PathToFFMPEG + '"' + " -strict -2 -hide_banner " + cmd.replace("PathToFFMPEG", PathToFFMPEG)); + processFFMPEG = new ProcessBuilder('"' + VideoPlayer.PathToFFMPEG + '"' + " -strict -2 -hide_banner " + cmd.replace("PathToFFMPEG", VideoPlayer.PathToFFMPEG)); process = processFFMPEG.start(); } else { - PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath(); - PathToFFMPEG = PathToFFMPEG.substring(0,PathToFFMPEG.length()-1); - PathToFFMPEG = PathToFFMPEG.substring(0,(int) (PathToFFMPEG.lastIndexOf("/"))).replace("%20", "\\ ") + "/Library/ffmpeg"; - - - processFFMPEG = new ProcessBuilder("/bin/bash", "-c" , PathToFFMPEG + " -strict -2 -hide_banner " + cmd.replace("PathToFFMPEG", PathToFFMPEG)); + processFFMPEG = new ProcessBuilder("/bin/bash", "-c" , VideoPlayer.PathToFFMPEG + " -strict -2 -hide_banner " + cmd.replace("PathToFFMPEG", VideoPlayer.PathToFFMPEG)); process = processFFMPEG.start(); } @@ -1237,26 +1224,16 @@ public void run() { try { - String PathToFFMPEG; ProcessBuilder processFFMPEG; if (System.getProperty("os.name").contains("Windows")) { - PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath(); - PathToFFMPEG = PathToFFMPEG.substring(1,PathToFFMPEG.length()-1); - PathToFFMPEG = PathToFFMPEG.substring(0,(int) (PathToFFMPEG.lastIndexOf("/"))).replace("%20", " ") + "\\Library\\ffmpeg.exe"; - - processFFMPEG = new ProcessBuilder('"' + PathToFFMPEG + '"' + " " + cmd.replace("PathToFFMPEG", PathToFFMPEG)); + processFFMPEG = new ProcessBuilder('"' + VideoPlayer.PathToFFMPEG + '"' + " " + cmd.replace("PathToFFMPEG", VideoPlayer.PathToFFMPEG)); process = processFFMPEG.start(); } else { - PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath(); - PathToFFMPEG = PathToFFMPEG.substring(0,PathToFFMPEG.length()-1); - PathToFFMPEG = PathToFFMPEG.substring(0,(int) (PathToFFMPEG.lastIndexOf("/"))).replace("%20", "\\ ") + "/Library/ffmpeg"; - - - processFFMPEG = new ProcessBuilder("/bin/bash", "-c" , PathToFFMPEG + " " + cmd.replace("PathToFFMPEG", PathToFFMPEG)); + processFFMPEG = new ProcessBuilder("/bin/bash", "-c" , VideoPlayer.PathToFFMPEG + " " + cmd.replace("PathToFFMPEG", VideoPlayer.PathToFFMPEG)); process = processFFMPEG.start(); } @@ -1296,26 +1273,18 @@ public static void devices(final String cmd) { runProcess = new Thread(new Runnable() { @Override public void run() { + try { - String PathToFFMPEG; + ProcessBuilder processFFMPEG; if (System.getProperty("os.name").contains("Windows")) - { - PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath(); - PathToFFMPEG = PathToFFMPEG.substring(1,PathToFFMPEG.length()-1); - PathToFFMPEG = PathToFFMPEG.substring(0,(int) (PathToFFMPEG.lastIndexOf("/"))).replace("%20", " ") + "\\Library\\ffmpeg.exe"; - - processFFMPEG = new ProcessBuilder('"' + PathToFFMPEG + '"' + " " + cmd.replace("PathToFFMPEG", PathToFFMPEG)); + { + processFFMPEG = new ProcessBuilder('"' + VideoPlayer.PathToFFMPEG + '"' + " " + cmd.replace("PathToFFMPEG", VideoPlayer.PathToFFMPEG)); process = processFFMPEG.start(); } else { - PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath(); - PathToFFMPEG = PathToFFMPEG.substring(0,PathToFFMPEG.length()-1); - PathToFFMPEG = PathToFFMPEG.substring(0,(int) (PathToFFMPEG.lastIndexOf("/"))).replace("%20", "\\ ") + "/Library/ffmpeg"; - - - processFFMPEG = new ProcessBuilder("/bin/bash", "-c" , PathToFFMPEG + " " + cmd.replace("PathToFFMPEG", PathToFFMPEG)); + processFFMPEG = new ProcessBuilder("/bin/bash", "-c" , VideoPlayer.PathToFFMPEG + " " + cmd.replace("PathToFFMPEG", VideoPlayer.PathToFFMPEG)); process = processFFMPEG.start(); } @@ -1443,25 +1412,15 @@ public static void playerWaveform(final String cmd) { try { - String PathToFFMPEG; ProcessBuilder processFFMPEG; if (System.getProperty("os.name").contains("Windows")) { - PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath(); - PathToFFMPEG = PathToFFMPEG.substring(1,PathToFFMPEG.length()-1); - PathToFFMPEG = PathToFFMPEG.substring(0,(int) (PathToFFMPEG.lastIndexOf("/"))).replace("%20", " ") + "\\Library\\ffmpeg.exe"; - - processFFMPEG = new ProcessBuilder('"' + PathToFFMPEG + '"' + cmd + '"'); + processFFMPEG = new ProcessBuilder('"' + VideoPlayer.PathToFFMPEG + '"' + cmd + '"'); waveformProcess = processFFMPEG.start(); } else { - PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath(); - PathToFFMPEG = PathToFFMPEG.substring(0,PathToFFMPEG.length()-1); - PathToFFMPEG = PathToFFMPEG.substring(0,(int) (PathToFFMPEG.lastIndexOf("/"))).replace("%20", "\\ ") + "/Library/ffmpeg"; - - - processFFMPEG = new ProcessBuilder("/bin/bash", "-c" , PathToFFMPEG + cmd); + processFFMPEG = new ProcessBuilder("/bin/bash", "-c" , VideoPlayer.PathToFFMPEG + cmd); waveformProcess = processFFMPEG.start(); } @@ -1546,25 +1505,15 @@ public static boolean isReadable(File file) { try { - String PathToFFMPEG; ProcessBuilder processFFMPEG; if (System.getProperty("os.name").contains("Windows")) { - PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath(); - PathToFFMPEG = PathToFFMPEG.substring(1,PathToFFMPEG.length()-1); - PathToFFMPEG = PathToFFMPEG.substring(0,(int) (PathToFFMPEG.lastIndexOf("/"))).replace("%20", " ") + "\\Library\\ffmpeg.exe"; - - processFFMPEG = new ProcessBuilder('"' + PathToFFMPEG + '"' + " -strict -2 -hide_banner -i " + '"' + file + '"' + " -t 5 -f null -" + '"'); + processFFMPEG = new ProcessBuilder('"' + VideoPlayer.PathToFFMPEG + '"' + " -strict -2 -hide_banner -i " + '"' + file + '"' + " -t 5 -f null -" + '"'); process = processFFMPEG.start(); } else { - PathToFFMPEG = Shutter.class.getProtectionDomain().getCodeSource().getLocation().getPath(); - PathToFFMPEG = PathToFFMPEG.substring(0,PathToFFMPEG.length()-1); - PathToFFMPEG = PathToFFMPEG.substring(0,(int) (PathToFFMPEG.lastIndexOf("/"))).replace("%20", "\\ ") + "/Library/ffmpeg"; - - - processFFMPEG = new ProcessBuilder("/bin/bash", "-c" , PathToFFMPEG + " -strict -2 -hide_banner -i " + '"' + file + '"' + " -t 5 -f null -"); + processFFMPEG = new ProcessBuilder("/bin/bash", "-c" , VideoPlayer.PathToFFMPEG + " -strict -2 -hide_banner -i " + '"' + file + '"' + " -t 5 -f null -"); process = processFFMPEG.start(); }