-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Hls recording fixes #1717
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
Hls recording fixes #1717
Changes from all commits
87c6050
75f10ef
4a4d6b3
4c6b244
089322a
838be12
4788604
682c412
2ac92cc
5ed3468
ba38709
144b9e1
0554bad
8c9c7c3
7bd6ee3
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 |
|---|---|---|
|
|
@@ -1645,6 +1645,55 @@ pub(crate) async fn create_screenshot( | |
| result | ||
| } | ||
|
|
||
| pub(crate) async fn create_screenshot_source_from_segments( | ||
| segments_dir: &std::path::Path, | ||
| ) -> Result<PathBuf, String> { | ||
| let init_path = segments_dir.join("init.mp4"); | ||
| if !init_path.exists() { | ||
| return Err(format!("init.mp4 not found in {}", segments_dir.display())); | ||
| } | ||
|
|
||
| let first_segment = find_first_segment(segments_dir) | ||
| .ok_or_else(|| format!("No .m4s segments found in {}", segments_dir.display()))?; | ||
|
|
||
| let temp_path = segments_dir.join(".screenshot_source.mp4"); | ||
|
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.
|
||
| let mut out = tokio::fs::File::create(&temp_path) | ||
| .await | ||
| .map_err(|e| format!("Failed to create screenshot source: {e}"))?; | ||
|
|
||
| let mut init_file = tokio::fs::File::open(&init_path) | ||
| .await | ||
| .map_err(|e| format!("Failed to open init.mp4: {e}"))?; | ||
| tokio::io::copy(&mut init_file, &mut out) | ||
| .await | ||
| .map_err(|e| format!("Failed to copy init.mp4: {e}"))?; | ||
|
|
||
| let mut seg_file = tokio::fs::File::open(&first_segment) | ||
| .await | ||
| .map_err(|e| format!("Failed to open {}: {e}", first_segment.display()))?; | ||
| tokio::io::copy(&mut seg_file, &mut out) | ||
| .await | ||
| .map_err(|e| format!("Failed to copy segment: {e}"))?; | ||
|
|
||
| Ok(temp_path) | ||
| } | ||
|
|
||
| fn find_first_segment(dir: &std::path::Path) -> Option<PathBuf> { | ||
| let mut segments: Vec<PathBuf> = std::fs::read_dir(dir) | ||
| .ok()? | ||
| .filter_map(|e| { | ||
| let path = e.ok()?.path(); | ||
| if path.extension().is_some_and(|ext| ext == "m4s") { | ||
| Some(path) | ||
| } else { | ||
| None | ||
| } | ||
| }) | ||
| .collect(); | ||
| segments.sort(); | ||
| segments.into_iter().next() | ||
| } | ||
|
|
||
| // async fn create_thumbnail(input: PathBuf, output: PathBuf, size: (u32, u32)) -> Result<(), String> { | ||
| // println!("Creating thumbnail: input={input:?}, output={output:?}, size={size:?}"); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RetryableHttpClienthas a connect timeout but no overall request timeout. A stalled request could hang for a long time even with retries. Consider adding.timeout(...)likeHttpClient.