fix(video): stop stream-copying oversized sources into HLS #166
No files matched your search
+2
-1
@@ -155,7 +155,8 @@ pub fn beat_filtergraph(opts: &SegmentOpts, per_photo: &[f64]) -> String {
|
|||||||
|
|
||||||
fn video_encoder_args(nvenc: bool) -> Vec<String> {
|
fn video_encoder_args(nvenc: bool) -> Vec<String> {
|
||||||
if nvenc {
|
if nvenc {
|
||||||
// p4 ≈ balanced; cq 23 ≈ libx264 crf 21. Matches the HLS transcode path.
|
// p4 ≈ balanced; cq 23 ≈ libx264 crf 21. Same quality target as the
|
||||||
|
// HLS transcode, which uses the faster p1 preset for throughput.
|
||||||
[
|
[
|
||||||
"-c:v",
|
"-c:v",
|
||||||
"h264_nvenc",
|
"h264_nvenc",
|
||||||
|
|||||||
+1
-32
@@ -1,7 +1,7 @@
|
|||||||
use futures::TryFutureExt;
|
use futures::TryFutureExt;
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
use std::io::Result;
|
use std::io::Result;
|
||||||
use std::process::{Output, Stdio};
|
use std::process::Stdio;
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
@@ -47,37 +47,6 @@ pub enum GifType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Ffmpeg {
|
impl Ffmpeg {
|
||||||
async fn _generate_playlist(&self, input_file: &str, output_file: &str) -> Result<String> {
|
|
||||||
let ffmpeg_result: Result<Output> = Command::new("ffmpeg")
|
|
||||||
.arg("-i")
|
|
||||||
.arg(input_file)
|
|
||||||
.arg("-c:v")
|
|
||||||
.arg("h264")
|
|
||||||
.arg("-crf")
|
|
||||||
.arg("21")
|
|
||||||
.arg("-preset")
|
|
||||||
.arg("veryfast")
|
|
||||||
.arg("-hls_time")
|
|
||||||
.arg("3")
|
|
||||||
.arg("-hls_list_size")
|
|
||||||
.arg("100")
|
|
||||||
.arg("-vf")
|
|
||||||
.arg("scale=1080:-2,setsar=1:1")
|
|
||||||
.arg(output_file)
|
|
||||||
.stdout(Stdio::null())
|
|
||||||
.stderr(Stdio::piped())
|
|
||||||
.output()
|
|
||||||
.inspect_err(|e| error!("Failed to run ffmpeg on child process: {}", e))
|
|
||||||
.map_err(|e| std::io::Error::other(e.to_string()))
|
|
||||||
.await;
|
|
||||||
|
|
||||||
if let Ok(ref res) = ffmpeg_result {
|
|
||||||
debug!("ffmpeg output: {:?}", res);
|
|
||||||
}
|
|
||||||
|
|
||||||
ffmpeg_result.map(|_| output_file.to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_video_duration(&self, input_file: &str) -> Result<u32> {
|
async fn get_video_duration(&self, input_file: &str) -> Result<u32> {
|
||||||
Command::new("ffprobe")
|
Command::new("ffprobe")
|
||||||
.args(["-i", input_file])
|
.args(["-i", input_file])
|
||||||
|
|||||||
Reference in new issue
Block a user