gpt4 book ai didi

java - Jx capture 不将文件保存到桌面

转载 作者:行者123 更新时间:2023-12-02 10:36:36 24 4
gpt4 key购买 nike

大家好,我正在尝试使用 Jx 捕获库制作视频录制软件,它应该将文件保存为 Desktop.wmv ,但程序执行后我无法在任何地方找到该文件。该程序正在运行,没有任何错误,但我无法在任何地方找到该文件。有人可以帮忙吗?谢谢!!

package webcrawler;

import com.teamdev.jxcapture.Codec;
import com.teamdev.jxcapture.EncodingParameters;
import com.teamdev.jxcapture.InterpolationMode;
import com.teamdev.jxcapture.VideoCapture;
import com.teamdev.jxcapture.audio.AudioCodec;
import com.teamdev.jxcapture.audio.AudioEncodingParameters;
import com.teamdev.jxcapture.audio.AudioSource;
import com.teamdev.jxcapture.video.VideoFormat;

import java.awt.*;
import java.io.File;
import java.util.List;


public class WebCrawler {


static boolean useAudio = true;
static boolean usePause = true;

public static void main(String[] args) throws Exception {
EncodingParameters encodingParameters = new EncodingParameters(new File("Desktop.wmv"));
encodingParameters.setBitrate(1500000);
encodingParameters.setSize(new Dimension(800, 600));
encodingParameters.setInterpolationMode(InterpolationMode.HighQuality);

VideoCapture videoCapture = VideoCapture.create(VideoFormat.WMV);

List<Codec> codecs = videoCapture.getVideoCodecs();
System.out.println("Available video codecs:");
for (Codec
codec : codecs) {
System.out.println("Video codec: " + codec);
}
Codec preferredCodec = codecs.get(1);
System.out.println("Selected video codec = " + preferredCodec);

encodingParameters.setCodec(preferredCodec);

if (useAudio) {
System.out.println("Available audio recording sources:");
List<AudioSource> audioSources = AudioSource.getAvailable();
for (AudioSource audioSource : audioSources) {
System.out.println("audioSource = " + audioSource);
}
if (audioSources.isEmpty()) {
System.err.println("No audio sources available");
} else {
AudioSource audioSource = audioSources.get(0);
System.out.println("Selected audio source = " + audioSource);
videoCapture.setAudioSource(audioSource);

List<AudioCodec> audioCodecs = videoCapture.getAudioCodecs();
if (audioSources.isEmpty()) {
System.err.println("No audio codecs available");
} else {
System.out.println("Available audio codecs:");
for (AudioCodec audioCodec : audioCodecs) {
System.out.println("audioCodec = " + audioCodec);
}

// Enable and configure audio encoding
AudioEncodingParameters audioEncoding = new AudioEncodingParameters();

AudioCodec audioCodec = audioCodecs.get(0);
System.out.println("Selected audio codec = " + audioCodec);
audioEncoding.setCodec(audioCodec);

encodingParameters.setAudioEncoding(audioEncoding);
}
}
}
System.out.println("encodingParameters = " + encodingParameters);

videoCapture.start(encodingParameters);
if (usePause) {
System.out.println("Recording started. Press 'Enter' to pause.");
System.in.read();
videoCapture.pause();
System.out.println("Recording started. Press 'Enter' to resume.");
System.in.read();
videoCapture.start();
}
System.out.println("Recording started. Press 'Enter' to stop.");
System.in.read();
videoCapture.stop();
System.out.println("Done.");
}
}

最佳答案

默认情况下,捕获的视频文件位于正在运行的应用程序的当前目录中。如果需要将文件放置到任何其他位置,则必须指定它的绝对路径。例如:

new EncodingParameters(new File("D:\User\Desktop.wmv"));

关于java - Jx capture 不将文件保存到桌面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53250507/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com