Skip to content

Commit 2654821

Browse files
Fixing yt-dlp issue
Signed-off-by: JayFromProgramming <ajsweene@mtu.edu>
1 parent 888f22c commit 2654821

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/com/example/clippyfx/ClippingView.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ private VideoChecks.Encoders getEncoder() {
144144
return VideoChecks.Encoders.valueOf(presetBox.getValue().toString());
145145
}
146146

147+
/**
148+
* Gets the size of the video to be clipped.
149+
* @return The size of the video to be clipped.
150+
*/
147151
private VideoChecks.Sizes getSize() {
148152
if (videoSizeSelect.getValue().toString().equals("Source")) {
149153
return VideoChecks.Sizes.Source;
@@ -152,6 +156,12 @@ private VideoChecks.Sizes getSize() {
152156
}
153157
}
154158

159+
/**
160+
* Called when the user clicks the clipIt button.
161+
* @param mouseEvent The mouse event that triggered the method. (Not used)
162+
* @throws IOException If the file cannot be found.
163+
* @throws InterruptedException If the process is interrupted.
164+
*/
155165
public void clipIt(MouseEvent mouseEvent) throws IOException, InterruptedException {
156166
if (clipping){
157167
FFmpegWrapper.killProcess(clipper);
@@ -178,6 +188,11 @@ public void clipIt(MouseEvent mouseEvent) throws IOException, InterruptedExcepti
178188
// TODO: GIANT GREEN CHECK MARK BABYYY WHOOOOOOOOOOO - Nick
179189
}
180190

191+
/**
192+
* The method used to pass the media player and peg generator to this class.
193+
* @param mediaPlayer The media player to be used.
194+
* @param pegGenerator The peg generator to be used.
195+
*/
181196
@SuppressWarnings("unchecked")
182197
public void passObjects(MediaPlayer mediaPlayer, PegGenerator pegGenerator) {
183198
closeHook(this.pain);

src/main/java/com/example/clippyfx/ImporterView.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ public progressUpdater(Process clipper) {
8787
splitList = new ArrayList<>();
8888
}
8989

90+
/**
91+
* Updates the window with the state of the video conversion.
92+
* @param now
93+
* The timestamp of the current frame given in nanoseconds. This
94+
* value will be the same for all {@code AnimationTimers} called
95+
* during one frame.
96+
*/
9097
@Override
9198
public void handle(long now) {
9299
String line = null;
@@ -128,6 +135,10 @@ public void handle(long now) {
128135
}
129136
}
130137

138+
/**
139+
* Checks for the availability of hardware acceleration and selects the best one.
140+
* If none are available, it will use CPU encoding.
141+
*/
131142
@SuppressWarnings("unchecked")
132143
private void checkHWACCEL() {
133144
ArrayList<VideoChecks.Encoders> encoders = VideoChecks.getEncoders();
@@ -157,8 +168,13 @@ protected double calcFrameRate(String ffprobeOutput) {
157168
return (double) Integer.parseInt(sections[0]) / (double) Integer.parseInt(sections[1]);
158169
}
159170

171+
/**
172+
* Converts the video to a h264 mp4 file so that it can be displayed in the embedded player.
173+
* @throws IOException if the file cannot be found
174+
* @throws InterruptedException if the process is interrupted
175+
*/
160176
public void convertIt() throws IOException, InterruptedException {
161-
if (clipping){
177+
if (clipping) {
162178
FFmpegWrapper.killProcess(clipper);
163179
clipping=false;
164180
updater.stop();
@@ -170,7 +186,8 @@ public void convertIt() throws IOException, InterruptedException {
170186
String fileSaveName = nameBox.getText();
171187

172188
ffmpegOutput.appendText("Starting conversion...\nCalculating duration and framerate...\n");
173-
String probe_command = "ffprobe -v error -select_streams v -of default=noprint_wrappers=1:nokey=1 -show_entries stream=r_frame_rate \"" + fileName + "\"";
189+
String probe_command = "ffprobe -v error -select_streams v -of default=noprint_wrappers=1:nokey=1" +
190+
" -show_entries stream=r_frame_rate \"" + fileName + "\"";
174191
fps = (float) calcFrameRate(StreamedCommand.getCommandOutput(probe_command));
175192
ffmpegOutput.appendText("Calculated framerate: " + fps + "\n");
176193
probe_command = "ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 \"" + fileName + "\"";
@@ -189,6 +206,12 @@ public void convertIt() throws IOException, InterruptedException {
189206
}
190207

191208

209+
/**
210+
* Called when the conversion is finished. Checks if the file exists and if it does it will
211+
* mark it for deletion on exit and close the window.
212+
* @note The temp file *will* be deleted on exit, so if needed it should be copied to a new location.
213+
* @throws IOException if the file cannot be found
214+
*/
192215
private void finish() throws IOException {
193216
clipping = false;
194217
progressBar.setProgress(1);

0 commit comments

Comments
 (0)