Skip to content
This repository was archived by the owner on Jan 3, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions doc/chinese.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# flutter_video_compress

压缩视频生成新路径,选择保留源视频或删除它。从视频路径获取视频缩略图并提供视频信息。方便的处理压缩视频。考虑减少应用程序大小不在IOS中使用FFmpeg
压缩视频并保存至新目录位置(可选择压缩后删除源文件). 获取视频缩略图及视频属性. 轻松处理压缩视频. (考虑到应用大小, 不在 IOS 中使用 FFmpeg 组件)

<p align="left">
<a href="https://pub.dartlang.org/packages/flutter_video_compress"><img alt="pub version" src="https://img.shields.io/pub/v/flutter_video_compress.svg"></a>
Expand All @@ -23,13 +23,13 @@
## 用户指南

**安装**
添加[flutter_video_compress](https://pub.dartlang.org/packages/flutter_video_compress)到你的pubspec.yaml文件中.
添加[flutter_video_compress](https://pub.dartlang.org/packages/flutter_video_compress)到`pubspec.yaml`:
```yaml
dependencies:
flutter_video_compress: ^0.3.x
```

**创建一个实例**
**创建一个 FlutterVideoCompress 实例**
```dart
final _flutterVideoCompress = FlutterVideoCompress();
```
Expand All @@ -52,7 +52,7 @@ final thumbnailFile = await _flutterVideoCompress.getThumbnailWithFile(
);
```

**转换视频为gif**
**视频转 Gif**
```dart
final file = await _flutterVideoCompress.convertVideoToGif(
videoFile.path,
Expand All @@ -63,16 +63,16 @@ final file = await _flutterVideoCompress.convertVideoToGif(
debugPrint(file.path);
```

**获取媒体信息**
> 现在支持持视频
**获取音视频信息**
> 现在支持视频

```dart
final info = await _flutterVideoCompress.getMediaInfo(file.path);
debugPrint(info.toJson().toString());
```

**压缩视频**
> 移动端平台及web平台视频格式是兼容的
> 同时兼容移动端和Web端

```dart
final info = await _flutterVideoCompress.compressVideo(
Expand All @@ -83,26 +83,26 @@ final info = await _flutterVideoCompress.compressVideo(
debugPrint(info.toJson().toString());
```

**检查压缩状态**
**获取压缩状态**
```dart
_flutterVideoCompress.isCompressing
```

**停止压缩**
> Android 会打印 InterruptedException 错误, 但是不会影响使用
> Android 会报 `InterruptedException` , 但不影响使用

```dart
await _flutterVideoCompress.cancelCompression()
```

**删除所有缓存文件**
> 删除这个插件生成的所有文件,我想你应该知道你在做什么
**清理缓存**
> 清理插件生成的所有缓存文件

```dart
await _flutterVideoCompress.deleteAllCache()
```

**订阅转换流**
**监听转换流**
```dart
class ... extends State<MyApp> {
Subscription _subscription;
Expand Down Expand Up @@ -135,20 +135,20 @@ class ... extends State<MyApp> {
|cancelCompression|`none`|取消压缩|`Future<void>`|
|deleteAllCache|`none`|删除位于'flutter_video_compress'的所有文件|`Future<bool>`|

## 订阅流
## 监听流
|Subscriptions|Description|Stream|
|--|--|--|
|compressProgress$|订阅压缩状态流|double `progress`|
|compressProgress$|监听压缩状态流|double `progress`|

## 注意
如果你的程序在使用这个插件后体积明显增大,可以使用下面的方法优化你的体积
如果你的程序在使用这个插件后体积明显增大,可以使用下面的方法进行优化:

* 将`x86`相关文件排除 (`./assets`)

* 这个库不使用`ffprobe`,只使用`ffmpeg`,但你的应用中仍然有`ffprobe`,你需要排除他 (`asssets/arm` or `assets/x86`)
* 这个库不使用`ffprobe`,只使用`ffmpeg`,但你的应用中包含`ffprobe`,进行排除 (`asssets/arm` or `assets/x86`)

将此配置添加到`build.gradle`文件中
**不要在Android模拟器**上使用**`ignoreAssetsPattern'!X86'`,将会崩溃
**请不要在Android模拟器**上使用**`ignoreAssetsPattern'!X86'`,会崩溃!

```gradle
android {
Expand Down Expand Up @@ -192,7 +192,7 @@ end

[详情](https://github.com/flutter/flutter/issues/16049#issuecomment-382629492)

如果你的程序从未使用过swift的插件,你或许会遇到下面的报错,这时候你需要添加下例代码`ios/Podfile`。
如果你的程序从未使用过swift的插件,你或许会遇到下面的报错,这时候你需要添加如下代码`ios/Podfile`。
> The 'Pods-Runner' target has transitive dependencies that include static binaries

```ruby
Expand All @@ -202,11 +202,11 @@ pre_install do |installer|
end
```

**如果上述方法不管用,你可以去报错的仓库提issue,理由是 不能支持swift(Can't support swift)**
**若上述方法无效,你可以去报错的仓库提issue,理由是 不能支持swift(Can't support swift)**

[详情](https://github.com/flutter/flutter/issues/16049#issue-309580132)

如果遇到`Regift`报错你可能需要将你的配置文件改成这样
如果遇到`Regift`报错你可能需要将你的配置文件调整为

> - `Regift` does not specify a Swift version and none of the targets (`Runner`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.

Expand All @@ -231,4 +231,7 @@ end
## 贡献指南

欢迎每一个贡献
<!-- 首先请查看[贡献指南](contributing.md)。 -->
<!-- 首先请查看[贡献指南](contributing.md)。 -->

## 翻译
[HarrisonQI](https://github.com/HarrisonQi) 协助翻译了此 README