我正在尝试使用Xuggler(我相信ffmpeg在引擎盖下使用)来执行以下操作:
我已经看过/阅读过他们的一些优秀教程,到目前为止我的内容是:
// I'll worry about implementing this functionality later, but
// involves querying native device drivers.
byte[] nextMjpeg = getNextMjpegFromSerialPort();
// I'll also worry about implementing this functionality as well;
// I'm simply providing these for thoroughness.
BufferedImage mjpeg = MjpegFactory.newMjpeg(nextMjpeg);
// Specify a h.264 video stream (how?)
String h264Stream = "???";
IMediaWriter writer = ToolFactory.makeWriter(h264Stream);
writer.addVideoStream(0, 0, ICodec.ID.CODEC_ID_H264);
writer.encodeVideo(0, mjpeg);
Run Code Online (Sandbox Code Playgroud)
首先,我想我离这儿很近,但它仍然不正确; 我只是通过阅读视频代码示例(而不是音频 - 我找不到任何好的音频示例)来实现这一目标.
从字面上看,我将获得对Xuggler实现中的原始视频和音频源的字节级访问.但对于我的生活,我无法弄清楚如何将它们变成h.264/AAC/MPEG-TS格式.在此提前感谢您的帮助.
我正在尝试用 Java 制作一个 mp3 播放器,但我不知道如何控制其中的音量。
我试过这样的事情:
// Adjust the volume on the output line.
if (dataLine.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
FloatControl volume = (FloatControl) dataLine.getControl(FloatControl.Type.MASTER_GAIN);
volume.setValue(100.0F);
}
Run Code Online (Sandbox Code Playgroud)
在这段代码工作正常之前,我编写的所有内容都很好,但显然 dataLine 不受支持,因为它跳过了这个 IF 语句。
我的问题是:你知道为什么会发生这种情况吗,我该如何解决这个问题,以便我可以控制我的应用程序的音量?