gpt4 book ai didi

Android 使用 CamcorderProfile 捕捉慢动作视频

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:15:34 25 4
gpt4 key购买 nike

我正尝试在我的 Nexus 5x 上拍摄慢动作视频。这就是我配置媒体记录器的方式:

CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH_SPEED_HIGH);

mMediaRecorder = new MediaRecorder();

// Step 1: Unlock and set camera to MediaRecorder
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);

// Step 2: Set sources
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

// Step 3: Set the high speed CamcorderProfile
mMediaRecorder.setProfile(profile);

// Step 4: Set output file
// Step 5: Prepare media recorder
// Step 6: Capture video

问题是,捕获的视频不是我的设备支持的 120 fps 慢动作视频。它们是常规的 29 fps 视频。

我经历了this answer ,在 official documentation 中讨论了以下内容:

For all the high speed profiles defined below ((from QUALITY_HIGH_SPEED_LOW to QUALITY_HIGH_SPEED_2160P), they are similar as normal recording profiles, with just higher output frame rate and bit rate. Therefore, setting these profiles with setProfile(CamcorderProfile) without specifying any other encoding parameters will produce high speed videos rather than slow motion videos that have different capture and output (playback) frame rates. To record slow motion videos, the application must set video output (playback) frame rate and bit rate appropriately via setVideoFrameRate(int) and setVideoEncodingBitRate(int) based on the slow motion factor. If the application intends to do the video recording with MediaCodec encoder, it must set each individual field of MediaFormat similarly according to this CamcorderProfile.

我不明白的是,setProfile已经使用从所选 CamcorderProfile 派生的参数调用了两个方法 setVideoFrameRate 和 setVideoEncodingBitRate。为什么我需要再次给他们打电话?我在这里缺少什么?

如有任何帮助,我们将不胜感激。对于我的生活,我无法让它工作!

编辑:我试过像这样调用方法,但它仍然捕获正常速度的视频:

mMediaRecorder.setVideoFrameRate(profile.videoFrameRate/4); 
mMediaRecorder.setVideoEncodingBitRate(profile.videoBitRate/4);

1/4,因为 CamcorderProfile.QUALITY_HIGH_SPEED_HIGH 宣传的帧速率是 120,我想捕捉文档 here 中所述的 30 fps 视频

public int videoFrameRate

Added in API level 8 The target video frame rate in frames per second.

This is the target recorded video output frame rate per second if the application configures the video recording via setProfile(CamcorderProfile) without specifying any other MediaRecorder encoding parameters. For example, for high speed quality profiles (from QUALITY_HIGH_SPEED_LOW to QUALITY_HIGH_SPEED_2160P), this is the frame rate where the video is recorded and played back with. If the application intends to create slow motion use case with the high speed quality profiles, it must set a different video frame rate that is corresponding to the desired output (playback) frame rate via setVideoFrameRate(int). For example, if QUALITY_HIGH_SPEED_720P advertises 240fps videoFrameRate in the CamcorderProfile, and the application intends to create 1/8 factor slow motion recording videos, the application must set 30fps via setVideoFrameRate(int). Failing to do so will result in high speed videos with normal speed playback frame rate (240fps for above example). If the application intends to do the video recording with MediaCodec encoder, it must set each individual field of MediaFormat similarly according to this CamcorderProfile.

最佳答案

mMediaRecorder.setVideoFrameRate(QUALITY_HIGH_SPEED_LOW);

mMediaRecorder.setVideoFrameRate(QUALITY_HIGH_SPEED_HIGH);

关于Android 使用 CamcorderProfile 捕捉慢动作视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35116159/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com