-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtract.java
More file actions
60 lines (43 loc) · 1.52 KB
/
Extract.java
File metadata and controls
60 lines (43 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package VAMIX;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
public class Extract extends SwingWorker<Void, Integer>{
private String openPath;
private String savePath;
private String videoSave;
//Store file locations
public Extract(String openPath, String savePath, String videoSave){
this.openPath = openPath;
this.savePath = savePath;
this.videoSave = videoSave;
}
public void extract() throws IOException{
//save audio in another file
String cmd="avconv -i "+this.openPath+ " -vn -c:a libmp3lame -q:a 2 " +this.savePath;
ProcessBuilder builder1 = new ProcessBuilder("/bin/bash", "-c", cmd);
builder1.start();
//save video without audio
String cmd2 = "avconv -i " +this.openPath + " -an " + this.videoSave;
ProcessBuilder builder2 = new ProcessBuilder("/bin/bash", "-c", cmd2);
builder2.start();
}
//check for audio
public int checkAudio(){
EmbeddedMediaPlayerComponent video = new EmbeddedMediaPlayerComponent();
EmbeddedMediaPlayer v = video.getMediaPlayer();
int channel = v.getAudioChannel();
return channel;
}
protected Void doInBackground() throws Exception {
this.extract();
return null;
}
protected void done(){
JFrame messageFrame = new JFrame();
JOptionPane.showMessageDialog(messageFrame, "Finished extracting","VAMIX", JOptionPane.INFORMATION_MESSAGE);
}
}