Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mob] streaming queue fixes #5105

Merged
merged 4 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
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
60 changes: 41 additions & 19 deletions mobile/lib/services/preview_video_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,15 @@ class PreviewVideoStore {
}
}

var (props, result) = await checkFileForPreviewCreation(enteFile);

if (result) {
return;
}

if (uploadingFileId >= 0) {
if (uploadingFileId == enteFile.uploadedFileID) return;

_items[enteFile.uploadedFileID!] = PreviewItem(
status: PreviewItemStatus.inQueue,
file: enteFile,
Expand All @@ -158,7 +166,7 @@ class PreviewVideoStore {
);
Bus.instance.fire(PreviewUpdatedEvent(_items));

final props = await getVideoPropsAsync(file);
props = await getVideoPropsAsync(file);
final fileSize = enteFile.fileSize ?? file.lengthSync();

final videoData = List.from(props?.propData?["streams"] ?? [])
Expand Down Expand Up @@ -571,6 +579,34 @@ class PreviewVideoStore {
}
}

Future<(FFProbeProps?, bool)> checkFileForPreviewCreation(
EnteFile enteFile,
) async {
final fileSize = enteFile.fileSize;
FFProbeProps? props;

if (fileSize != null && fileSize <= 10 * 1024 * 1024) {
final file = await getFile(enteFile, isOrigin: true);
if (file != null) {
props = await getVideoPropsAsync(file);
final videoData = List.from(props?.propData?["streams"] ?? [])
.firstWhereOrNull((e) => e["type"] == "video");

final codec = videoData["codec_name"]?.toString().toLowerCase();
final codecIsH264 = codec?.contains("h264") ?? false;

if (codecIsH264) {
if (_items.containsKey(enteFile.uploadedFileID!)) {
_items.remove(enteFile.uploadedFileID!);
Bus.instance.fire(PreviewUpdatedEvent(_items));
}
return (props, true);
}
}
}
return (props, false);
}

// get all files after cutoff date and add it to queue for preview creation
// only run when video streaming is enabled
Future<void> putFilesForPreviewCreation() async {
Expand All @@ -597,25 +633,11 @@ class PreviewVideoStore {

// set all video status to be in queue
for (final enteFile in allFiles) {
final fileSize = enteFile.fileSize;
FFProbeProps? props;
final (_, result) = await checkFileForPreviewCreation(enteFile);

if (fileSize != null && fileSize <= 10 * 1024 * 1024) {
final file = await getFile(enteFile, isOrigin: true);
if (file != null) {
props = await getVideoPropsAsync(file);
final videoData = List.from(props?.propData?["streams"] ?? [])
.firstWhereOrNull((e) => e["type"] == "video");

final codec = videoData["codec_name"]?.toString().toLowerCase();
final codecIsH264 = codec?.contains("h264") ?? false;

if (codecIsH264) {
_items.removeWhere((key, value) => value.file == enteFile);
Bus.instance.fire(PreviewUpdatedEvent(_items));
continue;
}
}
if (result) {
allFiles.remove(enteFile);
continue;
}

_items[enteFile.uploadedFileID!] = PreviewItem(
Expand Down
2 changes: 1 addition & 1 deletion mobile/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description: ente photos application
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html

version: 0.9.98+998
version: 0.9.99+999
publish_to: none

environment:
Expand Down