pub struct FfmpegTask { /* private fields */ }Expand description
FFmpeg 任务构建器
用于构建并执行服务端的 FFmpeg 转码任务。 采用 Builder 模式,支持链式调用。
§Example
use vtx_sdk::prelude::*;
fn handle_video(vid: String) -> VtxResult<Response> {
FfmpegTask::new("mini", vid)
.arg("-ss 10")
.arg("-t 30")
.execute()
}Implementations§
Source§impl FfmpegTask
impl FfmpegTask
Sourcepub fn new(profile: impl Into<String>, input_id: impl Into<String>) -> Self
pub fn new(profile: impl Into<String>, input_id: impl Into<String>) -> Self
创建一个新的 FFmpeg 任务
§Parameters
profile: 目标 Profile 名称 (如 “mini”, “remux”, “thumbnail”)input_id: 输入视频的唯一资源 ID (UUID)
Sourcepub fn new_pipe(profile: impl Into<String>) -> Self
pub fn new_pipe(profile: impl Into<String>) -> Self
创建一个使用 stdin 管道作为输入的任务(等价于 input_id = "pipe:0")。
Sourcepub fn seek(self, start: &str, duration: Option<&str>) -> Self
pub fn seek(self, start: &str, duration: Option<&str>) -> Self
快捷方法:设置时间裁剪
等同于 .arg("-ss").arg(start).arg("-t").arg(duration)
Sourcepub fn execute_buffer(self) -> VtxResult<Buffer>
pub fn execute_buffer(self) -> VtxResult<Buffer>
执行任务并返回 Buffer 资源句柄。
这允许你在返回响应前,使用 buffer.write(...) 往 stdin 写入数据(当 input_id="pipe:0" 时)。
Sourcepub fn execute(self) -> VtxResult<HttpResponse>
pub fn execute(self) -> VtxResult<HttpResponse>
执行任务并返回 HTTP 响应(200 + body=stdout 管道 Buffer)。
该方法会阻塞等待子进程启动,并立即返回包含 stdout 管道流的 HttpResponse。 数据将以流式传输给客户端,无需等待转码完成。
Auto Trait Implementations§
impl Freeze for FfmpegTask
impl RefUnwindSafe for FfmpegTask
impl Send for FfmpegTask
impl Sync for FfmpegTask
impl Unpin for FfmpegTask
impl UnwindSafe for FfmpegTask
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more