-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Stop muxer on queue_frame fail #1163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b1ca335
5453207
7c62a43
37063e7
edf5e83
6189dff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,10 +139,18 @@ | |
| pub struct H264Encoder { | ||
| base: EncoderBase, | ||
| encoder: encoder::Video, | ||
| config: VideoInfo, | ||
|
Check warning on line 142 in crates/enc-ffmpeg/src/video/h264.rs
|
||
| converter: Option<ffmpeg::software::scaling::Context>, | ||
| } | ||
|
|
||
| #[derive(thiserror::Error, Debug)] | ||
| pub enum QueueFrameError { | ||
| #[error("Converter: {0}")] | ||
| Converter(ffmpeg::Error), | ||
| #[error("Encode: {0}")] | ||
| Encode(ffmpeg::Error), | ||
| } | ||
|
|
||
| impl H264Encoder { | ||
| const TIME_BASE: i32 = 90000; | ||
|
|
||
|
|
@@ -155,42 +163,32 @@ | |
| mut frame: frame::Video, | ||
| timestamp: Duration, | ||
| output: &mut format::context::Output, | ||
| ) { | ||
| ) -> Result<(), QueueFrameError> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainError propagation pattern looks good. Verify caller handling. The change from logging errors inline to propagating them via Run the following script to verify that all callers of Also applies to: 172-176, 181-185 🏁 Script executed: #!/bin/bash
# Search for all calls to queue_frame and show surrounding context
# to verify error handling patterns
rg -nP -A5 -B2 '\.queue_frame\s*\(' --type rust -g '!**/target/**'Length of output: 148 🏁 Script executed: #!/bin/bash
# Search for all calls to queue_frame in Rust files excluding target directory
rg -nP -A5 -B2 '\bqueue_frame\s*\(' -g '*.rs' -g '!**/target/**'Length of output: 4681 Handle propagated errors in all callers of
🤖 Prompt for AI Agents |
||
| self.base | ||
| .update_pts(&mut frame, timestamp, &mut self.encoder); | ||
|
|
||
| let frame = if let Some(converter) = &mut self.converter { | ||
| let mut new_frame = frame::Video::empty(); | ||
| match converter.run(&frame, &mut new_frame) { | ||
| Ok(_) => { | ||
| new_frame.set_pts(frame.pts()); | ||
| new_frame | ||
| } | ||
| Err(e) => { | ||
| tracing::error!( | ||
| "Failed to convert frame: {} from format {:?} to {:?}", | ||
| e, | ||
| frame.format(), | ||
| converter.output().format | ||
| ); | ||
| // Return early as we can't process this frame | ||
| return; | ||
| } | ||
| } | ||
| converter | ||
| .run(&frame, &mut new_frame) | ||
| .map_err(QueueFrameError::Converter)?; | ||
| new_frame.set_pts(frame.pts()); | ||
| new_frame | ||
| } else { | ||
| frame | ||
| }; | ||
|
|
||
| if let Err(e) = self.base.send_frame(&frame, output, &mut self.encoder) { | ||
| tracing::error!("Failed to send frame to encoder: {:?}", e); | ||
| return; | ||
| } | ||
| self.base | ||
| .send_frame(&frame, output, &mut self.encoder) | ||
| .map_err(QueueFrameError::Encode)?; | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| pub fn finish(&mut self, output: &mut format::context::Output) { | ||
| if let Err(e) = self.base.process_eof(output, &mut self.encoder) { | ||
| tracing::error!("Failed to send EOF to encoder: {:?}", e); | ||
| return; | ||
|
Check warning on line 191 in crates/enc-ffmpeg/src/video/h264.rs
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| mod h264; | ||
| pub mod h264; | ||
| pub use h264::*; |
Uh oh!
There was an error while loading. Please reload this page.