gpt4 book ai didi

reactjs - 仅当以 30 FPS 拍摄视频时,FFmpeg 视频输出才被放大?

转载 作者:行者123 更新时间:2023-12-04 23:09:57 25 4
gpt4 key购买 nike

我已经使用 FFmpeg 大约一个月了,它很棒。
我正在 IOS 上以 60FPS 或 30FPS 的速度拍摄视频。我将视频大小调整为 1:1(或 4:3)。
我正在使用 https://github.com/mrousavy/react-native-vision-camera 拍摄我的视频
使用默认的 60FPS 一切正常。但是,由于某种原因,当视频以 30FPS 拍摄时,视频在 FFmpeg 执行后被放大,我不知道为什么......
这是我的 FFmpeg 命令在我的函数中的样子(React JS Hook ):

  const onMediaCaptured = useCallback(
(media: PhotoFile | VideoFile, type: 'photo' | 'video') => {
setIsProcessingMedia(!isProcessingMedia);

var path =
type === 'photo'
? RNFS.DocumentDirectoryPath + '/after.png'
: RNFS.DocumentDirectoryPath + '/after.mp4';

const portraitCrop =
type === 'video' ? 'crop=1080:1350' : 'crop=1350:1080';

const ffMPEGcmd = isSquareRatio
? `-y -i ${
media.path
} -aspect 1:1 -vf "crop=1080:1080:exact=1, scale=1080:1080, ${
type === 'photo' ? 'transpose=1' : null
}" -qscale 0 -b:v 10M ${path}`
: `-y -i ${media.path} -vf "${portraitCrop}, ${
type === 'photo' ? 'transpose=1' : null
}" -b:v 10M -qscale 0 ${path}`;

FFmpegKit.execute(ffMPEGcmd).then(async session => {
const returnCode = await session.getReturnCode();
if (ReturnCode.isSuccess(returnCode)) {
// SUCCESS
FFprobeKit.getMediaInformation(path)
.then(async (session: MediaInformationSessionCamera) => {
const information: MediaInformation =
await session.getMediaInformation();
const output = await session.getOutput();

const outputJSON = JSON.parse(output);
const newOne = outputJSON;

const videoHeight = newOne.streams[0].height;
const videoWidth = newOne.streams[0].width;

setIsProcessingMedia(false);

Actions.push('cameraMediaCaptured', {
isSquareRatio: isSquareRatio,
type: type,
ratio: isSquareRatio ? 1080 / 1080 : 1350 / 1080,
color: props.color,
category: props.category,
needsCrop: true,
videoHeight: videoHeight,
videoWidth: videoWidth,
aspectRatio: videoHeight / videoWidth,
});
})
.catch(error => console.error(error));
} else if (ReturnCode.isCancel(returnCode)) {
// CANCEL
} else {
// ERROR
alert('error');
}
});
},
[isSquareRatio, props.category, props.color, isProcessingMedia],
);
我很感激我能得到的任何反馈!
干杯。

最佳答案

它是否以 30 和 60 fps 的相同分辨率捕获视频?如果没有,30 fps 为您提供更高分辨率的视频,crop过滤器将有效地为您提供缩放视频。改用输入大小表达式:类似于 crop=ih:ih阅读 the documentation .那里也有很多例子。如果您希望使用更复杂的表达式,因此您不需要在 javascript 中进行纵向/横向检测,请查看 the FFmpeg expression syntax也是。

关于reactjs - 仅当以 30 FPS 拍摄视频时,FFmpeg 视频输出才被放大?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71850822/

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