iPhone 上的 Flutter Camera 插件风景视频

标签 flutter video-capture

在我的 iPhone X 上横向运行相机插件示例应用程序时,视频无法以正确的方向捕获。 它在肖像中效果很好。

enter image description here

pubspec.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 医生

[✓] 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 毫秒的时间内完成。

关于iPhone 上的 Flutter Camera 插件风景视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55329901/

相关文章:

flutter :参数格式不正确

c++ - 使用 OpenCV 从电视 USB 调谐器访问流

opencv - 以 60 fps 的高清格式将视频流式传输到 PC

ios - 如何从 CMSampleBufferRef 获取字节,通过网络发送

flutter - 当应用程序关闭时保存数据的状态管理器

dart - Flutter或Dart:如何获取设备信息,例如CPU计数,总内存和存储空间等

firebase - 如何基于Flutter中FutureBuilder中另一个Firebase查询的值从Firebase查询获取数据?

video - FFMPEG 元数据不适用于段格式

c++ - 使用 C/C++ 进行视频上采样

flutter - 在 InkWell 中包装卡片时波纹效果不起作用