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

Media metadata extraction & Thumbnailer rework #2285

Merged
merged 62 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b49b7db
initial ffprobe commit
HeavenVolkoff Apr 5, 2024
632ef47
Working slim down version ffprobe
HeavenVolkoff Apr 5, 2024
ecd58f1
Auto format ffprobe and deps source
HeavenVolkoff Apr 5, 2024
4e24b23
Remove show_pixel_formats logic
HeavenVolkoff Apr 5, 2024
fafdb97
Remove show_* and print_format options and their respective logic
HeavenVolkoff Apr 5, 2024
946c263
Rework ffprobe into simple_ffprobe
HeavenVolkoff Apr 5, 2024
a8e43fa
Reduce the amount of ffmpeg log messages while generating thumbnails
HeavenVolkoff Apr 5, 2024
9b36d5c
Fix completly wrong comments
HeavenVolkoff Apr 5, 2024
7da23b4
mend
HeavenVolkoff Apr 5, 2024
f8072d5
Start modeling ffmpeg extracted metadata on schema
HeavenVolkoff Apr 10, 2024
ef9252c
Finish modeling media info data
HeavenVolkoff Apr 10, 2024
d477908
Add relation between MediaInfo and FilePath
HeavenVolkoff Apr 17, 2024
b5aa5ae
Fix and update schema
HeavenVolkoff Apr 17, 2024
55f0e7f
Data models and start populating MediaInfo in rust
HeavenVolkoff Apr 17, 2024
d2bf7c4
Finish populating media info, chapters and program
HeavenVolkoff Apr 18, 2024
6dfc0b6
Improve FFmpegFormatContext data raw pointer access
HeavenVolkoff Apr 18, 2024
6c333ca
Impl FFmpegCodecContext, retrieve codec information
HeavenVolkoff Apr 19, 2024
22600fe
Fix FFmpegDict Drop
HeavenVolkoff Apr 19, 2024
36ddcbf
Fix some crago warnings
HeavenVolkoff Apr 19, 2024
760d753
Impl retrieval of video props
HeavenVolkoff Apr 19, 2024
b78cc18
Impl retrieval of audio and subtitle props
HeavenVolkoff Apr 19, 2024
b0b39b9
Remove simple_ffprobe now that the Rust impl is done
HeavenVolkoff Apr 20, 2024
032ae9d
Fix schema to match actually retrieved media info
HeavenVolkoff Apr 20, 2024
1cc6b40
Rework movie_decoder
HeavenVolkoff Apr 20, 2024
d4912bc
Fix incorrect props when initializing MovieDecoder
HeavenVolkoff Apr 20, 2024
023b5f1
Remove unecessary lifetimes
HeavenVolkoff Apr 20, 2024
c7dbb61
Added more native wrappers for some FFmpeg native objects used in mov…
HeavenVolkoff Apr 22, 2024
6ad2818
Remove FFmpegPacket
HeavenVolkoff Apr 23, 2024
4c7ff12
WIP
HeavenVolkoff Apr 24, 2024
2bbf983
Some small fixes
fogodev Apr 24, 2024
a31cdfc
More fixes
HeavenVolkoff Apr 25, 2024
79e39f6
fmt
HeavenVolkoff Apr 25, 2024
b37e726
Fix duplicate migration for job error changes
HeavenVolkoff Apr 26, 2024
1ae2200
fix rebase
HeavenVolkoff Apr 26, 2024
789b806
Solving segfaults, fuck C lang
fogodev Apr 26, 2024
9feeb5a
Update rust to version 1.77
HeavenVolkoff Apr 27, 2024
872592a
More segfault solving and other minor fixes
fogodev Apr 27, 2024
6cc38f7
Fix ffmpeg rotation filter breaking portrait video thumbnails #2150
HeavenVolkoff Apr 30, 2024
4e1f9af
Auto format
HeavenVolkoff Apr 30, 2024
ece7c27
Retrieve video/audio metadata on frontend
HeavenVolkoff May 1, 2024
ec8dade
Auto format
HeavenVolkoff May 1, 2024
43e1cd0
First draft on ffmpeg data save on db
fogodev May 2, 2024
3d778cb
Fix some incorrect changes to prisma schema
HeavenVolkoff May 2, 2024
9cdfef5
Some fixes for the FFmpegData schema
HeavenVolkoff May 2, 2024
8dcc602
A ton of things
fogodev May 3, 2024
b0d9653
Integrating ffmpeg media data in jobs and API
fogodev May 4, 2024
dd28578
Rspc can't BigInt
fogodev May 4, 2024
8e1ebe8
🙄
fogodev May 4, 2024
56885ff
Add initial ffmpeg metadata entries to Inspector
HeavenVolkoff May 7, 2024
0fd9b04
Fix Inspector not showing ffmpeg metadata
HeavenVolkoff May 7, 2024
2e558d1
Add bitrate, start time and chapters video metadata to Inspector
HeavenVolkoff May 7, 2024
e03f158
Solving some issues
fogodev May 8, 2024
6d81b47
Fix ffmpeg probe getting incorrect stream id and breaking database un…
HeavenVolkoff May 8, 2024
91c5ba5
Merge remote-tracking branch 'origin/main' into eng-949-collect-video…
HeavenVolkoff May 8, 2024
05798dc
fmt
HeavenVolkoff May 8, 2024
329651d
small improvements
HeavenVolkoff May 8, 2024
3d07979
Add migration for ffmpeg media data
HeavenVolkoff May 8, 2024
914da98
Fix cypress test
HeavenVolkoff May 8, 2024
82f6c5e
Requested changes
fogodev May 8, 2024
80355e1
Merge branch 'main' of github.com:spacedriveapp/spacedrive into eng-9…
fogodev May 8, 2024
6451a78
Implement feedback
HeavenVolkoff May 9, 2024
f043ae4
Fix thumb reactivity in non indexed locations
HeavenVolkoff May 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .cspell/project_words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ davidmytton
deel
elon
encryptor
Exif
Flac
graps
haden
Expand Down
3 changes: 1 addition & 2 deletions .github/actions/setup-rust/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ runs:
steps:
- name: Install Rust
id: toolchain
uses: dtolnay/rust-toolchain@stable
uses: IronCoreLabs/rust-toolchain@v1
with:
target: ${{ inputs.target }}
toolchain: '1.75'
components: clippy, rustfmt

