Merge pull request 'perf(video): decode HLS transcode sources on the GPU' (#167) from perf/hls-gpu-decode into master
Reviewed-on: #167
This commit was merged in pull request #167.
This commit is contained in:
commit
4745a945fe
1 file changed
+12
-2
+12
-2
@@ -633,14 +633,24 @@ impl Handler<GeneratePlaylistMessage> for PlaylistGenerator {
|
|||||||
// ffmpeg writes them next to the playlist (relative refs).
|
// ffmpeg writes them next to the playlist (relative refs).
|
||||||
let playlist_tmp = format!("{}.tmp", playlist_file);
|
let playlist_tmp = format!("{}.tmp", playlist_file);
|
||||||
|
|
||||||
|
let nvenc = !use_copy && crate::video::ffmpeg::is_nvenc_available().await;
|
||||||
|
|
||||||
let mut cmd = tokio::process::Command::new("ffmpeg");
|
let mut cmd = tokio::process::Command::new("ffmpeg");
|
||||||
cmd.arg("-y").arg("-i").arg(&video_file);
|
cmd.arg("-y");
|
||||||
|
if nvenc {
|
||||||
|
// Decode on NVDEC too. Without it a 4K source is decoded on
|
||||||
|
// the CPU and only the encode runs on the GPU: ~4.5x the CPU
|
||||||
|
// time. Frames come back to system memory, so the CPU
|
||||||
|
// filters (autorotate, scale) still apply, and ffmpeg falls
|
||||||
|
// back to software decode for codecs NVDEC lacks (ProRes).
|
||||||
|
cmd.arg("-hwaccel").arg("cuda");
|
||||||
|
}
|
||||||
|
cmd.arg("-i").arg(&video_file);
|
||||||
|
|
||||||
if use_copy {
|
if use_copy {
|
||||||
cmd.arg("-c:v").arg("copy");
|
cmd.arg("-c:v").arg("copy");
|
||||||
cmd.arg("-c:a").arg("aac");
|
cmd.arg("-c:a").arg("aac");
|
||||||
} else {
|
} else {
|
||||||
let nvenc = crate::video::ffmpeg::is_nvenc_available().await;
|
|
||||||
if nvenc {
|
if nvenc {
|
||||||
// NVENC: no CRF, use VBR + target CQ. p1 = fastest
|
// NVENC: no CRF, use VBR + target CQ. p1 = fastest
|
||||||
// preset — prioritizes encoder throughput over bitrate
|
// preset — prioritizes encoder throughput over bitrate
|
||||||
|
|||||||
Reference in new issue
Block a user