Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

a few things

Brendan Allana5f6b6d069cd
diff --git a/Cargo.lock b/Cargo.lock
index f27c55cc1..c4fcdd434 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -9136,8 +9136,8 @@ checksum = "810ce18ed2112484b0d4e15d022e5f598113e220c53e373fb31e67e21670c1ce"
dependencies = [
"windows-implement 0.59.0",
"windows-interface 0.59.0",
- "windows-result 0.3.0",
- "windows-strings 0.3.0",
+ "windows-result 0.3.1",
+ "windows-strings 0.3.1",
"windows-targets 0.53.0",
]
@@ -9207,6 +9207,12 @@ dependencies = [
"syn 2.0.90",
]
+[[package]]
+name = "windows-link"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6dccfd733ce2b1753b03b6d3c65edf020262ea35e20ccdf3e288043e6dd620e3"
+
[[package]]
name = "windows-registry"
version = "0.2.0"
@@ -9249,11 +9255,11 @@ dependencies = [
[[package]]
name = "windows-result"
-version = "0.3.0"
+version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d08106ce80268c4067c0571ca55a9b4e9516518eaa1a1fe9b37ca403ae1d1a34"
+checksum = "06374efe858fab7e4f881500e6e86ec8bc28f9462c47e5a9941a0142ad86b189"
dependencies = [
- "windows-targets 0.53.0",
+ "windows-link",
]
[[package]]
@@ -9277,11 +9283,11 @@ dependencies = [
[[package]]
name = "windows-strings"
-version = "0.3.0"
+version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b888f919960b42ea4e11c2f408fadb55f78a9f236d5eef084103c8ce52893491"
+checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319"
dependencies = [
- "windows-targets 0.53.0",
+ "windows-link",
]
[[package]]
diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json
index 3fb25c592..85395f040 100644
--- a/apps/desktop/src-tauri/tauri.conf.json
+++ b/apps/desktop/src-tauri/tauri.conf.json
@@ -35,6 +35,7 @@
},
"bundle": {
"active": true,
+ "createUpdaterArtifacts": true,
"targets": "all",
"icon": [
"icons/32x32.png",
diff --git a/apps/desktop/src-tauri/tauri.prod.conf.json b/apps/desktop/src-tauri/tauri.prod.conf.json
index ef5f58aa8..6f71ae604 100644
--- a/apps/desktop/src-tauri/tauri.prod.conf.json
+++ b/apps/desktop/src-tauri/tauri.prod.conf.json
@@ -17,7 +17,6 @@
}
},
"bundle": {
- "createUpdaterArtifacts": true,
"macOS": {
"entitlements": "Entitlements.plist"
},
diff --git a/apps/desktop/src/routes/(window-chrome)/(main).tsx b/apps/desktop/src/routes/(window-chrome)/(main).tsx
index 97bbb3128..b92f6e3d2 100644
--- a/apps/desktop/src/routes/(window-chrome)/(main).tsx
+++ b/apps/desktop/src/routes/(window-chrome)/(main).tsx
@@ -7,7 +7,7 @@ import {
useQueryClient,
} from "@tanstack/solid-query";
import { getVersion } from "@tauri-apps/api/app";
-import { getCurrentWindow } from "@tauri-apps/api/window";
+import { availableMonitors, getCurrentWindow } from "@tauri-apps/api/window";
import { LogicalSize } from "@tauri-apps/api/window";
import { cx } from "cva";
import {
diff --git a/crates/ffmpeg-hw-device/src/lib.rs b/crates/ffmpeg-hw-device/src/lib.rs
index 91b766e49..8b7bc921e 100644
--- a/crates/ffmpeg-hw-device/src/lib.rs
+++ b/crates/ffmpeg-hw-device/src/lib.rs
@@ -84,18 +84,17 @@ impl CodecContextExt for codec::decoder::decoder::Decoder {
return Err("no hw config");
};
- HW_PIX_FMT.set((*hw_config).pix_fmt);
-
- let context = self.as_mut_ptr();
-
- (*context).get_format = Some(get_format);
-
let mut hw_device_ctx = null_mut();
if av_hwdevice_ctx_create(&mut hw_device_ctx, device_type, null(), null_mut(), 0) < 0 {
return Err("failed to create hw device context");
}
+ HW_PIX_FMT.set((*hw_config).pix_fmt);
+
+ let context = self.as_mut_ptr();
+
+ (*context).get_format = Some(get_format);
(*context).hw_device_ctx = av_buffer_ref(hw_device_ctx);
Ok(HwDevice {
diff --git a/crates/media/src/platform/macos.rs b/crates/media/src/platform/macos.rs
index 544aacbbf..dcd652504 100644
--- a/crates/media/src/platform/macos.rs
+++ b/crates/media/src/platform/macos.rs
@@ -8,7 +8,7 @@ use core_foundation::{
};
use core_graphics::{
base::boolean_t,
- display::{CFArrayGetValueAtIndex, CFDictionaryRef, CGRect},
+ display::{CFArrayGetValueAtIndex, CFDictionaryRef, CGDisplay, CGDisplayBounds, CGRect},
window::{
kCGNullWindowID, kCGWindowBounds, kCGWindowLayer, kCGWindowListExcludeDesktopElements,
kCGWindowListOptionOnScreenOnly, kCGWindowName, kCGWindowNumber, kCGWindowOwnerName,
@@ -370,3 +370,19 @@ pub fn display_for_window(
None
}
+
+pub fn primary_monitor_bounds() -> Bounds {
+ let display = CGDisplay::main();
+ let height = display.pixels_high();
+ let width = display.pixels_wide();
+ let bounds = unsafe { CGDisplayBounds(display.id) };
+
+ dbg!(bounds);
+
+ Bounds {
+ x: bounds.origin.x,
+ y: bounds.origin.y,
+ width: width as f64,
+ height: height as f64,
+ }
+}
diff --git a/crates/recording/src/cursor.rs b/crates/recording/src/cursor.rs
index 91ef645b3..8357e091e 100644
--- a/crates/recording/src/cursor.rs
+++ b/crates/recording/src/cursor.rs
@@ -116,77 +116,105 @@ pub fn spawn_cursor_recorder(
} else {
"default".to_string()
};
+ // dbg!(&mouse_state, &screen_bounds);
if mouse_state.coords != last_mouse_state.coords {
// Get the actual mouse coordinates
let (mouse_x, mouse_y) = mouse_state.coords;
-
+
#[cfg(windows)]
let (mouse_x, mouse_y) = {
// On Windows, ensure we're using the correct coordinate system
// by getting the virtual screen metrics
use windows::Win32::UI::WindowsAndMessaging::GetSystemMetrics;
use windows::Win32::UI::WindowsAndMessaging::{
- SM_XVIRTUALSCREEN, SM_YVIRTUALSCREEN, SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN
+ SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN, SM_XVIRTUALSCREEN,
+ SM_YVIRTUALSCREEN,
};
-
+
let virtual_screen_x = unsafe { GetSystemMetrics(SM_XVIRTUALSCREEN) };
let virtual_screen_y = unsafe { GetSystemMetrics(SM_YVIRTUALSCREEN) };
let virtual_screen_width = unsafe { GetSystemMetrics(SM_CXVIRTUALSCREEN) };
let virtual_screen_height = unsafe { GetSystemMetrics(SM_CYVIRTUALSCREEN) };
-
+
// If screen_bounds doesn't match the virtual screen, adjust the coordinates
- if (screen_bounds.x as i32 != virtual_screen_x ||
- screen_bounds.y as i32 != virtual_screen_y ||
- screen_bounds.width as i32 != virtual_screen_width ||
- screen_bounds.height as i32 != virtual_screen_height) &&
- screen_bounds.width > 0.0 && screen_bounds.height > 0.0 {
-
+ if (screen_bounds.x as i32 != virtual_screen_x
+ || screen_bounds.y as i32 != virtual_screen_y
+ || screen_bounds.width as i32 != virtual_screen_width
+ || screen_bounds.height as i32 != virtual_screen_height)
+ && screen_bounds.width > 0.0
+ && screen_bounds.height > 0.0
+ {
// Convert to normalized coordinates in the virtual screen space first
- let norm_x = (mouse_x as f64 - virtual_screen_x as f64) / virtual_screen_width as f64;
- let norm_y = (mouse_y as f64 - virtual_screen_y as f64) / virtual_screen_height as f64;
-
+ let norm_x = (mouse_x as f64 - virtual_screen_x as f64)
+ / virtual_screen_width as f64;
+ let norm_y = (mouse_y as f64 - virtual_screen_y as f64)
+ / virtual_screen_height as f64;
+
// Then convert to the target screen coordinates
- let adjusted_x = (norm_x * screen_bounds.width + screen_bounds.x) as i32;
- let adjusted_y = (norm_y * screen_bounds.height + screen_bounds.y) as i32;
+ let adjusted_x =
+ (norm_x * screen_bounds.width + screen_bounds.x) as i32;
+ let adjusted_y =
+ (norm_y * screen_bounds.height + screen_bounds.y) as i32;
(adjusted_x, adjusted_y)
} else {
(mouse_x, mouse_y)
}
};
-
+
+ #[cfg(target_os = "macos")]
+ let (mouse_x, mouse_y) = {
+ let primary_bounds = cap_media::platform::primary_monitor_bounds();
+ dbg!(primary_bounds);
+
+ let mouse_x = mouse_x - screen_bounds.x as i32;
+ let mouse_y = mouse_y
+ + (screen_bounds.y + screen_bounds.height - primary_bounds.height)
+ as i32;
+
+ (mouse_x, mouse_y)
+ };
+
+ #[cfg(not(any(windows, target_os = "macos")))]
+ let (mouse_x, mouse_y) = {
+ (
+ mouse_x - screen_bounds.x as i32,
+ mouse_y - screen_bounds.y as i32,
+ )
+ };
+
// Calculate normalized coordinates (0.0 to 1.0) within the screen bounds
// Check if screen_bounds dimensions are valid to avoid division by zero
let x = if screen_bounds.width > 0.0 {
- (mouse_x as f64 - screen_bounds.x) / screen_bounds.width
+ mouse_x as f64 / screen_bounds.width
} else {
0.5 // Fallback if width is invalid
};
-
+
let y = if screen_bounds.height > 0.0 {
- (mouse_y as f64 - screen_bounds.y) / screen_bounds.height
+ mouse_y as f64 / screen_bounds.height
} else {
0.5 // Fallback if height is invalid
};
-
+
// Clamp values to ensure they're within valid range
- let x = if x.is_nan() || x.is_infinite() {
+ let x = if x.is_nan() || x.is_infinite() {
debug!("X coordinate is invalid: {}", x);
- 0.5
- } else {
- x.max(0.0).min(1.0)
+ 0.5
+ } else {
+ x.max(0.0).min(1.0)
};
-
- let y = if y.is_nan() || y.is_infinite() {
+
+ let y = if y.is_nan() || y.is_infinite() {
debug!("Y coordinate is invalid: {}", y);
- 0.5
- } else {
- y.max(0.0).min(1.0)
+ 0.5
+ } else {
+ y.max(0.0).min(1.0)
};
-
+
debug!("Normalized coords: ({}, {})", x, y);
-
+
let mouse_event = CursorMoveEvent {
active_modifiers: vec![],
cursor_id: cursor_id.clone(),
@@ -209,42 +237,48 @@ pub fn spawn_cursor_recorder(
// Get the actual mouse coordinates
let (mouse_x, mouse_y) = mouse_state.coords;
-
+
#[cfg(windows)]
let (mouse_x, mouse_y) = {
// On Windows, ensure we're using the correct coordinate system
// by getting the virtual screen metrics
use windows::Win32::UI::WindowsAndMessaging::GetSystemMetrics;
use windows::Win32::UI::WindowsAndMessaging::{
- SM_XVIRTUALSCREEN, SM_YVIRTUALSCREEN, SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN
+ SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN, SM_XVIRTUALSCREEN,
+ SM_YVIRTUALSCREEN,
};
-
+
let virtual_screen_x = unsafe { GetSystemMetrics(SM_XVIRTUALSCREEN) };
let virtual_screen_y = unsafe { GetSystemMetrics(SM_YVIRTUALSCREEN) };
let virtual_screen_width = unsafe { GetSystemMetrics(SM_CXVIRTUALSCREEN) };
let virtual_screen_height = unsafe { GetSystemMetrics(SM_CYVIRTUALSCREEN) };
-
+
// If screen_bounds doesn't match the virtual screen, adjust the coordinates
- if (screen_bounds.x as i32 != virtual_screen_x ||
- screen_bounds.y as i32 != virtual_screen_y ||
- screen_bounds.width as i32 != virtual_screen_width ||
- screen_bounds.height as i32 != virtual_screen_height) &&
- screen_bounds.width > 0.0 && screen_bounds.height > 0.0 {
-
+ if (screen_bounds.x as i32 != virtual_screen_x
+ || screen_bounds.y as i32 != virtual_screen_y
+ || screen_bounds.width as i32 != virtual_screen_width
+ || screen_bounds.height as i32 != virtual_screen_height)
+ && screen_bounds.width > 0.0
+ && screen_bounds.height > 0.0
+ {
// Convert to normalized coordinates in the virtual screen space first
- let norm_x = (mouse_x as f64 - virtual_screen_x as f64) / virtual_screen_width as f64;
- let norm_y = (mouse_y as f64 - virtual_screen_y as f64) / virtual_screen_height as f64;
-
+ let norm_x = (mouse_x as f64 - virtual_screen_x as f64)
+ / virtual_screen_width as f64;
+ let norm_y = (mouse_y as f64 - virtual_screen_y as f64)
+ / virtual_screen_height as f64;
+
// Then convert to the target screen coordinates
- let adjusted_x = (norm_x * screen_bounds.width + screen_bounds.x) as i32;
- let adjusted_y = (norm_y * screen_bounds.height + screen_bounds.y) as i32;
-
+ let adjusted_x =
+ (norm_x * screen_bounds.width + screen_bounds.x) as i32;
+ let adjusted_y =
+ (norm_y * screen_bounds.height + screen_bounds.y) as i32;
+
(adjusted_x, adjusted_y)
} else {
(mouse_x, mouse_y)
}
};
-
+
// Calculate normalized coordinates (0.0 to 1.0) within the screen bounds
// Check if screen_bounds dimensions are valid to avoid division by zero
let x = if screen_bounds.width > 0.0 {
@@ -252,16 +286,24 @@ pub fn spawn_cursor_recorder(
} else {
0.5 // Fallback if width is invalid
};
-
+
let y = if screen_bounds.height > 0.0 {
(mouse_y as f64 - screen_bounds.y) / screen_bounds.height
} else {
0.5 // Fallback if height is invalid
};
-
+
// Clamp values to ensure they're within valid range
- let x = if x.is_nan() || x.is_infinite() { 0.5 } else { x.max(0.0).min(1.0) };
- let y = if y.is_nan() || y.is_infinite() { 0.5 } else { y.max(0.0).min(1.0) };
+ let x = if x.is_nan() || x.is_infinite() {
+ 0.5
+ } else {
+ x.max(0.0).min(1.0)
+ };
+ let y = if y.is_nan() || y.is_infinite() {
+ 0.5
+ } else {
+ y.max(0.0).min(1.0)
+ };
let mouse_event = CursorClickEvent {
down: pressed,
@@ -354,11 +396,11 @@ fn get_cursor_image_data() -> Option<CursorData> {
fn get_cursor_image_data() -> Option<CursorData> {
use windows::Win32::Foundation::{HWND, POINT};
use windows::Win32::Graphics::Gdi::{
- CreateCompatibleDC, CreateDIBSection, DeleteDC, DeleteObject, GetDC,
- GetObjectA, ReleaseDC, SelectObject, BITMAP, BITMAPINFO, BITMAPINFOHEADER, DIB_RGB_COLORS,
+ CreateCompatibleDC, CreateDIBSection, DeleteDC, DeleteObject, GetDC, GetObjectA, ReleaseDC,
+ SelectObject, BITMAP, BITMAPINFO, BITMAPINFOHEADER, DIB_RGB_COLORS,
};
+ use windows::Win32::UI::WindowsAndMessaging::{DrawIconEx, GetIconInfo, DI_NORMAL, ICONINFO};
use windows::Win32::UI::WindowsAndMessaging::{GetCursorInfo, CURSORINFO, CURSORINFO_FLAGS};
- use windows::Win32::UI::WindowsAndMessaging::{DrawIconEx, GetIconInfo, ICONINFO, DI_NORMAL};
unsafe {
// Get cursor info
@@ -410,7 +452,7 @@ fn get_cursor_image_data() -> Option<CursorData> {
// Create DCs
let screen_dc = GetDC(HWND::default());
let mem_dc = CreateCompatibleDC(screen_dc);
-
+
// Get cursor dimensions
let width = bitmap.bmWidth;
let height = if icon_info.hbmColor.is_invalid() && bitmap.bmHeight > 0 {
@@ -426,7 +468,7 @@ fn get_cursor_image_data() -> Option<CursorData> {
biWidth: width,
biHeight: -height, // Negative for top-down DIB
biPlanes: 1,
- biBitCount: 32, // 32-bit RGBA
+ biBitCount: 32, // 32-bit RGBA
biCompression: 0,
biSizeImage: 0,
biXPelsPerMeter: 0,
@@ -468,12 +510,14 @@ fn get_cursor_image_data() -> Option<CursorData> {
0,
0,
cursor_info.hCursor,
- 0, // Use actual size
- 0, // Use actual size
+ 0, // Use actual size
+ 0, // Use actual size
0,
None,
DI_NORMAL,
- ).is_err() {
+ )
+ .is_err()
+ {
// Clean up
SelectObject(mem_dc, old_bitmap);
DeleteObject(dib);
@@ -494,16 +538,16 @@ fn get_cursor_image_data() -> Option<CursorData> {
std::ptr::copy_nonoverlapping(bits, image_data.as_mut_ptr() as *mut _, size);
// Calculate hotspot
- let mut hotspot_x = if icon_info.fIcon.as_bool() == false {
- icon_info.xHotspot as f64 / width as f64
- } else {
- 0.5
+ let mut hotspot_x = if icon_info.fIcon.as_bool() == false {
+ icon_info.xHotspot as f64 / width as f64
+ } else {
+ 0.5
};
-
- let mut hotspot_y = if icon_info.fIcon.as_bool() == false {
- icon_info.yHotspot as f64 / height as f64
- } else {
- 0.5
+
+ let mut hotspot_y = if icon_info.fIcon.as_bool() == false {
+ icon_info.yHotspot as f64 / height as f64
+ } else {
+ 0.5
};
// Cleanup
@@ -524,40 +568,46 @@ fn get_cursor_image_data() -> Option<CursorData> {
// 1. Swap B and R channels
let b = image_data[i];
image_data[i] = image_data[i + 2]; // B <- R
- image_data[i + 2] = b; // R <- B
-
+ image_data[i + 2] = b; // R <- B
+
// 2. Pre-multiply alpha if needed
// This is already handled by DrawIconEx
}
// Convert to RGBA image
let mut rgba_image = image::RgbaImage::from_raw(width as u32, height as u32, image_data)?;
-
+
// For text cursor (I-beam), enhance visibility by adding a shadow/outline
// Check if this is likely a text cursor by examining dimensions and pixels
let is_text_cursor = width <= 20 && height >= 20 && width <= height / 2;
-
+
if is_text_cursor {
// Add a subtle shadow/outline to make it visible on white backgrounds
for y in 0..height as u32 {
for x in 0..width as u32 {
let pixel = rgba_image.get_pixel(x, y);
// If this is a solid pixel of the cursor
- if pixel[3] > 200 { // If alpha is high (visible pixel)
+ if pixel[3] > 200 {
+ // If alpha is high (visible pixel)
// Add shadow pixels around it
for dx in [-1, 0, 1].iter() {
for dy in [-1, 0, 1].iter() {
let nx = x as i32 + dx;
let ny = y as i32 + dy;
-
+
// Skip if out of bounds or same pixel
- if nx < 0 || ny < 0 || nx >= width as i32 || ny >= height as i32 || (*dx == 0 && *dy == 0) {
+ if nx < 0
+ || ny < 0
+ || nx >= width as i32
+ || ny >= height as i32
+ || (*dx == 0 && *dy == 0)
+ {
continue;
}
-
+
let nx = nx as u32;
let ny = ny as u32;
-
+
let shadow_pixel = rgba_image.get_pixel(nx, ny);
// Only add shadow where there isn't already content
if shadow_pixel[3] < 100 {
@@ -569,19 +619,20 @@ fn get_cursor_image_data() -> Option<CursorData> {
}
}
}
-
+
// Find the bounds of non-transparent pixels to trim whitespace
let mut min_x = width as u32;
let mut min_y = height as u32;
let mut max_x = 0u32;
let mut max_y = 0u32;
-
+
let mut has_content = false;
-
+
for y in 0..height as u32 {
for x in 0..width as u32 {
let pixel = rgba_image.get_pixel(x, y);
- if pixel[3] > 0 { // If pixel has any opacity
+ if pixel[3] > 0 {
+ // If pixel has any opacity
has_content = true;
min_x = min_x.min(x);
min_y = min_y.min(y);
@@ -590,22 +641,24 @@ fn get_cursor_image_data() -> Option<CursorData> {
}
}
}
-
+
// Only trim if we found content and there's actually whitespace to trim
- let trimmed_image = if has_content && (min_x > 0 || min_y > 0 || max_x < width as u32 - 1 || max_y < height as u32 - 1) {
+ let trimmed_image = if has_content
+ && (min_x > 0 || min_y > 0 || max_x < width as u32 - 1 || max_y < height as u32 - 1)
+ {
// Add a small padding (2 pixels) around the content
let padding = 2u32;
let trim_min_x = min_x.saturating_sub(padding);
let trim_min_y = min_y.saturating_sub(padding);
let trim_max_x = (max_x + padding).min(width as u32 - 1);
let trim_max_y = (max_y + padding).min(height as u32 - 1);
-
+
let trim_width = trim_max_x - trim_min_x + 1;
let trim_height = trim_max_y - trim_min_y + 1;
-
+
// Create a new image with the trimmed dimensions
let mut trimmed = image::RgbaImage::new(trim_width, trim_height);
-
+
// Copy the content to the new image
for y in 0..trim_height {
for x in 0..trim_width {
@@ -615,16 +668,16 @@ fn get_cursor_image_data() -> Option<CursorData> {
trimmed.put_pixel(x, y, *pixel);
}
}
-
+
// Adjust hotspot coordinates for the trimmed image
hotspot_x = (hotspot_x * width as f64 - trim_min_x as f64) / trim_width as f64;
hotspot_y = (hotspot_y * height as f64 - trim_min_y as f64) / trim_height as f64;
-
+
trimmed
} else {
rgba_image
};
-
+
// Convert to PNG format
let mut png_data = Vec::new();
trimmed_image
diff --git a/crates/rendering/src/decoder/ffmpeg.rs b/crates/rendering/src/decoder/ffmpeg.rs
index a61542114..25156e59c 100644
--- a/crates/rendering/src/decoder/ffmpeg.rs
+++ b/crates/rendering/src/decoder/ffmpeg.rs
@@ -117,41 +117,28 @@ impl FfmpegDecoder {
}
}
- for config in decoder.codec().unwrap().hw_configs() {
- unsafe {
- dbg!((*config).device_type);
- }
- }
-
// Get video dimensions to check against hardware acceleration limits
let width = decoder.width();
let height = decoder.height();
-
- // Hardware acceleration has dimension limits (typically 4096x4096 for h264)
- // Only attempt to use hardware acceleration if the video dimensions are within these limits
- let hw_device = if width <= 4096 && height <= 4096 {
- let hw_device_types = if cfg!(target_os = "macos") {
- [AVHWDeviceType::AV_HWDEVICE_TYPE_VIDEOTOOLBOX].as_slice()
- } else {
- [
- AVHWDeviceType::AV_HWDEVICE_TYPE_CUDA,
- AVHWDeviceType::AV_HWDEVICE_TYPE_D3D12VA,
- AVHWDeviceType::AV_HWDEVICE_TYPE_D3D11VA,
- AVHWDeviceType::AV_HWDEVICE_TYPE_VAAPI,
- AVHWDeviceType::AV_HWDEVICE_TYPE_VULKAN,
- AVHWDeviceType::AV_HWDEVICE_TYPE_DXVA2,
- ]
- .as_slice()
- };
- hw_device_types
- .iter()
- .find_map(|&typ| decoder.try_use_hw_device(typ).ok())
+ let hw_device_types = if cfg!(target_os = "macos") {
+ [AVHWDeviceType::AV_HWDEVICE_TYPE_VIDEOTOOLBOX].as_slice()
} else {
- println!("Video dimensions ({width}x{height}) exceed hardware acceleration limits, using software decoding");
- None
+ [
+ AVHWDeviceType::AV_HWDEVICE_TYPE_CUDA,
+ AVHWDeviceType::AV_HWDEVICE_TYPE_D3D12VA,
+ AVHWDeviceType::AV_HWDEVICE_TYPE_D3D11VA,
+ AVHWDeviceType::AV_HWDEVICE_TYPE_VAAPI,
+ AVHWDeviceType::AV_HWDEVICE_TYPE_VULKAN,
+ AVHWDeviceType::AV_HWDEVICE_TYPE_DXVA2,
+ ]
+ .as_slice()
};
+ let hw_device = hw_device_types
+ .iter()
+ .find_map(|&typ| decoder.try_use_hw_device(typ).ok());
+
let mut temp_frame = ffmpeg::frame::Video::empty();
// let mut packets = input.packets().peekable();