Skip to content

Commit

Permalink
Fix video not being playable on MacOS when encoded with hevc_videotoo…
Browse files Browse the repository at this point in the history
…lbox (#48)

fixed final video not being playable on macos when encoded with hevc_videotoolbox
  • Loading branch information
vmzhivetyev authored Aug 21, 2024
1 parent 1044026 commit fc17974
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion backend/src/ffmpeg/encoders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,21 @@ pub struct Encoder {
pub codec: Codec,
pub hardware: bool,
pub detected: bool,
pub extra_args: Vec<String>
}

impl Encoder {
fn new(name: &str, codec: Codec, hardware: bool) -> Self {
Self::new_with_extra_args(name, codec, hardware, &[])
}

fn new_with_extra_args(name: &str, codec: Codec, hardware: bool, extra_args: &[&str]) -> Self {
Self {
name: name.to_string(),
codec,
hardware,
detected: false,
extra_args: extra_args.iter().map(|&s| s.to_string()).collect(),
}
}

Expand Down Expand Up @@ -77,7 +83,10 @@ impl Encoder {
Encoder::new("hevc_v4l2m2m", Codec::H265, true),

#[cfg(target_os = "macos")]
Encoder::new("hevc_videotoolbox", Codec::H265, true),
Encoder::new_with_extra_args(
"hevc_videotoolbox", Codec::H265, true,
&["-tag:v", "hvc1"] // Apple QuickTime player on Mac only supports hvc1
),
];

all_encoders
Expand Down
1 change: 1 addition & 0 deletions backend/src/ffmpeg/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ pub fn spawn_encoder(
.pix_fmt("yuv420p")
.codec_video(&video_encoder.name)
.args(["-b:v", &format!("{}M", bitrate_mbps)])
.args(&video_encoder.extra_args)
.overwrite()
.output(output_video.to_str().unwrap());

Expand Down
1 change: 1 addition & 0 deletions backend/src/ffmpeg/render_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ impl Default for RenderSettings {
codec: Codec::H264,
hardware: false,
detected: false,
extra_args: Vec::new(),
},
selected_encoder_idx: 0,
show_undetected_encoders: false,
Expand Down

0 comments on commit fc17974

Please sign in to comment.