mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 20:24:27 -04:00
Fix slow transcoder (use mediainfo id instead of sha1)
This commit is contained in:
parent
1641ba2898
commit
e79e568a4c
12
transcoder/Cargo.lock
generated
12
transcoder/Cargo.lock
generated
@ -1112,17 +1112,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sha-1"
|
|
||||||
version = "0.10.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"cpufeatures",
|
|
||||||
"digest",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha1"
|
name = "sha1"
|
||||||
version = "0.10.5"
|
version = "0.10.5"
|
||||||
@ -1317,7 +1306,6 @@ dependencies = [
|
|||||||
"rand",
|
"rand",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"sha-1",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"utoipa",
|
"utoipa",
|
||||||
]
|
]
|
||||||
|
@ -13,4 +13,3 @@ derive_more = "0.99.17"
|
|||||||
reqwest = { version = "0.11.16", default_features = false, features = ["json", "rustls-tls"] }
|
reqwest = { version = "0.11.16", default_features = false, features = ["json", "rustls-tls"] }
|
||||||
utoipa = { version = "3", features = ["actix_extras"] }
|
utoipa = { version = "3", features = ["actix_extras"] }
|
||||||
json = "0.12.4"
|
json = "0.12.4"
|
||||||
sha-1 = "0.10.1"
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use json::JsonValue;
|
use json::JsonValue;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use sha1::{Digest, Sha1};
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fs, io,
|
fs, io,
|
||||||
@ -103,6 +102,7 @@ pub struct Chapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn extract(path: String, sha: &String, subs: &Vec<Subtitle>) {
|
async fn extract(path: String, sha: &String, subs: &Vec<Subtitle>) {
|
||||||
|
println!("Extract subs and fonts for {}", path);
|
||||||
let mut cmd = Command::new("ffmpeg");
|
let mut cmd = Command::new("ffmpeg");
|
||||||
cmd.current_dir(format!("/metadata/{sha}/att/"))
|
cmd.current_dir(format!("/metadata/{sha}/att/"))
|
||||||
.args(&["-dump_attachment:t", ""])
|
.args(&["-dump_attachment:t", ""])
|
||||||
@ -141,16 +141,13 @@ pub async fn identify(path: String) -> Result<MediaInfo, std::io::Error> {
|
|||||||
assert!(mediainfo.status.success());
|
assert!(mediainfo.status.success());
|
||||||
let output = json::parse(str::from_utf8(mediainfo.stdout.as_slice()).unwrap()).unwrap();
|
let output = json::parse(str::from_utf8(mediainfo.stdout.as_slice()).unwrap()).unwrap();
|
||||||
|
|
||||||
let mut file = fs::File::open(&path)?;
|
|
||||||
let mut hasher = Sha1::new();
|
|
||||||
io::copy(&mut file, &mut hasher)?;
|
|
||||||
let sha = format!("{:x}", hasher.finalize());
|
|
||||||
|
|
||||||
let general = output["media"]["track"]
|
let general = output["media"]["track"]
|
||||||
.members()
|
.members()
|
||||||
.find(|x| x["@type"] == "General")
|
.find(|x| x["@type"] == "General")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
let sha = general["UniqueID"].to_string();
|
||||||
|
|
||||||
let subs: Vec<Subtitle> = output["media"]["track"]
|
let subs: Vec<Subtitle> = output["media"]["track"]
|
||||||
.members()
|
.members()
|
||||||
.filter(|x| x["@type"] == "Text")
|
.filter(|x| x["@type"] == "Text")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user