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