Android 设备无法在 Jelly Bean 4.2.2 上捕捉低质量视频

标签 android video-capture

看来,即使我将录像机配置文件设置为低,视频的质量也是最高的。

这是我的代码:

        camera.setDisplayOrientation(90);
        camera.unlock();
        recorder.reset();
        recorder.setCamera(camera);
        recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
        recorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));

 //when removing these comments I get an exception on my 4.2.2 device when calling start() on the recorder.
/*      recorder.setVideoFrameRate(24);
        recorder.setVideoSize(480, 360);

*/      
        recorder.setOrientationHint(90);
        file = FileUtils.getFileName(FileTypes.VIDEO);
        if (!file.exists()) {
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        recorder.setOutputFile(FileUtils.getFileName(FileTypes.VIDEO).toString());
        recorder.setMaxDuration(45000);

最佳答案

试试这个。虽然这看起来与您的代码相同,但它对我有用。为 CamcorderProfile 创建一个单独的实例并将记录器配置文件设置为此实例。

  CamcorderProfile cprofileLow = CamcorderProfile
            .get(CamcorderProfile.QUALITY_LOW);
    recorder.setProfile(cprofileLow);
    recorder.setOutputFile("/sdcard/videocapture_example.mp4");
    recorder.setMaxDuration(50000); // 50 seconds
    recorder.setMaxFileSize(3000000); // Approximately 3 megabytes

请注意,您拥有高端设备(因为您的设备是4.2.2),您可能会获得相对较好的分辨率,这是您设备中可能的最低分辨率。

关于Android 设备无法在 Jelly Bean 4.2.2 上捕捉低质量视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16170218/

相关文章:

android - 为什么框架布局没有正确绘制 z 索引?

android - YouTubePlayerSupportFragment-initialize() 方法中的空指针异常

bash - 下载直播流时,如何使 youtube-dl 或 streamlink 在一段时间后停止

opencv - 使用 OpenCV 捕获多播 UDP 视频流

android - 用于创建丰富/复杂界面的书籍、教程或资源 (android)

android - 来自 drawable 或 blob 的图像

android - 这个系统是有序广播还是正常广播?

android - 如何在 Android 上跨各种设备可靠地捕获低分辨率视频?

OpenCV 打不开其他电脑上的视频

windows - 在 Windows 上捕获和显示实时摄像头内容