Skip to content

Commit f4e9d9d

Browse files
committed
chore: remove ffmpeg kit.
1 parent 18d9722 commit f4e9d9d

File tree

6 files changed

+17
-219
lines changed

6 files changed

+17
-219
lines changed

android/app/build.gradle

-45
Original file line numberDiff line numberDiff line change
@@ -95,51 +95,6 @@ android {
9595
outputFileName = "F-DEMO_${versionName}(${versionCode})_${buildType.name}_${buildTime()}.apk"
9696
}
9797
}
98-
99-
packagingOptions {
100-
// other options here
101-
102-
/* Fix for ffmpeg-kit-react-native START */
103-
pickFirst 'lib/arm64-v8a/libgojni.so'
104-
pickFirst 'lib/armeabi-v7a/libgojni.so'
105-
pickFirst 'lib/x86/libgojni.so'
106-
pickFirst 'lib/x86_64/libgojni.so'
107-
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
108-
pickFirst 'lib/x86/libc++_shared.so'
109-
pickFirst 'lib/x86_64/libc++_shared.so'
110-
pickFirst 'lib/arm64-v8a/libc++_shared.so'
111-
pickFirst 'lib/arm64-v8a/libavcodec.so'
112-
pickFirst 'lib/arm64-v8a/libavformat.so'
113-
pickFirst 'lib/arm64-v8a/libavutil.so'
114-
pickFirst 'lib/arm64-v8a/libswscale.so'
115-
pickFirst 'lib/arm64-v8a/libavdevice.so'
116-
pickFirst 'lib/arm64-v8a/libavfilter.so'
117-
pickFirst 'lib/arm64-v8a/libffmpegkit.so'
118-
pickFirst 'lib/arm64-v8a/libffmpegkit_abidetect.so'
119-
pickFirst 'lib/arm64-v8a/libswresample.so'
120-
pickFirst 'lib/arm64-v8a/libswscale.so'
121-
pickFirst 'lib/x86/libavcodec.so'
122-
pickFirst 'lib/x86/libavformat.so'
123-
pickFirst 'lib/x86/libavutil.so'
124-
pickFirst 'lib/x86/libswscale.so'
125-
pickFirst 'lib/x86/libavdevice.so'
126-
pickFirst 'lib/x86/libavfilter.so'
127-
pickFirst 'lib/x86/libffmpegkit.so'
128-
pickFirst 'lib/x86/libffmpegkit_abidetect.so'
129-
pickFirst 'lib/x86/libswresample.so'
130-
pickFirst 'lib/x86/libswscale.so'
131-
pickFirst 'lib/x86_64/libavcodec.so'
132-
pickFirst 'lib/x86_64/libavformat.so'
133-
pickFirst 'lib/x86_64/libavutil.so'
134-
pickFirst 'lib/x86_64/libswscale.so'
135-
pickFirst 'lib/x86_64/libavdevice.so'
136-
pickFirst 'lib/x86_64/libavfilter.so'
137-
pickFirst 'lib/x86_64/libffmpegkit.so'
138-
pickFirst 'lib/x86_64/libffmpegkit_abidetect.so'
139-
pickFirst 'lib/x86_64/libswresample.so'
140-
pickFirst 'lib/x86_64/libswscale.so'
141-
/* Fix for ffmpeg-kit-react-native END */
142-
}
14398
}
14499