- name: Cache Rust Dependencies
Expand Down
3 changes: 1 addition & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"args": [
"build",
"--manifest-path=./apps/desktop/src-tauri/Cargo.toml",
"--no-default-features",
"--features=ai-models"
"--no-default-features"
],
"problemMatcher": "$rustc"
},
Expand Down
3 changes: 1 addition & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
"command": "run",
"args": [
"--manifest-path=./apps/desktop/src-tauri/Cargo.toml",
"--no-default-features",
"--features=ai-models"
"--no-default-features"
],
"env": {
"RUST_BACKTRACE": "short"
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ To run the landing page:

If you encounter any issues, ensure that you are using the following versions of Rust, Node and Pnpm:

- Rust version: **1.75**
- Rust version: **1.77**
fogodev marked this conversation as resolved.
Show resolved Hide resolved
- Node version: **18.18**
- Pnpm version: **9.0.6**

Expand Down
13 changes: 10 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 10 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,20 @@ repository = "https://github.com/spacedriveapp/spacedrive"
[workspace.dependencies]
# First party dependencies
prisma-client-rust = { git = "https://github.com/spacedriveapp/prisma-client-rust", rev = "528ab1cd02c25a1b183c0a8bc44e28954fdd0bfd", features = [
"specta",
"sqlite-create-many",
"migrations",
"specta",
"sqlite",
"sqlite-create-many",
], default-features = false }
prisma-client-rust-cli = { git = "https://github.com/spacedriveapp/prisma-client-rust", rev = "528ab1cd02c25a1b183c0a8bc44e28954fdd0bfd", features = [
"specta",
"sqlite-create-many",
"migrations",
"specta",
"sqlite",
"sqlite-create-many",
], default-features = false }
prisma-client-rust-sdk = { git = "https://github.com/spacedriveapp/prisma-client-rust", rev = "528ab1cd02c25a1b183c0a8bc44e28954fdd0bfd", features = [
"sqlite",
], default-features = false }

tracing = "0.1.40"
tracing-subscriber = "0.3.18"
tracing-appender = "0.2.3"

rspc = { version = "0.1.4" }
specta = { version = "=2.0.0-rc.11" }
tauri-specta = { version = "=2.0.0-rc.8" }
Expand All @@ -54,7 +49,7 @@ async-trait = "0.1.77"
axum = "=0.6.20"
base64 = "0.21.5"
blake3 = "1.5.0"
chrono = "0.4.31"
chrono = "0.4.38"
clap = "4.4.7"
futures = "0.3.30"
futures-concurrency = "7.4.3"
Expand All @@ -64,6 +59,7 @@ http = "0.2.9"
image = "0.24.7"
itertools = "0.12.0"
lending-stream = "1.0.0"
libc = "0.2"
normpath = "1.1.1"
once_cell = "1.18.0"
pin-project-lite = "0.2.13"
Expand All @@ -83,13 +79,14 @@ thiserror = "1.0.50"
tokio = "1.36.0"
tokio-stream = "0.1.14"
tokio-util = "0.7.10"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
tracing-appender = "0.2.3"
tracing-test = "^0.2.4"
uhlc = "=0.5.2"
uuid = "1.5.0"
webp = "0.2.6"

[workspace.dev-dependencies]
tracing-test = { version = "^0.2.4" }

[patch.crates-io]
# Proper IOS Support
if-watch = { git = "https://github.com/oscartbeaumont/if-watch.git", rev = "a92c17d3f85c1c6fb0afeeaf6c2b24d0b147e8c3" }
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/crates/linux/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = { workspace = true }

[dependencies]
tokio = { workspace = true, features = ["fs"] }
libc = "0.2"
libc = { workspace = true }

[target.'cfg(target_os = "linux")'.dependencies]
# WARNING: gtk should follow the same version used by tauri
Expand Down
21 changes: 2 additions & 19 deletions apps/desktop/crates/linux/src/app_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,14 @@ use std::path::Path;

use gtk::{
gio::{
content_type_guess,
prelude::AppInfoExt,
prelude::{AppLaunchContextExt, FileExt},
AppInfo, AppLaunchContext, DesktopAppInfo, File as GioFile, ResourceError,
content_type_guess, prelude::AppInfoExt, prelude::FileExt, AppInfo, AppLaunchContext,
DesktopAppInfo, File as GioFile, ResourceError,
},
glib::error::Error as GlibError,
prelude::IsA,
};
use tokio::fs::File;
use tokio::io::AsyncReadExt;

use crate::env::remove_prefix_from_pathlist;

fn remove_prefix_from_env_in_ctx(
ctx: &impl IsA<AppLaunchContext>,
env_name: &str,
prefix: &impl AsRef<Path>,
) {
if let Some(value) = remove_prefix_from_pathlist(env_name, prefix) {
ctx.setenv(env_name, value);
} else {
ctx.unsetenv(env_name);
}
}

thread_local! {
static LAUNCH_CTX: AppLaunchContext = {
// TODO: Display supports requires GDK, which can only run on the main thread
Expand Down
37 changes: 2 additions & 35 deletions apps/desktop/crates/linux/src/env.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
use std::{
collections::HashSet,
env,
ffi::{CStr, OsStr, OsString},
ffi::{CStr, OsStr},
mem,
os::unix::ffi::OsStrExt,
path::{Path, PathBuf},
path::PathBuf,
ptr,
};

fn version(version_str: &str) -> i32 {
let mut version_parts: Vec<i32> = version_str
.split('.')
.take(4) // Take up to 4 components
.map(|part| part.parse().unwrap_or(0))
.collect();

// Pad with zeros if needed
version_parts.resize_with(4, Default::default);

(version_parts[0] * 1_000_000_000)
+ (version_parts[1] * 1_000_000)
+ (version_parts[2] * 1_000)
+ version_parts[3]
}

pub fn get_current_user_home() -> Option<PathBuf> {
use libc::{getpwuid_r, getuid, passwd, ERANGE};

Expand Down Expand Up @@ -193,23 +177,6 @@ pub fn normalize_environment() {
.expect("PATH must be successfully normalized");
}

pub(crate) fn remove_prefix_from_pathlist(
env_name: &str,
prefix: &impl AsRef<Path>,
) -> Option<OsString> {
env::var_os(env_name).and_then(|value| {
let mut dirs = env::split_paths(&value)
.filter(|dir| !(dir.as_os_str().is_empty() || dir.starts_with(prefix)))
.peekable();

if dirs.peek().is_none() {
None
} else {
Some(env::join_paths(dirs).expect("Should not fail because we are only filtering a pathlist retrieved from the environmnet"))
}
})
}

// Check if snap by looking if SNAP is set and not empty and that the SNAP directory exists
pub fn is_snap() -> bool {
if let Some(snap) = std::env::var_os("SNAP") {
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/crates/windows/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = { workspace = true }
[dependencies]
normpath = { workspace = true }
thiserror = { workspace = true }
libc = "0.2"
libc = { workspace = true }

[target.'cfg(target_os = "windows")'.dependencies.windows]
version = "0.51"
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/modules/sd-core/android/crate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sd-mobile-android"
version = "0.1.0"
rust-version = "1.64.0"
rust-version = "1.64"
license = { workspace = true }
repository = { workspace = true }
edition = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/modules/sd-core/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sd-mobile-core"
version = "0.1.0"
rust-version = "1.64.0"
rust-version = "1.64"
license = { workspace = true }
repository = { workspace = true }
edition = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/modules/sd-core/ios/crate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sd-mobile-ios"
version = "0.1.0"
rust-version = "1.64.0"
rust-version = "1.64"
license = { workspace = true }
repository = { workspace = true }
edition = { workspace = true }
Expand Down
10 changes: 8 additions & 2 deletions apps/mobile/src/components/drawer/DrawerLocations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { DrawerNavigationHelpers } from '@react-navigation/drawer/lib/typescript
import { useNavigation } from '@react-navigation/native';
import { useRef } from 'react';
import { Pressable, Text, View } from 'react-native';
import { arraysEqual, byteSize, Location, useLibraryQuery, useOnlineLocations } from '@sd/client';
import {
arraysEqual,
humanizeSize,
Location,
useLibraryQuery,
useOnlineLocations
} from '@sd/client';
import { ModalRef } from '~/components/layout/Modal';
import { tw, twStyle } from '~/lib/tailwind';

Expand Down Expand Up @@ -45,7 +51,7 @@ const DrawerLocationItem: React.FC<DrawerLocationItemProps> = ({
</View>
<View style={tw`rounded-md border border-app-lightborder bg-app-box px-1 py-0.5`}>
<Text style={tw`text-[11px] font-medium text-ink-dull`} numberOfLines={1}>
{`${byteSize(location.size_in_bytes)}`}
{`${humanizeSize(location.size_in_bytes)}`}
</Text>
</View>
</View>
Expand Down
4 changes: 2 additions & 2 deletions apps/mobile/src/components/locations/GridLocation.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DotsThreeOutlineVertical } from 'phosphor-react-native';
import { Pressable, Text, View } from 'react-native';
import { arraysEqual, byteSize, Location, useOnlineLocations } from '@sd/client';
import { arraysEqual, humanizeSize, Location, useOnlineLocations } from '@sd/client';
import { tw, twStyle } from '~/lib/tailwind';

import FolderIcon from '../icons/FolderIcon';
Expand Down Expand Up @@ -47,7 +47,7 @@ const GridLocation: React.FC<GridLocationProps> = ({ location, modalRef }: GridL
</Text>
</View>
<Text style={tw`text-left text-[13px] font-bold text-ink-dull`} numberOfLines={1}>
{`${byteSize(location.size_in_bytes)}`}
{`${humanizeSize(location.size_in_bytes)}`}
</Text>
</Card>
);
Expand Down
14 changes: 4 additions & 10 deletions apps/mobile/src/components/locations/ListLocation.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useNavigation } from '@react-navigation/native';
import { Location, arraysEqual, byteSize, useOnlineLocations } from '@sd/client';
import { DotsThreeVertical } from 'phosphor-react-native';
import { useRef } from 'react';
import { Pressable, Text, View } from 'react-native';
import { Swipeable } from 'react-native-gesture-handler';
import { arraysEqual, humanizeSize, Location, useOnlineLocations } from '@sd/client';
import { tw, twStyle } from '~/lib/tailwind';
import { SettingsStackScreenProps } from '~/navigation/tabs/SettingsStack';

Expand Down Expand Up @@ -62,22 +62,16 @@ const ListLocation = ({ location }: ListLocationProps) => {
</View>
</View>
<View style={tw`flex-row items-center gap-3`}>
<View
style={tw`rounded-md border border-app-box bg-app p-1.5`}
>
<View style={tw`rounded-md border border-app-box bg-app p-1.5`}>
<Text
style={tw`text-left text-xs font-medium text-ink-dull`}
numberOfLines={1}
>
{`${byteSize(location.size_in_bytes)}`}
{`${humanizeSize(location.size_in_bytes)}`}
</Text>
</View>
<Pressable hitSlop={24} onPress={() => swipeRef.current?.openRight()}>
<DotsThreeVertical
weight="bold"
size={20}
color={tw.color('ink-dull')}
/>
<DotsThreeVertical weight="bold" size={20} color={tw.color('ink-dull')} />
</Pressable>
</View>
</Card>
Expand Down
4 changes: 2 additions & 2 deletions apps/mobile/src/components/modal/inspector/ActionsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { PropsWithChildren, useRef } from 'react';
import { Pressable, Text, View, ViewStyle } from 'react-native';
import FileViewer from 'react-native-file-viewer';
import {
byteSize,
getIndexedItemFilePath,
getItemObject,
humanizeSize,
useLibraryMutation,
useLibraryQuery
} from '@sd/client';
Expand Down Expand Up @@ -119,7 +119,7 @@ export const ActionsModal = () => {
</Text>
<View style={tw`flex flex-row`}>
<Text style={tw`text-xs text-ink-faint`}>
{`${byteSize(filePath?.size_in_bytes_bytes)}`},
{`${humanizeSize(filePath?.size_in_bytes_bytes)}`},
</Text>
<Text style={tw`text-xs text-ink-faint`}>
{' '}
Expand Down