Cleanup
This commit is contained in:
@@ -19,14 +19,14 @@ use log::{debug, error, info, trace};
|
|||||||
use crate::data::{Claims, FilesRequest, FilterMode, PhotosResponse, SortType};
|
use crate::data::{Claims, FilesRequest, FilterMode, PhotosResponse, SortType};
|
||||||
use crate::{create_thumbnails, AppState};
|
use crate::{create_thumbnails, AppState};
|
||||||
|
|
||||||
use crate::data::SortType::{NameAsc};
|
use crate::data::SortType::NameAsc;
|
||||||
use crate::error::IntoHttpError;
|
use crate::error::IntoHttpError;
|
||||||
use crate::tags::TagDao;
|
use crate::tags::TagDao;
|
||||||
|
use crate::video::actors::StreamActor;
|
||||||
use path_absolutize::*;
|
use path_absolutize::*;
|
||||||
use rand::prelude::SliceRandom;
|
use rand::prelude::SliceRandom;
|
||||||
use rand::thread_rng;
|
use rand::thread_rng;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use crate::video::actors::StreamActor;
|
|
||||||
|
|
||||||
pub async fn list_photos<TagD: TagDao, FS: FileSystemAccess>(
|
pub async fn list_photos<TagD: TagDao, FS: FileSystemAccess>(
|
||||||
_: Claims,
|
_: Claims,
|
||||||
@@ -396,10 +396,7 @@ mod tests {
|
|||||||
if self.err {
|
if self.err {
|
||||||
Err(anyhow!("Error for test"))
|
Err(anyhow!("Error for test"))
|
||||||
} else if let Some(files) = self.files.get(path) {
|
} else if let Some(files) = self.files.get(path) {
|
||||||
Ok(files
|
Ok(files.iter().map(PathBuf::from).collect::<Vec<PathBuf>>())
|
||||||
.iter()
|
|
||||||
.map(PathBuf::from)
|
|
||||||
.collect::<Vec<PathBuf>>())
|
|
||||||
} else {
|
} else {
|
||||||
Ok(Vec::new())
|
Ok(Vec::new())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
use crate::video::actors::{PlaylistGenerator, StreamActor, VideoPlaylistManager};
|
||||||
use actix::{Actor, Addr};
|
use actix::{Actor, Addr};
|
||||||
use std::{env, sync::Arc};
|
use std::{env, sync::Arc};
|
||||||
use crate::video::actors::{PlaylistGenerator, StreamActor, VideoPlaylistManager};
|
|
||||||
|
|
||||||
pub struct AppState {
|
pub struct AppState {
|
||||||
pub stream_manager: Arc<Addr<StreamActor>>,
|
pub stream_manager: Arc<Addr<StreamActor>>,
|
||||||
|
|||||||
@@ -48,10 +48,7 @@ impl UserDao for TestUserDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn user_exists(&mut self, user: &str) -> bool {
|
fn user_exists(&mut self, user: &str) -> bool {
|
||||||
self.user_map
|
self.user_map.borrow().iter().any(|u| u.username == user)
|
||||||
.borrow()
|
|
||||||
.iter()
|
|
||||||
.any(|u| u.username == user)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use tokio::process::Command;
|
|||||||
pub struct Ffmpeg;
|
pub struct Ffmpeg;
|
||||||
|
|
||||||
impl Ffmpeg {
|
impl Ffmpeg {
|
||||||
async fn generate_playlist(&self, input_file: &str, output_file: &str) -> Result<String> {
|
async fn _generate_playlist(&self, input_file: &str, output_file: &str) -> Result<String> {
|
||||||
let ffmpeg_result: Result<Output> = tokio::process::Command::new("ffmpeg")
|
let ffmpeg_result: Result<Output> = tokio::process::Command::new("ffmpeg")
|
||||||
.arg("-i")
|
.arg("-i")
|
||||||
.arg(input_file)
|
.arg(input_file)
|
||||||
@@ -43,10 +43,10 @@ impl Ffmpeg {
|
|||||||
|
|
||||||
async fn get_video_duration(&self, input_file: &str) -> Result<String> {
|
async fn get_video_duration(&self, input_file: &str) -> Result<String> {
|
||||||
Command::new("ffprobe")
|
Command::new("ffprobe")
|
||||||
.args(&["-i", input_file])
|
.args(["-i", input_file])
|
||||||
.args(&["-show_entries", "format=duration"])
|
.args(["-show_entries", "format=duration"])
|
||||||
.args(&["-v", "quiet"])
|
.args(["-v", "quiet"])
|
||||||
.args(&["-of", "csv=p=0"])
|
.args(["-of", "csv=p=0"])
|
||||||
.output()
|
.output()
|
||||||
.await
|
.await
|
||||||
.map(|out| String::from_utf8_lossy(&out.stdout).trim().to_string())
|
.map(|out| String::from_utf8_lossy(&out.stdout).trim().to_string())
|
||||||
@@ -73,9 +73,9 @@ impl Ffmpeg {
|
|||||||
debug!("Creating gif frames for '{}'", input_file);
|
debug!("Creating gif frames for '{}'", input_file);
|
||||||
|
|
||||||
Command::new("ffmpeg")
|
Command::new("ffmpeg")
|
||||||
.args(&["-i", input_file])
|
.args(["-i", input_file])
|
||||||
.args(&["-vf", &format!("fps=20/{}", duration)])
|
.args(["-vf", &format!("fps=20/{}", duration)])
|
||||||
.args(&["-q:v", "2"])
|
.args(["-q:v", "2"])
|
||||||
.stderr(Stdio::null())
|
.stderr(Stdio::null())
|
||||||
.arg(format!("{}/frame_%03d.jpg", temp_path))
|
.arg(format!("{}/frame_%03d.jpg", temp_path))
|
||||||
.status()
|
.status()
|
||||||
@@ -84,9 +84,9 @@ impl Ffmpeg {
|
|||||||
debug!("Generating palette");
|
debug!("Generating palette");
|
||||||
|
|
||||||
Command::new("ffmpeg")
|
Command::new("ffmpeg")
|
||||||
.args(&["-i", &format!("{}/frame_%03d.jpg", temp_path)])
|
.args(["-i", &format!("{}/frame_%03d.jpg", temp_path)])
|
||||||
.args(&["-vf", "palettegen"])
|
.args(["-vf", "palettegen"])
|
||||||
.arg(&format!("{}/palette.png", temp_path))
|
.arg(format!("{}/palette.png", temp_path))
|
||||||
.stderr(Stdio::null())
|
.stderr(Stdio::null())
|
||||||
.status()
|
.status()
|
||||||
})
|
})
|
||||||
@@ -117,15 +117,15 @@ impl Ffmpeg {
|
|||||||
async fn create_gif_from_frames(&self, frame_base_dir: &str, output_file: &str) -> Result<i32> {
|
async fn create_gif_from_frames(&self, frame_base_dir: &str, output_file: &str) -> Result<i32> {
|
||||||
Command::new("ffmpeg")
|
Command::new("ffmpeg")
|
||||||
.arg("-y")
|
.arg("-y")
|
||||||
.args(&["-framerate", "4"])
|
.args(["-framerate", "4"])
|
||||||
.args(&["-i", &format!("{}/frame_%03d.jpg", frame_base_dir)])
|
.args(["-i", &format!("{}/frame_%03d.jpg", frame_base_dir)])
|
||||||
.args(&["-i", &format!("{}/palette.png", frame_base_dir)])
|
.args(["-i", &format!("{}/palette.png", frame_base_dir)])
|
||||||
.args(&[
|
.args([
|
||||||
"-filter_complex",
|
"-filter_complex",
|
||||||
// Scale to 480x480 with a center crop
|
// Scale to 480x480 with a center crop
|
||||||
"[0:v]scale=480:-1:flags=lanczos,crop='min(in_w,in_h)':'min(in_w,in_h)':(in_w-out_w)/2:(in_h-out_h)/2, paletteuse",
|
"[0:v]scale=480:-1:flags=lanczos,crop='min(in_w,in_h)':'min(in_w,in_h)':(in_w-out_w)/2:(in_h-out_h)/2, paletteuse",
|
||||||
])
|
])
|
||||||
.args(&["-loop", "0"]) // loop forever
|
.args(["-loop", "0"]) // loop forever
|
||||||
.arg(output_file)
|
.arg(output_file)
|
||||||
.stderr(Stdio::null())
|
.stderr(Stdio::null())
|
||||||
.status()
|
.status()
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
pub mod actors;
|
pub mod actors;
|
||||||
pub mod ffmpeg;
|
pub mod ffmpeg;
|
||||||
|
|||||||
Reference in New Issue
Block a user