145100
flutter {

openim_common/lib/src/utils/utils.dart

-108
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import 'dart:async';
22
import 'dart:convert';
33
import 'dart:io';
44

5-
import 'package:ffmpeg_kit_flutter_full_gpl/ffmpeg_kit.dart';
6-
import 'package:ffmpeg_kit_flutter_full_gpl/ffprobe_kit.dart';
7-
import 'package:ffmpeg_kit_flutter_full_gpl/return_code.dart';
8-
import 'package:ffmpeg_kit_flutter_full_gpl/session_state.dart';
95
import 'package:path_provider_platform_interface/path_provider_platform_interface.dart';
106
import 'package:azlistview/azlistview.dart';
117
import 'package:collection/collection.dart';
@@ -169,110 +165,6 @@ class IMUtils {
169165
return mediaInfo;
170166
}
171167

172-
/// Extracts a thumbnail (PNG image) from the first frame of a video file.
173-
///
174-
/// Returns the generated thumbnail file. If extraction fails, throws an exception.
175-
static Future<File> getVideoThumbnail(File file) async {
176-
final path = file.path;
177-
final fileName = path.split('/').last.split('.').first; // Get base name without extension
178-
final tempDir = await createTempDir(dir: 'video');
179-
final targetPath = '$tempDir/$fileName.png';
180-
181-
// FFmpeg command to extract the first frame at 0 seconds
182-
final ffmpegCommand = '-i "$path" -ss 0 -vframes 1 -q:v 15 -y "$targetPath"';
183-
final session = await FFmpegKit.execute(ffmpegCommand);
184-
185-
final state = await session.getState();
186-
final returnCode = await session.getReturnCode();
187-
188-
if (state == SessionState.failed || !ReturnCode.isSuccess(returnCode)) {
189-
Logger().printError(info: 'Failed to generate thumbnail: $ffmpegCommand');
190-
throw Exception('Thumbnail extraction failed for $path');
191-
}
192-
193-
session.cancel();
194-
final thumbnail = File(targetPath);
195-
196-
// Verify the thumbnail file exists
197-
if (!thumbnail.existsSync()) {
198-
Logger().printError(info: 'Thumbnail file not found at $targetPath');
199-
throw Exception('Thumbnail file was not created');
200-
}
201-
202-
return thumbnail;
203-
}
204-
205-
/// compress video
206-
/// Compresses a video file and returns the resulting file.
207-
/// Aims for speed priority, moderate quality, and minimal file size while keeping resolution unchanged.
208-
static Future<File?> compressVideoAndGetFile(File file) async {
209-
final path = file.path;
210-
final fileName = path.split('/').last;
211-
final tempDir = await createTempDir(dir: 'video');
212-
final targetPath = '$tempDir/$fileName';
213-
214-
// Get media information using FFprobe
215-
final mediaInfo = await FFprobeKit.getMediaInformation(path);
216-
final streams = mediaInfo.getMediaInformation()?.getStreams() ?? [];
217-
final fileSize = int.tryParse(mediaInfo.getMediaInformation()?.getSize() ?? '0') ?? 0;
218-
mediaInfo.cancel();
219-
220-
// Check video and audio codecs
221-
final isH264265 =
222-
streams.any((s) => s.getCodec()?.contains('h264') == true || s.getCodec()?.contains('hevc') == true);
223-
final audioStream = streams.firstWhereOrNull((s) => s.getType()?.contains('audio') == true);
224-
final isAAC = audioStream?.getCodec()?.toLowerCase().contains('aac') == true;
225-
226-
// If target file exists and is H.264, return it directly (assuming no further processing needed)
227-
if (File(targetPath).existsSync() && isH264265) {
228-
return File(targetPath);
229-
}
230-
231-
// Default FFmpeg command for compression
232-
String ffmpegCommand = '-i "$path" -preset fast -crf 28 -threads 4 -c:a aac -b:a 96k -c:v libx264 -y "$targetPath"';
233-
234-
if (isH264265) {
235-
if (isAAC) {
236-
const sizeThreshold = 50 * 1024 * 1024; // 50MB threshold
237-
if (fileSize > sizeThreshold) {
238-
// Compress video if size exceeds threshold
239-
final compressed = await VideoCompress.compressVideo(
240-
path,
241-
quality: VideoQuality.Res1280x720Quality, // Moderate quality for smaller file size
242-
);
243-
Logger.print('Compressed video size: ${compressed?.file?.lengthSync()} bytes');
244-
245-
return compressed?.file ?? file; // Return compressed file or original on failure
246-
} else {
247-
// Copy file directly if below threshold
248-
file.copySync(targetPath);
249-
250-
return File(targetPath);
251-
}
252-
} else {
253-
// Only convert audio to AAC, copy video stream for speed
254-
ffmpegCommand = '-i "$path" -c:v copy -c:a aac -b:a 96k -threads 4 -y "$targetPath"';
255-
}
256-
}
257-
// Execute FFmpeg command
258-
Logger.print('executing FFmpeg command: $ffmpegCommand');
259-
final session = await FFmpegKit.execute(ffmpegCommand);
260-
final state = await session.getState();
261-
final returnCode = await session.getReturnCode();
262-
263-
if (state == SessionState.failed || !ReturnCode.isSuccess(returnCode)) {
264-
// Log error and fallback to copying original file
265-
Logger().printError(info: "FFmpeg failed: $ffmpegCommand");
266-
file.copySync(targetPath);
267-
268-
return File(targetPath);
269-
}
270-
271-
session.cancel();
272-
273-
return File(targetPath);
274-
}
275-
276168
static Future<File?> compressImageAndGetFile(File file, {int quality = 80}) async {
277169
var path = file.path;
278170
var name = path.substring(path.lastIndexOf("/") + 1).toLowerCase();

openim_common/pubspec.lock

+16-32
Original file line numberDiff line numberDiff line change
@@ -438,22 +438,6 @@ packages:
438438
url: "https://pub.dev"
439439
source: hosted
440440
version: "2.1.3"
441-
ffmpeg_kit_flutter_full_gpl:
442-
dependency: "direct main"
443-
description:
444-
name: ffmpeg_kit_flutter_full_gpl
445-
sha256: "4f269bcb636bfcb544e5b4d65c706a3d311839970cb42638e72406410c1b5b7b"
446-
url: "https://pub.dev"
447-
source: hosted
448-
version: "6.0.3"
449-
ffmpeg_kit_flutter_platform_interface:
450-
dependency: transitive
451-
description:
452-
name: ffmpeg_kit_flutter_platform_interface
453-
sha256: addf046ae44e190ad0101b2fde2ad909a3cd08a2a109f6106d2f7048b7abedee
454-
url: "https://pub.dev"
455-
source: hosted
456-
version: "0.2.1"
457441
file:
458442
dependency: transitive
459443
description:
@@ -914,10 +898,10 @@ packages:
914898
dependency: transitive
915899
description:
916900
name: html
917-
sha256: "9475be233c437f0e3637af55e7702cbbe5c23a68bd56e8a5fa2d426297b7c6c8"
901+
sha256: "6d1264f2dffa1b1101c25a91dff0dc2daee4c18e87cd8538729773c073dbf602"
918902
url: "https://pub.dev"
919903
source: hosted
920-
version: "0.15.5+1"
904+
version: "0.15.6"
921905
http:
922906
dependency: transitive
923907
description:
@@ -2271,10 +2255,10 @@ packages:
22712255
dependency: transitive
22722256
description:
22732257
name: video_player_avfoundation
2274-
sha256: "84b4752745eeccb6e75865c9aab39b3d28eb27ba5726d352d45db8297fbd75bc"
2258+
sha256: "9ee764e5cd2fc1e10911ae8ad588e1a19db3b6aa9a6eb53c127c42d3a3c3f22f"
22752259
url: "https://pub.dev"
22762260
source: hosted
2277-
version: "2.7.0"
2261+
version: "2.7.1"
22782262
video_player_platform_interface:
22792263
dependency: transitive
22802264
description:
@@ -2287,10 +2271,10 @@ packages:
22872271
dependency: transitive
22882272
description:
22892273
name: video_player_web
2290-
sha256: "3ef40ea6d72434edbfdba4624b90fd3a80a0740d260667d91e7ecd2d79e13476"
2274+
sha256: e8bba2e5d1e159d5048c9a491bb2a7b29c535c612bb7d10c1e21107f5bd365ba
22912275
url: "https://pub.dev"
22922276
source: hosted
2293-
version: "2.3.4"
2277+
version: "2.3.5"
22942278
visibility_detector:
22952279
dependency: "direct main"
22962280
description:
@@ -2319,18 +2303,18 @@ packages:
23192303
dependency: transitive
23202304
description:
23212305
name: wakelock_plus
2322-
sha256: b90fbcc8d7bdf3b883ea9706d9d76b9978cb1dfa4351fcc8014d6ec31a493354
2306+
sha256: a474e314c3e8fb5adef1f9ae2d247e57467ad557fa7483a2b895bc1b421c5678
23232307
url: "https://pub.dev"
23242308
source: hosted
2325-
version: "1.2.11"
2309+
version: "1.3.2"
23262310
wakelock_plus_platform_interface:
23272311
dependency: transitive
23282312
description:
23292313
name: wakelock_plus_platform_interface
2330-
sha256: "70e780bc99796e1db82fe764b1e7dcb89a86f1e5b3afb1db354de50f2e41eb7a"
2314+
sha256: e10444072e50dbc4999d7316fd303f7ea53d31c824aa5eb05d7ccbdd98985207
23312315
url: "https://pub.dev"
23322316
source: hosted
2333-
version: "1.2.2"
2317+
version: "1.2.3"
23342318
watcher:
23352319
dependency: transitive
23362320
description:
@@ -2351,18 +2335,18 @@ packages:
23512335
dependency: transitive
23522336
description:
23532337
name: web_socket
2354-
sha256: "3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83"
2338+
sha256: bfe6f435f6ec49cb6c01da1e275ae4228719e59a6b067048c51e72d9d63bcc4b
23552339
url: "https://pub.dev"
23562340
source: hosted
2357-
version: "0.1.6"
2341+
version: "1.0.0"
23582342
web_socket_channel:
23592343
dependency: transitive
23602344
description:
23612345
name: web_socket_channel
2362-
sha256: "0b8e2457400d8a859b7b2030786835a28a8e80836ef64402abef392ff4f1d0e5"
2346+
sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8
23632347
url: "https://pub.dev"
23642348
source: hosted
2365-
version: "3.0.2"
2349+
version: "3.0.3"
23662350
webview_flutter:
23672351
dependency: "direct main"
23682352
description:
@@ -2391,10 +2375,10 @@ packages:
23912375
dependency: transitive
23922376
description:
23932377
name: webview_flutter_wkwebview
2394-
sha256: bf0745adeaca48a3105473440cffade47720fe2d56514de4e86f0d363439c4a7
2378+
sha256: c9f9be526fa0d3347374ceaa05c4b3acb85f4f112abd62f7d74b7d301fa515ff
23952379
url: "https://pub.dev"
23962380
source: hosted
2397-
version: "3.18.6"
2381+
version: "3.20.0"
23982382
wechat_assets_picker:
23992383
dependency: "direct main"
24002384
description:

openim_common/pubspec.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ dependencies:
6060
local_auth: ^2.2.0
6161
gesture_password_widget: ^2.0.1
6262
sound_mode: ^2.0.2
63-
device_info_plus: ^10.1.2
63+
device_info_plus: 10.1.2
6464
visibility_detector: ^0.4.0+2
6565
extended_text_field: ^16.0.0
6666
extended_text: ^13.0.2
@@ -77,7 +77,6 @@ dependencies:
7777
syncfusion_flutter_core: ^25.2.7
7878
syncfusion_flutter_sliders: ^25.2.7
7979
flutter_map: ^6.0.1
80-
ffmpeg_kit_flutter_full_gpl: 6.0.3
8180
pull_to_refresh_new: ^2.0.5
8281
geolocator: ^12.0.0
8382
fixnum: ^1.1.0

openim_live/pubspec.lock

-16
Original file line numberDiff line numberDiff line change
@@ -361,22 +361,6 @@ packages:
361361
url: "https://pub.dev"
362362
source: hosted
363363
version: "2.1.3"
364-
ffmpeg_kit_flutter_full_gpl:
365-
dependency: transitive
366-
description:
367-
name: ffmpeg_kit_flutter_full_gpl
368-
sha256: "4f269bcb636bfcb544e5b4d65c706a3d311839970cb42638e72406410c1b5b7b"
369-
url: "https://pub.dev"
370-
source: hosted
371-
version: "6.0.3"
372-
ffmpeg_kit_flutter_platform_interface:
373-
dependency: transitive
374-
description:
375-
name: ffmpeg_kit_flutter_platform_interface
376-
sha256: addf046ae44e190ad0101b2fde2ad909a3cd08a2a109f6106d2f7048b7abedee
377-
url: "https://pub.dev"
378-
source: hosted
379-
version: "0.2.1"
380364
file:
381365
dependency: transitive
382366
description:

pubspec.lock

-16
Original file line numberDiff line numberDiff line change
@@ -494,22 +494,6 @@ packages:
494494
url: "https://pub.dev"
495495
source: hosted
496496
version: "2.1.3"
497-
ffmpeg_kit_flutter_full_gpl:
498-
dependency: transitive
499-
description:
500-
name: ffmpeg_kit_flutter_full_gpl
501-
sha256: "4f269bcb636bfcb544e5b4d65c706a3d311839970cb42638e72406410c1b5b7b"
502-
url: "https://pub.dev"
503-
source: hosted
504-
version: "6.0.3"
505-
ffmpeg_kit_flutter_platform_interface:
506-
dependency: transitive
507-
description:
508-
name: ffmpeg_kit_flutter_platform_interface
509-
sha256: addf046ae44e190ad0101b2fde2ad909a3cd08a2a109f6106d2f7048b7abedee
510-
url: "https://pub.dev"
511-
source: hosted
512-
version: "0.2.1"
513497
file:
514498
dependency: transitive
515499
description:

0 commit comments

Comments
 (0)