Add option to force FFmpeg decoder for video export #1506
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds an experimental option to force the use of the FFmpeg decoder for video exports on macOS, along with related changes to error handling and diagnostics. The main goal is to provide a fallback for users experiencing hardware decoder issues, improving reliability and user experience for MP4 exports.
Greptile Overview
Greptile Summary
This PR adds an experimental option to force FFmpeg decoder usage for MP4 video exports on macOS, addressing hardware decoder reliability issues. The implementation includes:
Key Changes:
AtomicBoolto control decoder selection across the rendering pipelineArchitecture:
The
force_ffmpeg_decoderflag flows from UI → export settings → global state, affecting decoder selection inspawn_decoder(). On macOS, the decoder priority is: forced FFmpeg (if enabled) → AVAssetReader → FFmpeg fallback. Automatic retry occurs when frame decode errors are detected without the flag set.Error Handling Improvements:
FrameDecodeFailederror variant with specific messagingTesting:
Updated benchmark and long video export tests to explicitly set
force_ffmpeg_decoder: false.Confidence Score: 3/5
Important Files Changed
File Analysis
Sequence Diagram
sequenceDiagram participant User as User (ExportPage.tsx) participant Export as export_video (export.rs) participant Rendering as cap_rendering participant Decoder as spawn_decoder (decoder/mod.rs) participant AVAsset as AVAssetReaderDecoder participant FFmpeg as FfmpegDecoder User->>Export: export_video(settings with force_ffmpeg_decoder) Export->>Rendering: set_force_ffmpeg_decoder(force_ffmpeg) Export->>Export: do_export() Export->>Rendering: render_video_to_channel() alt Force FFmpeg is true Rendering->>Decoder: spawn_decoder() Decoder->>FFmpeg: spawn FFmpeg decoder (forced) FFmpeg-->>Decoder: return decoder handle else Force FFmpeg is false (normal path) Rendering->>Decoder: spawn_decoder() Decoder->>AVAsset: spawn AVAssetReader alt AVAssetReader succeeds AVAsset-->>Decoder: return decoder handle else AVAssetReader fails Decoder->>FFmpeg: spawn FFmpeg decoder (fallback) FFmpeg-->>Decoder: return decoder handle with fallback_reason end end Rendering-->>Export: rendering result alt Export succeeds Export->>Rendering: set_force_ffmpeg_decoder(false) Export-->>User: Ok(path) else Export fails with frame decode error AND not forced Export->>Rendering: set_force_ffmpeg_decoder(true) Export->>Export: do_export() retry Export->>Rendering: render with FFmpeg forced alt Retry succeeds Export->>Rendering: set_force_ffmpeg_decoder(false) Export-->>User: Ok(path) else Retry fails Export->>Rendering: set_force_ffmpeg_decoder(false) Export-->>User: Err(retry_e) end else Export fails with other error Export->>Rendering: set_force_ffmpeg_decoder(false) Export-->>User: Err(e) end