Java Android Mediarecorder:获得3GP而不是MPEG4
我只想用android和MPEG4格式录制视频。我希望容器和编解码器是MPEG4。这就是我为此所做的Java Android Mediarecorder:获得3GP而不是MPEG4,java,android,audio-recording,video-recording,Java,Android,Audio Recording,Video Recording,我只想用android和MPEG4格式录制视频。我希望容器和编解码器是MPEG4。这就是我为此所做的 Thread video = new Thread(new Runnable() { public void run() { videoRecorder = new MediaRecorder(); videoRecorder.setPreviewDisplay(surfaceView.getHolder().getSurface());
Thread video = new Thread(new Runnable() {
public void run() {
videoRecorder = new MediaRecorder();
videoRecorder.setPreviewDisplay(surfaceView.getHolder().getSurface());
videoRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
videoRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
videoRecorder.setVideoEncodingBitRate(56 * 8 * 1024);
videoRecorder.setVideoSize(176, 144);
videoRecorder.setVideoFrameRate(12);
videoRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
videoRecorder.setOutputFile("/sdcard/video.m4e");
try {
videoRecorder.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
videoRecorder.start();
}
});
video.start();
现在,在录制之后,我将视频录制到video.m4e
文件中。但当我查看它的信息时,我得到了以下信息:
同时,我使用以下方法录制音频:
Thread audio = new Thread(new Runnable() {
public void run() {
audioRecorder = new MediaRecorder();
audioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
audioRecorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
audioRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
audioRecorder.setOutputFile("/sdcard/audio.amr");
try {
audioRecorder.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
audioRecorder.start();
}
});
audio.start();
我得到了我想要的AMR格式的容器和编解码器:
那么,是什么原因导致MediaRecorder以3GP格式录制视频?我还没有在我的程序中指定3GP。我正在运行Android 2.2的三星Galaxy标签上测试这段代码,这是由框架定义的。具体来说,它有一组在MediaRecorder类中找到的参数,这些参数定义了所有支持的内容 这是由框架定义的。具体来说,它有一组在MediaRecorder类中找到的参数,这些参数定义了所有支持的内容 MPEG-4是一种定义音频和视频(AV)数字数据压缩的方法。
用于存储基于时间的媒体内容的文件格式。它是一种通用格式,构成了许多其他更具体的文件格式(例如3GP、Motion JPEG 2000、MPEG-4 Part 14)的基础。
因此,您得到的结果中没有阴谋,您使用的压缩方法(或“编解码器”)是MPEG4,而您的手机生成的视频格式是3GP,实际上是媒体MPEG4压缩方案套件视频格式的一部分。MPEG-4是定义音频和视频(AV)数字数据压缩的方法。
用于存储基于时间的媒体内容的文件格式。它是一种通用格式,构成了许多其他更具体的文件格式(例如3GP、Motion JPEG 2000、MPEG-4 Part 14)的基础。
因此,您得到的结果中没有阴谋,您使用的压缩方法(或“编解码器”)是MPEG4,而您的手机生成的视频格式是3GP,这实际上是媒体MPEG4压缩方案套件视频格式的一部分。我不理解akkilis的解释 在官方的Android教程中, MPEG_4是“媒体文件格式”选项之一,与三个GPP并行。 int AAC_ADTS AAC ADTS文件格式 int AMR_NB AMR NB文件格式 int AMR_WB AMR WB文件格式 int默认值
int MPEG_4 MPEG4媒体文件格式 int RAW_AMR此常量在API级别16中被弃用。不推荐使用MediaRecorder.OutputFormat.AMR\u NB int ThreeGPP 3GPP媒体文件格式 还有另一个参数用于指定编码格式: int默认值
int H263
int H264
int MPEG_4_SP 在OP的代码中,他指定了文件格式和编码格式 videoRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); 录像机.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP)
因此,akkilis的解释似乎不适用于本例。我不理解akkilis的解释 在官方的Android教程中, MPEG_4是“媒体文件格式”选项之一,与三个GPP并行。 int AAC_ADTS AAC ADTS文件格式 int AMR_NB AMR NB文件格式 int AMR_WB AMR WB文件格式 int默认值
int MPEG_4 MPEG4媒体文件格式 int RAW_AMR此常量在API级别16中被弃用。不推荐使用MediaRecorder.OutputFormat.AMR\u NB int ThreeGPP 3GPP媒体文件格式 还有另一个参数用于指定编码格式: int默认值
int H263
int H264
int MPEG_4_SP 在OP的代码中,他指定了文件格式和编码格式 videoRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); 录像机.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP)
因此,akkilis的解释似乎不适用于此示例。请再详细说明一下好吗?请再详细说明一下好吗?这是否意味着我不能用MPEG4容器以MPEG4格式录制视频?您又一次感到困惑了。它采用MPEG4标准,但采用3gp格式,而3gp格式又是“mp4”的简化格式,专门为支持移动设备而设计。好的,我现在就知道了。我可以在不放入容器的情况下录制原始视频吗?我想如果这样做,系统本身会应用一些默认的压缩方案。但我对此并不确定。这是否意味着我不能用MPEG4容器以MPEG4格式录制视频?你又一次感到困惑了。它采用MPEG4标准,但采用3gp格式,而3gp格式又是“mp4”的简化格式,专门为支持移动设备而设计。好的,我现在就知道了。我可以在不放入容器的情况下录制原始视频吗?我想如果这样做,系统本身会应用一些默认的压缩方案。但我对此不确定。