diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3e5bec0bd..77afebc97f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,8 +103,9 @@ jobs: settings: - target: aarch64-apple-darwin runner: macos-latest - - target: x86_64-pc-windows-msvc - runner: windows-latest + # Windows can't take the disk usage lol + # - target: x86_64-pc-windows-msvc + # runner: windows-latest runs-on: ${{ matrix.settings.runner }} permissions: contents: read diff --git a/crates/video-decode/src/avassetreader.rs b/crates/video-decode/src/avassetreader.rs index 58eb04436d..dc2e53a6c4 100644 --- a/crates/video-decode/src/avassetreader.rs +++ b/crates/video-decode/src/avassetreader.rs @@ -16,11 +16,13 @@ pub struct AVAssetReaderDecoder { tokio_handle: TokioHandle, track_output: R, reader: R, + width: u32, + height: u32, } impl AVAssetReaderDecoder { pub fn new(path: PathBuf, tokio_handle: TokioHandle) -> Result { - let pixel_format = { + let (pixel_format, width, height) = { let input = ffmpeg::format::input(&path).unwrap(); let input_stream = input @@ -35,11 +37,15 @@ impl AVAssetReaderDecoder { .video() .map_err(|e| format!("video decoder / {e}"))?; - pixel_to_pixel_format(decoder.format()) + ( + pixel_to_pixel_format(decoder.format()), + decoder.width(), + decoder.height(), + ) }; let (track_output, reader) = - Self::get_reader_track_output(&path, 0.0, &tokio_handle, pixel_format)?; + Self::get_reader_track_output(&path, 0.0, &tokio_handle, pixel_format, width, height)?; Ok(Self { path, @@ -47,6 +53,8 @@ impl AVAssetReaderDecoder { tokio_handle, track_output, reader, + width, + height, }) } @@ -57,6 +65,8 @@ impl AVAssetReaderDecoder { requested_time, &self.tokio_handle, self.pixel_format, + self.width, + self.height, )?; Ok(()) @@ -67,6 +77,8 @@ impl AVAssetReaderDecoder { time: f32, handle: &TokioHandle, pixel_format: cv::PixelFormat, + width: u32, + height: u32, ) -> Result<(R, R), String> { let asset = av::UrlAsset::with_url( &ns::Url::with_fs_path_str(path.to_str().unwrap(), false), @@ -93,8 +105,16 @@ impl AVAssetReaderDecoder { let mut reader_track_output = av::AssetReaderTrackOutput::with_track( &track, Some(&ns::Dictionary::with_keys_values( - &[cv::pixel_buffer::keys::pixel_format().as_ns()], - &[pixel_format.to_cf_number().as_ns().as_id_ref()], + &[ + cv::pixel_buffer::keys::pixel_format().as_ns(), + cv::pixel_buffer::keys::width().as_ns(), + cv::pixel_buffer::keys::height().as_ns(), + ], + &[ + pixel_format.to_cf_number().as_ns().as_id_ref(), + ns::Number::with_u32(width).as_id_ref(), + ns::Number::with_u32(height).as_id_ref(), + ], )), ) .map_err(|e| format!("asset.reader_track_output{{{pixel_format:?}}}): {e}"))?;