├── .github ├── dependabot.yml └── workflows │ ├── ci-version.yml │ └── ci.yml ├── src ├── lib.rs ├── position.rs ├── resolution.rs ├── cli.rs ├── window_info.rs └── main.rs ├── Makefile ├── Cargo.toml ├── LICENSE ├── README.md ├── rustfmt.toml └── .gitignore /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | # FFmpeg Screen Recorder 3 | 4 | This program is a gadget which helps you use **FFmpeg** to record your screen on Linux. The video record can be saved as a file, or be streamed via RTMP protocol. 5 | */ 6 | -------------------------------------------------------------------------------- /src/position.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | pub struct Position { 3 | pub x: i32, 4 | pub y: i32, 5 | } 6 | 7 | impl Position { 8 | #[inline] 9 | pub fn new(x: i32, y: i32) -> Position { 10 | Position { 11 | x, 12 | y, 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | EXECUTABLE_NAME := ffmpeg-screen-recorder 2 | 3 | all: ./target/x86_64-unknown-linux-musl/release/$(EXECUTABLE_NAME) 4 | 5 | ./target/x86_64-unknown-linux-musl/release/$(EXECUTABLE_NAME): $(shell find . -type f -iname '*.rs' -o -name 'Cargo.toml' | grep -v ./target | sed 's/ /\\ /g') 6 | cargo build --release --target x86_64-unknown-linux-musl 7 | 8 | install: 9 | $(MAKE) 10 | sudo cp ./target/x86_64-unknown-linux-musl/release/$(EXECUTABLE_NAME) /usr/local/bin/$(EXECUTABLE_NAME) 11 | sudo chown root: /usr/local/bin/$(EXECUTABLE_NAME) 12 | sudo chmod 0755 /usr/local/bin/$(EXECUTABLE_NAME) 13 | 14 | uninstall: 15 | sudo rm /usr/local/bin/$(EXECUTABLE_NAME) 16 | 17 | test: 18 | cargo test --verbose 19 | 20 | clean: 21 | cargo clean 22 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ffmpeg-screen-recorder" 3 | version = "1.0.21" 4 | authors = ["Magic Len "] 5 | edition = "2021" 6 | rust-version = "1.70" 7 | repository = "https://github.com/magiclen/FFmpeg-Screen-Recorder" 8 | homepage = "https://magiclen.org/ffmpeg-screen-recorder" 9 | keywords = ["ffmpeg", "cli", "screenrecord"] 10 | categories = ["command-line-utilities"] 11 | description = "This program is a gadget which helps you use FFmpeg to record your screen on Linux. The video record can be saved as a file, or be streamed via RTMP protocol." 12 | license = "MIT" 13 | include = ["src/**/*", "Cargo.toml", "README.md", "LICENSE"] 14 | 15 | [profile.release] 16 | lto = true 17 | codegen-units = 1 18 | panic = "abort" 19 | strip = true 20 | 21 | [dependencies] 22 | clap = { version = "4", features = ["derive"] } 23 | concat-with = "0.2" 24 | terminal_size = "0.3" 25 | 26 | anyhow = "1" 27 | 28 | execute = "0.2" 29 | num_cpus = "1" 30 | chrono = "0.4" 31 | nix = { version = "0.27", features = ["signal"] } 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 magiclen.org (Ron Li) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/ci-version.yml: -------------------------------------------------------------------------------- 1 | name: CI-version 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v*" 7 | 8 | env: 9 | CARGO_TERM_COLOR: always 10 | 11 | jobs: 12 | tests: 13 | strategy: 14 | fail-fast: false 15 | matrix: 16 | os: 17 | - ubuntu-latest 18 | toolchain: 19 | - stable 20 | - nightly 21 | target: 22 | - x86_64-unknown-linux-gnu 23 | - x86_64-unknown-linux-musl 24 | features: 25 | - 26 | name: Test ${{ matrix.toolchain }} on ${{ matrix.os }} to ${{ matrix.target }} (${{ matrix.features }}) 27 | runs-on: ${{ matrix.os }} 28 | steps: 29 | - uses: actions/checkout@v4 30 | - uses: actions-rust-lang/setup-rust-toolchain@v1 31 | with: 32 | toolchain: ${{ matrix.toolchain }} 33 | target: ${{ matrix.target }} 34 | - run: cargo test --release --target ${{ matrix.target }} ${{ matrix.features }} 35 | - run: cargo doc --release --target ${{ matrix.target }} ${{ matrix.features }} 36 | 37 | MSRV: 38 | strategy: 39 | fail-fast: false 40 | matrix: 41 | os: 42 | - ubuntu-latest 43 | toolchain: 44 | - "1.70" 45 | target: 46 | - x86_64-unknown-linux-gnu 47 | - x86_64-unknown-linux-musl 48 | features: 49 | - 50 | name: Test ${{ matrix.toolchain }} on ${{ matrix.os }} to ${{ matrix.target }} (${{ matrix.features }}) 51 | runs-on: ${{ matrix.os }} 52 | steps: 53 | - uses: actions/checkout@v4 54 | - uses: actions-rust-lang/setup-rust-toolchain@v1 55 | with: 56 | toolchain: ${{ matrix.toolchain }} 57 | target: ${{ matrix.target }} 58 | - run: cargo test --release --lib --bins --target ${{ matrix.target }} ${{ matrix.features }} -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | FFmpeg Screen Recorder 2 | ==================== 3 | 4 | [![CI](https://github.com/magiclen/FFmpeg-Screen-Recorder/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/FFmpeg-Screen-Recorder/actions/workflows/ci.yml) 5 | 6 | This program is a gadget which helps you use **FFmpeg** to record your screen on Linux. The video record can be saved as a file, or be streamed via RTMP protocol. 7 | 8 | ## Setup 9 | 10 | All you need is **FFmpeg**. You can get one [here](https://ffmpeg.org/). It has to be compiled with **libxcb**, **libfdk-aac** and **libx264** libraries. 11 | 12 | ## Help 13 | 14 | ``` 15 | EXAMPLES: 16 | ffmpeg-screen-recorder # Record the full screen without audio and output into the current working directory 17 | ffmpeg-screen-recorder -w # Select a window and record it without audio and output into the current working directory 18 | ffmpeg-screen-recorder -a # Record the full screen with the system audio and output into the current working directory 19 | ffmpeg-screen-recorder -o /path/to/file # Record the full screen without audio and output to /path/to/file 20 | ffmpeg-screen-recorder -o rtmp://xxx # Record the full screen without audio and output to rtmp://xxx 21 | 22 | Usage: ffmpeg-screen-recorder [OPTIONS] 23 | 24 | Options: 25 | -w, --window Select a window to record 26 | -a, --with-audio Record your screen with audio which could be internal or external. It depends on your computer environment 27 | -n, --no-normalize Do not pad the video size with black borders to the fixed ratio of 16:9 [aliases: nn] 28 | -o, --output Assign a destination of your video. It should be a file path or a RTMP url [default: CWD/