如何在android中正确录制720p视频?那么如何正确设置视频的帧率呢?

发布于 2024-11-17 10:05:25 字数 1515 浏览 1 评论 0原文

如何在android中正确录制720p视频?以及如何正确设置视频的帧速率。

mParameters = mCameraDevice.getParameters();
        mParameters.setPreviewSize(1280,
                720);
mParameters.setPreviewFrameRate(30);

    mMediaRecorder = new MediaRecorder();

        // Unlock the camera object before passing it to media recorder.
        mCameraDevice.unlock();
        mMediaRecorder.setCamera(mCameraDevice);
        mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
        //mMediaRecorder.setProfile(mProfile);
        mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);




        mMediaRecorder.setMaxDuration(mMaxVideoDurationInMs);


        // Set output file.
        if (mStorageStatus != STORAGE_STATUS_OK) {
            mMediaRecorder.setOutputFile("/dev/null");
        } else {
            // Try Uri in the intent first. If it doesn't exist, use our own
            // instead.
            createVideoPath();
            mMediaRecorder.setOutputFile(mVideoFilename);

        }
        mMediaRecorder.setVideoSize(1280, 720);
        mMediaRecorder.setVideoFrameRate(30);

        mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());

我在 HTC HD 设备中测试了此代码。就可以成功录制了。但是当播放录制的视频时,屏幕只是绿屏并有声音。谁能解释一下视频大小和视频帧率之间的关系以及各种视频(音频)源和编码器的区别。

how to record rightly 720p video in android? And how to set correctly the frame rate of video for it.

mParameters = mCameraDevice.getParameters();
        mParameters.setPreviewSize(1280,
                720);
mParameters.setPreviewFrameRate(30);

    mMediaRecorder = new MediaRecorder();

        // Unlock the camera object before passing it to media recorder.
        mCameraDevice.unlock();
        mMediaRecorder.setCamera(mCameraDevice);
        mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
        //mMediaRecorder.setProfile(mProfile);
        mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);




        mMediaRecorder.setMaxDuration(mMaxVideoDurationInMs);


        // Set output file.
        if (mStorageStatus != STORAGE_STATUS_OK) {
            mMediaRecorder.setOutputFile("/dev/null");
        } else {
            // Try Uri in the intent first. If it doesn't exist, use our own
            // instead.
            createVideoPath();
            mMediaRecorder.setOutputFile(mVideoFilename);

        }
        mMediaRecorder.setVideoSize(1280, 720);
        mMediaRecorder.setVideoFrameRate(30);

        mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());

I test this code in HTC HD device. It can record successfully. But when play the recorded video, the screen is just green with sound. Who can give some explain the relation between video size and video frame rate and the difference of all kinds of video(audio) source and encoder.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

远昼 2024-11-24 10:05:25

您可以使用适当规格的相机以 720p 进行录制,但大多数设备在不将其缩小到标准清晰度的情况下无法显示 720p 视频。 720p 中的 720 指的是较小轴(高度)的像素度量,一般来说,大多数设备的屏幕分辨率不是 1280x720px。请随意发布有关如何解码和播放视频的代码。

You can record at 720p with a properly specced camera, but most devices will not be able to display 720p video without scaling it down to standard def. the 720 in 720p refers to its pixel measure of the smaller axis (height) and in general most devices' screen resolutions are NOT 1280x720px. Feel free to post code about how you decode and playback the video.

无人接听 2024-11-24 10:05:25

对于解码,您可以使用ffmpeg。更多信息可以在这里找到:

当您使用ffmpeg时,可以使用CamcorderProfile进行记录。

For decoding you can use the ffmpeg. More information can found here:

When you use ffmpeg, you can use the CamcorderProfile for the record.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文