Skip to content

Commit

Permalink
new feature: switch danmaku fps
Browse files Browse the repository at this point in the history
support hdr and hires for b
refine title display
set h264 as default
  • Loading branch information
THMonster committed Jun 21, 2023
1 parent 53c55cb commit 92ce901
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 310 deletions.
121 changes: 34 additions & 87 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,34 @@ on:
push:

jobs:
android:
runs-on: ubuntu-20.04
build:
name: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [aarch64, aarch64-musl, amd64, amd64-musl]
include:
- build: aarch64
os: ubuntu-latest
rust: stable
cross: true
target: aarch64-unknown-linux-gnu
- build: aarch64-musl
os: ubuntu-latest
rust: stable
cross: true
target: aarch64-unknown-linux-musl
- build: amd64
os: ubuntu-latest
rust: stable
cross: false
target: x86_64-unknown-linux-gnu
- build: amd64-musl
os: ubuntu-latest
rust: stable
cross: true
target: x86_64-unknown-linux-musl
fail-fast: false

steps:
- name: Checkout
Expand All @@ -14,98 +40,19 @@ jobs:
submodules: 'recursive'
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: aarch64-linux-android
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- uses: actions-rs/cargo@v1
with:
use-cross: true
use-cross: ${{ matrix.cross }}
command: build
args: --release --target aarch64-linux-android
- run: mv ./target/aarch64-linux-android/release/dmlive ./dmlive-android
- uses: ncipollo/release-action@v1
with:
allowUpdates: true
tag: "release"
artifacts: "./dmlive-android"
token: ${{ secrets.GITHUB_TOKEN }}
aarch64:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'recursive'
- run: sudo apt-get install pkg-config libssl-dev p7zip-full
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: aarch64-unknown-linux-gnu
override: true
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target aarch64-unknown-linux-gnu
- run: mv ./target/aarch64-unknown-linux-gnu/release/dmlive ./dmlive-aarch64

- uses: ncipollo/release-action@v1
with:
allowUpdates: true
tag: "release"
artifacts: "./dmlive-aarch64"
token: ${{ secrets.GITHUB_TOKEN }}
amd64:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'recursive'
- run: sudo apt-get install pkg-config libssl-dev p7zip-full
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
override: true
- uses: actions-rs/cargo@v1
with:
command: build
args: --release
- run: mv ./target/release/dmlive ./dmlive-amd64

- uses: ncipollo/release-action@v1
with:
allowUpdates: true
tag: "release"
artifacts: "./dmlive-amd64"
token: ${{ secrets.GITHUB_TOKEN }}
windows:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'recursive'
- run: sudo apt-get install pkg-config libssl-dev p7zip-full
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-pc-windows-gnu
override: true
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target x86_64-pc-windows-gnu
- run: mv ./target/release/dmlive.exe ./dmlive-win64.exe
args: --release --target ${{ matrix.target }}
- run: mv ./target/release/dmlive ./dmlive-${{ matrix.build }} || mv "./target/${{ matrix.target }}/release/dmlive" ./dmlive-${{ matrix.build }}

- uses: ncipollo/release-action@v1
with:
allowUpdates: true
tag: "release"
artifacts: "./dmlive-win64.exe"
artifacts: "./dmlive-${{ matrix.build }}"
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dmlive"
version = "5.2.0"
version = "5.3.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 2 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub struct ConfigManager {
pub font_scale: RwLock<f64>,
pub font_alpha: RwLock<f64>,
pub danmaku_speed: RwLock<u64>,
pub display_fps: RwLock<(u64, u64)>,
pub room_url: String,
pub http_address: Option<String>,
pub run_mode: RunMode,
Expand Down Expand Up @@ -125,6 +126,7 @@ impl ConfigManager {
on_writing: AtomicBool::new(false),
plat,
cookies_from_browser: c.cookies_from_browser.unwrap_or_else(|| "".into()),
display_fps: RwLock::new((60, 0)),
}
}

Expand Down
20 changes: 11 additions & 9 deletions src/ffmpeg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@ use tokio::sync::oneshot;
use tokio::task::spawn_local;
use tokio::time::timeout;
use tokio::{
io::{
AsyncBufReadExt,
AsyncWriteExt,
},
io::{AsyncBufReadExt, AsyncWriteExt},
process::Command,
sync::RwLock,
};

use crate::{
config::ConfigManager,
dmlive::DMLMessage,
};
use crate::{config::ConfigManager, dmlive::DMLMessage};

pub struct FfmpegControl {
ipc_manager: Arc<crate::ipcmanager::IPCManager>,
Expand All @@ -42,9 +36,17 @@ impl FfmpegControl {

async fn run_write_record_task(&self, title: String) -> tokio::task::JoinHandle<()> {
let in_stream = self.ipc_manager.get_f2m_socket_path();
let max_len = match title.char_indices().nth(70) {
Some(it) => it.0,
None => title.len(),
};
spawn_local(async move {
let now = chrono::Local::now();
let filename = format!("{} - {}.mkv", title.replace('/', "-"), now.format("%F %T"));
let filename = format!(
"{} - {}.mkv",
title[..max_len].replace('/', "-"),
now.format("%F %T")
);
loop {
let mut cmd = Command::new("ffmpeg");
cmd.args(&["-y", "-xerror", "-hide_banner", "-nostats", "-nostdin"]);
Expand Down
5 changes: 5 additions & 0 deletions src/mpv/cmdparser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub struct CmdParser {
pub fsup: bool,
pub fsdown: bool,
pub nick: bool,
pub fps: bool,
pub fs: Option<f64>,
pub fa: Option<f64>,
pub speed: Option<u64>,
Expand All @@ -21,6 +22,7 @@ impl CmdParser {
let mut fsup = false;
let mut fsdown = false;
let mut nick = false;
let mut fps = false;
let mut fs = None;
let mut fa = None;
let mut speed = None;
Expand All @@ -41,6 +43,8 @@ impl CmdParser {
fsdown = true;
} else if cmd.trim().eq("nick") {
nick = true;
} else if cmd.trim().eq("fps") {
fps = true;
}
let subcmds: Vec<&str> = cmd.split('=').collect();
let mut iter = subcmds.iter();
Expand Down Expand Up @@ -79,6 +83,7 @@ impl CmdParser {
fsup,
fsdown,
nick,
fps,
fs,
fa,
speed,
Expand Down
Loading

0 comments on commit 92ce901

Please sign in to comment.