add play button to video thumbnails
parent
b80d547689
commit
7540b31ab8
|
@ -0,0 +1 @@
|
||||||
|
src/assets/play.png filter=lfs diff=lfs merge=lfs -text
|
1
Makefile
1
Makefile
|
@ -5,6 +5,7 @@ package: target/release/upend webui/public/build/main.js
|
||||||
linuxdeploy-x86_64.AppImage --appdir dist
|
linuxdeploy-x86_64.AppImage --appdir dist
|
||||||
cp target/release/upend dist/usr/bin/upend
|
cp target/release/upend dist/usr/bin/upend
|
||||||
cp -r webui/public dist/usr/bin/webui
|
cp -r webui/public dist/usr/bin/webui
|
||||||
|
cp -r src/assets dist/usr/bin/assets
|
||||||
cp media/upend.png dist/usr/share/icons/upend.png
|
cp media/upend.png dist/usr/share/icons/upend.png
|
||||||
VERSION="$$(grep '^version' Cargo.toml|grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')" \
|
VERSION="$$(grep '^version' Cargo.toml|grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')" \
|
||||||
linuxdeploy-x86_64.AppImage --appdir dist -d upend.desktop --output appimage
|
linuxdeploy-x86_64.AppImage --appdir dist -d upend.desktop --output appimage
|
||||||
|
|
Binary file not shown.
|
@ -1,10 +1,13 @@
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
|
use log::warn;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
|
use crate::common::get_static_dir;
|
||||||
|
|
||||||
use super::Previewable;
|
use super::Previewable;
|
||||||
|
|
||||||
pub struct VideoPath<'a>(pub &'a Path);
|
pub struct VideoPath<'a>(pub &'a Path);
|
||||||
|
@ -26,9 +29,21 @@ impl<'a> Previewable for VideoPath<'a> {
|
||||||
let duration = String::from_utf8_lossy(&duration_cmd.stdout)
|
let duration = String::from_utf8_lossy(&duration_cmd.stdout)
|
||||||
.trim()
|
.trim()
|
||||||
.parse::<f64>()?;
|
.parse::<f64>()?;
|
||||||
|
let play_button = get_static_dir("assets").map(|d| d.join("play.png")).ok();
|
||||||
let outfile = tempfile::Builder::new().suffix(".webp").tempfile()?;
|
let outfile = tempfile::Builder::new().suffix(".webp").tempfile()?;
|
||||||
let thumbnail_cmd = Command::new("ffmpeg")
|
let thumbnail_cmd = Command::new("ffmpeg")
|
||||||
.args(["-i", &self.0.to_string_lossy()])
|
.args(["-i", &self.0.to_string_lossy()])
|
||||||
|
.args(if let Some(play_button) = play_button {
|
||||||
|
vec![
|
||||||
|
"-i".to_string(),
|
||||||
|
play_button.to_string_lossy().to_string(),
|
||||||
|
"-filter_complex".to_string(),
|
||||||
|
"[0:v][1:v]overlay=(W-w)/2:(H-h)/2".to_string(),
|
||||||
|
]
|
||||||
|
} else {
|
||||||
|
warn!("Could not find play button to overlay for video thumbnail!");
|
||||||
|
vec![]
|
||||||
|
})
|
||||||
.args(["-vframes", "1"])
|
.args(["-vframes", "1"])
|
||||||
.args(["-ss", &(duration / 2.0).to_string()])
|
.args(["-ss", &(duration / 2.0).to_string()])
|
||||||
.arg(&*outfile.path().to_string_lossy())
|
.arg(&*outfile.path().to_string_lossy())
|
||||||
|
|
Loading…
Reference in New Issue