AndroidUSBCamera
AndroidUSBCamera copied to clipboard
可以支持USB的音频输入吗?
摄像头是带麦克风的,怎样可以获取到音频输入数据并来播放呢?
Good question. but perhaps we need to ask it in parent project https://github.com/saki4510t/UVCCamera
I am also finding more info about this topic.
Good question. but perhaps we need to ask it in parent project https://github.com/saki4510t/UVCCamera
I am also finding more info about this topic.
Do you have a solution to this problem
That is what I want to know before. But now my project does not need the audio. So I dont know about solution for your question now.
支持
同样想知道如何播放摄像头采集的音频
支持
请问大佬什么时候更新usb音频部分呢?另外视频格式可以增加h264的支持吗?
@jiangdongguo 求指点,我也遇到了这个问题,摄像头带有麦克风,推流之后没有声音,这个需要改造库里的哪些地方?
大抵是要自己写 NDK 的驱动
大抵是要自己写 NDK 的驱动
改一下源码就可以了,原本功能有把USB的音频保存成文件
大抵是要自己写 NDK 的驱动
改一下源码就可以了,原本功能有把USB的音频保存成文件
您说的是要修改 libusb 吗还是本库的?
大抵是要自己写 NDK 的驱动
朋友 你推流没有声音的问题解决了嘛 我目前也遇到这个问题
大抵是要自己写 NDK 的驱动
改一下源码就可以了,原本功能有把USB的音频保存成文件
兄弟 你是怎么改的 能不能告诉我一下
大抵是要自己写 NDK 的驱动
改一下源码就可以了,原本功能有把USB的音频保存成文件
兄弟 你是怎么改的 能不能告诉我一下
把UVCCamera的源码下载下来,在MediaAudioEncoder类的AudioThread处理获取到的音频数据。
if (audioRecord != null) {
try {
if (mIsCapturing) {
if (DEBUG) Log.v(TAG, "AudioThread:start audio recording");
int readBytes;
audioRecord.startRecording();
try {
for ( ; mIsCapturing && !mRequestStop && !mIsEOS ; ) {
// read audio data from internal mic
buf.clear();
try {
// readBytes = audioRecord.read(buf, SAMPLES_PER_FRAME);
readBytes = audioRecord.read(buffer, 0, SAMPLES_PER_FRAME);
outputStream.write(buffer);
// outstream.write(buffer, 0, SAMPLES_PER_FRAME);
// buf.get(buffer, 0, SAMPLES_PER_FRAME);
} catch (final Exception e) {
break;
}
if (readBytes > 0) {
// set audio data to encoder
// buf.position(readBytes);
// buf.flip();
// encode(buf, readBytes, getPTSUs());
frameAvailableSoon();
cnt++;
}
}
if (cnt > 0) {
frameAvailableSoon();
}
} finally {
outputStream.close();
audioRecord.stop();
// outstream.close();
}
}
} catch (final Exception e) {
Log.e(TAG, "AudioThread#run", e);
} finally {
audioRecord.release();
}
}
`
`
private final MediaEncoder.MediaEncoderListener mMediaEncoderListener = new MediaEncoder.MediaEncoderListener() {
@Override
public void onPrepared(final MediaEncoder encoder) {
if (DEBUG) Log.v(TAG, "onPrepared:encoder=" + encoder);
mIsRecording = true;
if (encoder instanceof MediaVideoEncoder) {
try {
mWeakCameraView.get().setVideoEncoder((MediaVideoEncoder) encoder);
} catch (final Exception e) {
Log.e(TAG, "onPrepared:", e);
}
}
if (encoder instanceof MediaSurfaceEncoder){
try {
mWeakCameraView.get().setVideoEncoder((MediaSurfaceEncoder)encoder);
mUVCCamera.startCapture(((MediaSurfaceEncoder)encoder).getInputSurface());
} catch (final Exception e) {
Log.e(TAG, "onPrepared:", e);
}
}
if (encoder instanceof MediaAudioEncoder){
path = ((MediaAudioEncoder) encoder).getFilePath();
startRecord();
}
}
大抵是要自己写 NDK 的驱动
改一下源码就可以了,原本功能有把USB的音频保存成文件
兄弟 你是怎么改的 能不能告诉我一下
把UVCCamera的源码下载下来,在MediaAudioEncoder类的AudioThread处理获取到的音频数据。 `if (audioRecord != null) { try { if (mIsCapturing) { if (DEBUG) Log.v(TAG, "AudioThread:start audio recording"); int readBytes; audioRecord.startRecording(); try { for ( ; mIsCapturing && !mRequestStop && !mIsEOS ; ) { // read audio data from internal mic buf.clear(); try { // readBytes = audioRecord.read(buf, SAMPLES_PER_FRAME);
readBytes = audioRecord.read(buffer, 0, SAMPLES_PER_FRAME); outputStream.write(buffer);
// outstream.write(buffer, 0, SAMPLES_PER_FRAME); // buf.get(buffer, 0, SAMPLES_PER_FRAME);
} catch (final Exception e) { break; } if (readBytes > 0) { // set audio data to encoder
// buf.position(readBytes); // buf.flip();
// encode(buf, readBytes, getPTSUs()); frameAvailableSoon(); cnt++; } } if (cnt > 0) { frameAvailableSoon(); } } finally { outputStream.close(); audioRecord.stop(); // outstream.close(); } } } catch (final Exception e) { Log.e(TAG, "AudioThread#run", e); } finally { audioRecord.release(); } }
private final MediaEncoder.MediaEncoderListener mMediaEncoderListener = new MediaEncoder.MediaEncoderListener() { @override public void onPrepared(final MediaEncoder encoder) { if (DEBUG) Log.v(TAG, "onPrepared:encoder=" + encoder); mIsRecording = true; if (encoder instanceof MediaVideoEncoder) { try { mWeakCameraView.get().setVideoEncoder((MediaVideoEncoder) encoder); } catch (final Exception e) { Log.e(TAG, "onPrepared:", e); } } if (encoder instanceof MediaSurfaceEncoder){ try { mWeakCameraView.get().setVideoEncoder((MediaSurfaceEncoder)encoder); mUVCCamera.startCapture(((MediaSurfaceEncoder)encoder).getInputSurface()); } catch (final Exception e) { Log.e(TAG, "onPrepared:", e); } } if (encoder instanceof MediaAudioEncoder){ path = ((MediaAudioEncoder) encoder).getFilePath(); startRecord(); } } `
感谢兄弟 能不能把源码打包发一份给我看看 [email protected]
兄弟 能不能把这个文件整个发给我 谢谢了 困扰我小半个月了
------------------ 原始邮件 ------------------ 发件人: "CarryHekangkai"<[email protected]>; 发送时间: 2020年12月9日(星期三) 上午9:46 收件人: "jiangdongguo/AndroidUSBCamera"<[email protected]>; 抄送: "℉ōrēvēr."<[email protected]>; "Comment"<[email protected]>; 主题: Re: [jiangdongguo/AndroidUSBCamera] 可以支持USB的音频输入吗? (#258)
大抵是要自己写 NDK 的驱动
改一下源码就可以了,原本功能有把USB的音频保存成文件
兄弟 你是怎么改的 能不能告诉我一下
把UVCCamera的源码下载下来,在MediaAudioEncoder类的AudioThread处理获取到的音频数据。
`if (audioRecord != null) {
try {
if (mIsCapturing) {
if (DEBUG) Log.v(TAG, "AudioThread:start audio recording");
int readBytes;
audioRecord.startRecording();
try {
for ( ; mIsCapturing && !mRequestStop && !mIsEOS ; ) {
// read audio data from internal mic
buf.clear();
try {
// readBytes = audioRecord.read(buf, SAMPLES_PER_FRAME);
readBytes = audioRecord.read(buffer, 0, SAMPLES_PER_FRAME); outputStream.write(buffer);
// outstream.write(buffer, 0, SAMPLES_PER_FRAME);
// buf.get(buffer, 0, SAMPLES_PER_FRAME);
} catch (final Exception e) { break; } if (readBytes > 0) { // set audio data to encoder
// buf.position(readBytes);
// buf.flip();
// encode(buf, readBytes, getPTSUs()); frameAvailableSoon(); cnt++; } } if (cnt > 0) { frameAvailableSoon(); } } finally { outputStream.close(); audioRecord.stop(); // outstream.close(); } } } catch (final Exception e) { Log.e(TAG, "AudioThread#run", e); } finally { audioRecord.release(); } }
private final MediaEncoder.MediaEncoderListener mMediaEncoderListener = new MediaEncoder.MediaEncoderListener() { @override public void onPrepared(final MediaEncoder encoder) { if (DEBUG) Log.v(TAG, "onPrepared:encoder=" + encoder); mIsRecording = true; if (encoder instanceof MediaVideoEncoder) { try { mWeakCameraView.get().setVideoEncoder((MediaVideoEncoder) encoder); } catch (final Exception e) { Log.e(TAG, "onPrepared:", e); } } if (encoder instanceof MediaSurfaceEncoder){ try { mWeakCameraView.get().setVideoEncoder((MediaSurfaceEncoder)encoder); mUVCCamera.startCapture(((MediaSurfaceEncoder)encoder).getInputSurface()); } catch (final Exception e) { Log.e(TAG, "onPrepared:", e); } } if (encoder instanceof MediaAudioEncoder){ path = ((MediaAudioEncoder) encoder).getFilePath(); startRecord(); } } `
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
大抵是要自己写 NDK 的驱动
改一下源码就可以了,原本功能有把USB的音频保存成文件
兄弟 你是怎么改的 能不能告诉我一下
把UVCCamera的源码下载下来,在MediaAudioEncoder类的AudioThread处理获取到的音频数据。 `if (audioRecord != null) { try { if (mIsCapturing) { if (DEBUG) Log.v(TAG, "AudioThread:start audio recording"); int readBytes; audioRecord.startRecording(); try { for ( ; mIsCapturing && !mRequestStop && !mIsEOS ; ) { // read audio data from internal mic buf.clear(); try { // readBytes = audioRecord.read(buf, SAMPLES_PER_FRAME);
readBytes = audioRecord.read(buffer, 0, SAMPLES_PER_FRAME); outputStream.write(buffer);
// outstream.write(buffer, 0, SAMPLES_PER_FRAME); // buf.get(buffer, 0, SAMPLES_PER_FRAME);
} catch (final Exception e) { break; } if (readBytes > 0) { // set audio data to encoder
// buf.position(readBytes); // buf.flip(); // encode(buf, readBytes, getPTSUs()); frameAvailableSoon(); cnt++; } } if (cnt > 0) { frameAvailableSoon(); } } finally { outputStream.close(); audioRecord.stop(); // outstream.close(); } } } catch (final Exception e) { Log.e(TAG, "AudioThread#run", e); } finally { audioRecord.release(); } }
private final MediaEncoder.MediaEncoderListener mMediaEncoderListener = new MediaEncoder.MediaEncoderListener() { @override public void onPrepared(final MediaEncoder encoder) { if (DEBUG) Log.v(TAG, "onPrepared:encoder=" + encoder); mIsRecording = true; if (encoder instanceof MediaVideoEncoder) { try { mWeakCameraView.get().setVideoEncoder((MediaVideoEncoder) encoder); } catch (final Exception e) { Log.e(TAG, "onPrepared:", e); } } if (encoder instanceof MediaSurfaceEncoder){ try { mWeakCameraView.get().setVideoEncoder((MediaSurfaceEncoder)encoder); mUVCCamera.startCapture(((MediaSurfaceEncoder)encoder).getInputSurface()); } catch (final Exception e) { Log.e(TAG, "onPrepared:", e); } } if (encoder instanceof MediaAudioEncoder){ path = ((MediaAudioEncoder) encoder).getFilePath(); startRecord(); } } `
感谢兄弟 能不能把源码打包发一份给我看看 [email protected]
这个AudioThread是使用AudioRecord获取手机系统录音。只不过凑巧是,audioSource设置为mic,且usb摄像头有mic,那么拿到的录音数据就是摄像头mic的(类似外置录音源)。但是这样有一个问题就是,app会一直占用系统录音,其他app就无法调用系统录音了。要想直接拿到摄像头的音频数据,必须从NDK层入手。
了解 了解 写了 大兄弟
------------------ 原始邮件 ------------------ 发件人: "butterfly0Dream"<[email protected]>; 发送时间: 2020年12月9日(星期三) 中午11:07 收件人: "jiangdongguo/AndroidUSBCamera"<[email protected]>; 抄送: "℉ōrēvēr."<[email protected]>; "Comment"<[email protected]>; 主题: Re: [jiangdongguo/AndroidUSBCamera] 可以支持USB的音频输入吗? (#258)
大抵是要自己写 NDK 的驱动
改一下源码就可以了,原本功能有把USB的音频保存成文件
兄弟 你是怎么改的 能不能告诉我一下
把UVCCamera的源码下载下来,在MediaAudioEncoder类的AudioThread处理获取到的音频数据。
`if (audioRecord != null) {
try {
if (mIsCapturing) {
if (DEBUG) Log.v(TAG, "AudioThread:start audio recording");
int readBytes;
audioRecord.startRecording();
try {
for ( ; mIsCapturing && !mRequestStop && !mIsEOS ; ) {
// read audio data from internal mic
buf.clear();
try {
// readBytes = audioRecord.read(buf, SAMPLES_PER_FRAME);
readBytes = audioRecord.read(buffer, 0, SAMPLES_PER_FRAME); outputStream.write(buffer);
// outstream.write(buffer, 0, SAMPLES_PER_FRAME);
// buf.get(buffer, 0, SAMPLES_PER_FRAME);
} catch (final Exception e) { break; } if (readBytes > 0) { // set audio data to encoder
// buf.position(readBytes);
// buf.flip();
// encode(buf, readBytes, getPTSUs());
frameAvailableSoon();
cnt++;
}
}
if (cnt > 0) {
frameAvailableSoon();
}
} finally {
outputStream.close();
audioRecord.stop();
// outstream.close();
}
}
} catch (final Exception e) {
Log.e(TAG, "AudioThread#run", e);
} finally {
audioRecord.release();
}
}
private final MediaEncoder.MediaEncoderListener mMediaEncoderListener = new MediaEncoder.MediaEncoderListener() { @override public void onPrepared(final MediaEncoder encoder) { if (DEBUG) Log.v(TAG, "onPrepared:encoder=" + encoder); mIsRecording = true; if (encoder instanceof MediaVideoEncoder) { try { mWeakCameraView.get().setVideoEncoder((MediaVideoEncoder) encoder); } catch (final Exception e) { Log.e(TAG, "onPrepared:", e); } } if (encoder instanceof MediaSurfaceEncoder){ try { mWeakCameraView.get().setVideoEncoder((MediaSurfaceEncoder)encoder); mUVCCamera.startCapture(((MediaSurfaceEncoder)encoder).getInputSurface()); } catch (final Exception e) { Log.e(TAG, "onPrepared:", e); } } if (encoder instanceof MediaAudioEncoder){ path = ((MediaAudioEncoder) encoder).getFilePath(); startRecord(); } } `
感谢兄弟 能不能把源码打包发一份给我看看 [email protected]
这个AudioThread是使用AudioRecord获取手机系统录音。只不过凑巧是,audioSource设置为mic,且usb摄像头有mic,那么拿到的录音数据就是摄像头mic的(类似外置录音源)。但是这样有一个问题就是,app会一直占用系统录音,其他app就无法调用系统录音了。要想直接拿到摄像头的音频数据,必须从NDK层入手。
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
了解 了解 写了 大兄弟 … ------------------ 原始邮件 ------------------ 发件人: "butterfly0Dream"<[email protected]>; 发送时间: 2020年12月9日(星期三) 中午11:07 收件人: "jiangdongguo/AndroidUSBCamera"<[email protected]>; 抄送: "℉ōrēvēr."<[email protected]>; "Comment"<[email protected]>; 主题: Re: [jiangdongguo/AndroidUSBCamera] 可以支持USB的音频输入吗? (#258) 大抵是要自己写 NDK 的驱动 改一下源码就可以了,原本功能有把USB的音频保存成文件 兄弟 你是怎么改的 能不能告诉我一下 把UVCCamera的源码下载下来,在MediaAudioEncoder类的AudioThread处理获取到的音频数据。
if (audioRecord != null) { try { if (mIsCapturing) { if (DEBUG) Log.v(TAG, "AudioThread:start audio recording"); int readBytes; audioRecord.startRecording(); try { for ( ; mIsCapturing && !mRequestStop && !mIsEOS ; ) { // read audio data from internal mic buf.clear(); try { // readBytes = audioRecord.read(buf, SAMPLES_PER_FRAME); readBytes = audioRecord.read(buffer, 0, SAMPLES_PER_FRAME); outputStream.write(buffer); // outstream.write(buffer, 0, SAMPLES_PER_FRAME); // buf.get(buffer, 0, SAMPLES_PER_FRAME); } catch (final Exception e) { break; } if (readBytes > 0) { // set audio data to encoder // buf.position(readBytes); // buf.flip(); // encode(buf, readBytes, getPTSUs()); frameAvailableSoon(); cnt++; } } if (cnt > 0) { frameAvailableSoon(); } } finally { outputStream.close(); audioRecord.stop(); // outstream.close(); } } } catch (final Exception e) { Log.e(TAG, "AudioThread#run", e); } finally { audioRecord.release(); } } private final MediaEncoder.MediaEncoderListener mMediaEncoderListener = new MediaEncoder.MediaEncoderListener() { @override public void onPrepared(final MediaEncoder encoder) { if (DEBUG) Log.v(TAG, "onPrepared:encoder=" + encoder); mIsRecording = true; if (encoder instanceof MediaVideoEncoder) { try { mWeakCameraView.get().setVideoEncoder((MediaVideoEncoder) encoder); } catch (final Exception e) { Log.e(TAG, "onPrepared:", e); } } if (encoder instanceof MediaSurfaceEncoder){ try { mWeakCameraView.get().setVideoEncoder((MediaSurfaceEncoder)encoder); mUVCCamera.startCapture(((MediaSurfaceEncoder)encoder).getInputSurface()); } catch (final Exception e) { Log.e(TAG, "onPrepared:", e); } } if (encoder instanceof MediaAudioEncoder){ path = ((MediaAudioEncoder) encoder).getFilePath(); startRecord(); } }
感谢兄弟 能不能把源码打包发一份给我看看 [email protected] 这个AudioThread是使用AudioRecord获取手机系统录音。只不过凑巧是,audioSource设置为mic,且usb摄像头有mic,那么拿到的录音数据就是摄像头mic的(类似外置录音源)。但是这样有一个问题就是,app会一直占用系统录音,其他app就无法调用系统录音了。要想直接拿到摄像头的音频数据,必须从NDK层入手。 — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
大兄弟 这个问题你后来解决了吗
https://app.mi.com/details?id=com.shenyaocn.android.usbcamera 这个支持音频输入 不知道他怎么做到的
支持
不支持吧,是说和预览视频一样能同时播放声音,不是录制声音,比如采集卡直接接入电视盒子,直接通过设备看电影能放声音之类的。
https://app.mi.com/details?id=com.shenyaocn.android.usbcamera 这个支持音频输入 不知道他怎么做到的
微博可以找到他
https://app.mi.com/details?id=com.shenyaocn.android.usbcamera 这个支持音频输入 不知道他怎么做到的
微博可以找到他
谢谢,是我肤浅了 加个trackaudio直接播放就可以了。
@MAYBreath 我也是要用於USB采集卡,請問您能预览视频並同时播放声音了嗎?是在哪個類加入trackaudio?謝謝~~
https://app.mi.com/details?id=com.shenyaocn.android.usbcamera This supports audio input, I don’t know how he did it
You can find him on Weibo
Thank you, I am superficial and just add a trackaudio to play it directly.
Did you find any solution?
sorry 不行
---原始邮件--- 发件人: @.> 发送时间: 2021年10月27日(周三) 晚上6:26 收件人: @.>; 抄送: @.@.>; 主题: Re: [jiangdongguo/AndroidUSBCamera] 可以支持USB的音频输入吗? (#258)
@MAYBreath 我也是要用再USB采集卡,請問您能预览视频並同时播放声音了嗎?是在哪個類加入trackaudio?謝謝~~
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
sorry no … ---原始邮件--- 发件人: @.> 发送时间: 2021年10月27日(周三) 晚上6:26 收件人: @.>; 抄送: @.@.>; 主题: Re: [jiangdongguo/AndroidUSBCamera] 可以支持USB的音频输入吗? (#258) @MAYBreath 我也是要用再USB采集卡,請問您能预览视频並同时播放声音了嗎?是在哪個類加入trackaudio?謝謝~~ — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
Then how is this easycap app working?
有解决了吗?各位
我已解决,可以看我的博客 : https://blog.csdn.net/EthanCo/article/details/125802505
我已解决,可以看我的博客 : https://blog.csdn.net/EthanCo/article/details/125802505
其实不需要额外用库的,他本身就自带有AAC编码器AACEncodeConsumer 里面就有采集音频 直接加载就能播放
不过真巧 我也是打算用在车机上,不知道你是哪个车企的?