Compare commits

...

4 Commits

Author SHA1 Message Date
Xinrea
08979d2079 bump version to 2.13.8 2025-09-29 19:36:50 +08:00
Xinrea
c6efe07303 fix: clip black screen at beginning 2025-09-29 01:06:47 +08:00
Xinrea
7294f0ca6d fix: progress report for transcode 2025-09-28 19:54:49 +08:00
Xinrea
eac1c09149 feat: add hevc option for bilibili
clip from hevc live needs fix-encoding
2025-09-28 19:48:33 +08:00
6 changed files with 30 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "bili-shadowreplay",
"private": true,
"version": "2.13.7",
"version": "2.13.8",
"type": "module",
"scripts": {
"dev": "vite",

2
src-tauri/Cargo.lock generated
View File

@@ -553,7 +553,7 @@ checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba"
[[package]]
name = "bili-shadowreplay"
version = "2.13.7"
version = "2.13.8"
dependencies = [
"async-ffmpeg-sidecar",
"async-std",

View File

@@ -4,7 +4,7 @@ resolver = "2"
[package]
name = "bili-shadowreplay"
version = "2.13.7"
version = "2.13.8"
description = "BiliBili ShadowReplay"
authors = ["Xinrea"]
license = ""

View File

@@ -82,6 +82,7 @@ pub async fn transcode(
let child = ffmpeg_process
.args([output_path.to_str().unwrap()])
.args(["-y"])
.args(["-progress", "pipe:2"])
.stderr(Stdio::piped())
.spawn();
if let Err(e) = child {
@@ -131,8 +132,8 @@ pub async fn trim_video(
#[cfg(target_os = "windows")]
ffmpeg_process.creation_flags(CREATE_NO_WINDOW);
ffmpeg_process.args(["-i", file.to_str().unwrap()]);
ffmpeg_process.args(["-ss", &start_time.to_string()]);
ffmpeg_process.args(["-i", file.to_str().unwrap()]);
ffmpeg_process.args(["-t", &duration.to_string()]);
ffmpeg_process.args(["-c", "copy"]);
ffmpeg_process.args([output_path.to_str().unwrap()]);
@@ -1165,7 +1166,12 @@ pub async fn convert_fmp4_to_ts_raw(
let child = ffmpeg_process
.args(["-f", "mp4"])
.args(["-i", "-"]) // Read from stdin
.args(["-c", "copy"]) // Stream copy (no re-encoding)
.args(["-c:v", "libx264"])
.args(["-b:v", "6000k"])
.args(["-maxrate", "10000k"])
.args(["-bufsize", "16000k"])
.args(["-c:a", "copy"])
.args(["-threads", "0"])
.args(["-f", "mpegts"])
.args(["-y", output_ts.to_str().unwrap()]) // Overwrite output
.args(["-progress", "pipe:2"]) // Progress to stderr

View File

@@ -400,7 +400,7 @@ impl BiliRecorder {
self.room_id,
Protocol::HttpHls,
Format::FMP4,
Codec::Avc,
&[Codec::Avc, Codec::Hevc],
Qn::Q4K,
)
.await;
@@ -444,7 +444,7 @@ impl BiliRecorder {
self.room_id,
Protocol::HttpHls,
Format::TS,
Codec::Avc,
&[Codec::Avc, Codec::Hevc],
Qn::Q4K,
)
.await;

View File

@@ -444,7 +444,7 @@ impl BiliClient {
room_id: i64,
protocol: Protocol,
format: Format,
codec: Codec,
codec: &[Codec],
qn: Qn,
) -> Result<BiliStream, BiliClientError> {
let url = format!(
@@ -452,7 +452,7 @@ impl BiliClient {
room_id,
protocol.clone() as u8,
format.clone() as u8,
codec.clone() as u8,
codec.iter().map(|c| (c.clone() as u8).to_string()).collect::<Vec<String>>().join(","),
qn as i64,
);
let mut headers = self.generate_user_agent_header();
@@ -515,17 +515,20 @@ impl BiliClient {
.ok_or_else(|| BiliClientError::FormatNotFound(target_format.to_owned()))?;
// Find the matching codec
let target_codec = match codec {
let target_codecs = codec
.iter()
.map(|c| match c {
Codec::Avc => "avc",
Codec::Hevc => "hevc",
};
})
.collect::<Vec<&str>>();
let codec_info = format_info["codec"]
.as_array()
.unwrap_or(&empty_vec)
.iter()
.find(|c| c["codec_name"].as_str() == Some(target_codec))
.ok_or_else(|| BiliClientError::CodecNotFound(target_codec.to_owned()))?;
.find(|c| target_codecs.contains(&c["codec_name"].as_str().unwrap_or("")))
.ok_or_else(|| BiliClientError::CodecNotFound(target_codecs.join(",")))?;
let url_info = codec_info["url_info"].as_array().unwrap_or(&empty_vec);
@@ -540,6 +543,12 @@ impl BiliClient {
let drm = codec_info["drm"].as_bool().unwrap_or(false);
let base_url = codec_info["base_url"].as_str().unwrap_or("").to_string();
let master_url = format_info["master_url"].as_str().map(|s| s.to_string());
let codec = codec_info["codec_name"].as_str().unwrap_or("");
let codec = match codec {
"avc" => Codec::Avc,
"hevc" => Codec::Hevc,
_ => return Err(BiliClientError::CodecNotFound(codec.to_string())),
};
Ok(BiliStream {
format,