flutter - iPhone上的Flutter Camera Plugin横向视频
问题描述
在我的 iPhone X 上横向运行相机插件示例应用程序时,视频没有以正确的方向捕获。它在肖像中效果很好。
发布规范.yaml
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
camera: ^0.4.2
path_provider: ^0.5.0
video_player: ^0.10.0
firebase_core: ^0.2.5
扑医生
[✓] Flutter (Channel unknown, v1.1.0, on Mac OS X 10.14.3 18D109, locale en-AU)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.2)
[✓] Connected device (1 available)
解决方案
直到官方包中的支持登陆,我已经成功flutter_ffmpeg
设置了正确的元数据。
const int AV_LOG_ERROR = 16;
final FlutterFFmpeg _flutterFFmpeg = new FlutterFFmpeg();
_flutterFFmpeg.setLogLevel(AV_LOG_ERROR);
/// The :s:v:0 after -metadata is the stream specifier,
/// which just tells ffmpeg to which stream it should add the metadata.
/// :s stands for the streams of the input file,
/// :v selects video streams and the number is the stream index,
/// zero-based - so this will select the first video stream.
/// The -c option specifies the codec
/// to be used, with copy for just copying the streams, without re-encoding.
final String looselessConversion = '-i $videoPath.mp4 -c copy -metadata:s:v:0 rotate=90 $videoPath-processed.mp4';
try {
final int returnCode = await _flutterFFmpeg.execute(looselessConversion);
if(returnCode == 0) {
// delete the origina video file
await File('$videoPath.mp4').delete();
} else {
throw _flutterFFmpeg.getLastCommandOutput();
}
} catch (e) {
print('video processing error: $e);
}
因为我没有对视频进行编码(只是编辑元数据),所以对于任何长度的视频文件,该过程在不到 10 毫秒的时间内完成。
推荐阅读
- c# - 从 AddHttpClient 访问 IMemoryCache 服务
- c# - 仅出于多态目的使用空基类?
- javascript - 当父组件向子组件传递数据并渲染子组件时显示加载栏。反应.JS
- c# - 来自另一个库的 Ef Core 3.1 DbSet
- windows - 如何在不注销并重新登录的情况下在 Windows 上启动自动运行应用程序?
- python - 如何找到相同字典值的总数?
- docker - 在 docker 容器中运行 aws-cdk 会破坏 lambda 捆绑。无论如何,我如何使用 nodejs lambda 捆绑?
- html - CSS Flexbox 以 % 宽度包裹项目
- javascript - 一些人可以帮助我使用 Angularjs 使用 Syncfusion ej-angular 在形状中添加 HTML 元素
- nginx - 强制在 NGINX 中进行块传输以获取代理响应