├── .cargo
└── config.toml
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_ae.md
│ ├── bug_openfx.md
│ ├── bug_standalone.md
│ └── feature_request.md
├── RELEASE_TEMPLATE.md
└── workflows
│ └── build-workspace.yml
├── .gitignore
├── .gitmodules
├── Cargo.lock
├── Cargo.toml
├── LICENSE-APACHE-2.0
├── LICENSE-ISC
├── LICENSE-MIT
├── MAINTAINING.md
├── README.md
├── about.toml
├── assets
├── icon.ico
├── icon.png
├── icon.svg
├── install_scripts
│ └── postinstall
├── macos_icon.png
└── macos_icon_less_detail.png
├── crates
├── ae-plugin
│ ├── Cargo.toml
│ ├── README.md
│ ├── build.rs
│ └── src
│ │ ├── handle.rs
│ │ ├── lib.rs
│ │ └── window_handle.rs
├── gui
│ ├── Cargo.toml
│ ├── LICENSE
│ ├── README.md
│ ├── about.json
│ ├── build.rs
│ ├── icon.rc
│ ├── src
│ │ ├── app
│ │ │ ├── app_state.rs
│ │ │ ├── dnd_overlay.rs
│ │ │ ├── error.rs
│ │ │ ├── executor.rs
│ │ │ ├── format_eta.rs
│ │ │ ├── layout_helper.rs
│ │ │ ├── license_dialog.rs
│ │ │ ├── main.rs
│ │ │ ├── mod.rs
│ │ │ ├── pipeline_info.rs
│ │ │ ├── presets.rs
│ │ │ ├── render_job.rs
│ │ │ ├── render_settings.rs
│ │ │ ├── system_fonts.rs
│ │ │ ├── third_party_licenses_dialog.rs
│ │ │ └── ui_context.rs
│ │ ├── bin
│ │ │ ├── ntsc-rs-cli.rs
│ │ │ ├── ntsc-rs-launcher.rs
│ │ │ └── ntsc-rs-standalone.rs
│ │ ├── expression_parser.rs
│ │ ├── gst_utils
│ │ │ ├── clock_format.rs
│ │ │ ├── egui_sink.rs
│ │ │ ├── gstreamer_error.rs
│ │ │ ├── init.rs
│ │ │ ├── mod.rs
│ │ │ ├── multi_file_path.rs
│ │ │ ├── ntsc_pipeline.rs
│ │ │ ├── ntscrs_filter.rs
│ │ │ ├── process_gst_frame.rs
│ │ │ └── video_pad_filter.rs
│ │ ├── lib.rs
│ │ ├── third_party_licenses.rs
│ │ └── widgets
│ │ │ ├── mod.rs
│ │ │ ├── render_job.rs
│ │ │ ├── splitscreen.rs
│ │ │ └── timeline.rs
│ └── todo.md
├── macros
│ ├── Cargo.toml
│ └── src
│ │ └── lib.rs
├── ntscrs
│ ├── Cargo.toml
│ ├── benches
│ │ ├── balloons.png
│ │ └── filter_profile.rs
│ └── src
│ │ ├── f32x4.rs
│ │ ├── filter.rs
│ │ ├── lib.rs
│ │ ├── ntsc.rs
│ │ ├── random.rs
│ │ ├── settings
│ │ ├── easy.rs
│ │ ├── mod.rs
│ │ ├── settings.rs
│ │ └── standard.rs
│ │ ├── shift.rs
│ │ ├── thread_pool.rs
│ │ └── yiq_fielding.rs
└── openfx-plugin
│ ├── .gitignore
│ ├── Cargo.toml
│ ├── README.md
│ ├── build.rs
│ ├── src
│ ├── bindings.rs
│ └── lib.rs
│ └── wrapper.h
├── docs
└── img
│ ├── appdemo.png
│ ├── logo-darkmode.svg
│ └── logo-lightmode.svg
├── rustfmt.toml
└── xtask
├── Cargo.toml
├── README.md
└── src
├── bin
└── xtask.rs
├── build_ofx_plugin.rs
├── lib.rs
├── macos_ae_plugin.rs
├── macos_bundle.rs
└── util
├── mod.rs
└── targets.rs
/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [alias]
2 | xtask = "run --package xtask --"
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_ae.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report (After Effects/Premiere plugin)
3 | about: Report a bug in the After Effects/Premiere plugin
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 | ---
8 |
9 |
28 |
29 | **Describe the bug**
30 |
31 |
32 | **To Reproduce**
33 |
35 |
36 | **Screenshots/Screen Recordings**
37 |
39 |
40 | **Platform Information**
41 | -
43 |
44 | -
46 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_openfx.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report (OpenFX plugin)
3 | about: Report a bug in the OpenFX plugin
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 | ---
8 |
9 |
28 |
29 | **Describe the bug**
30 |
31 |
32 | **To Reproduce**
33 |
35 |
36 | **Screenshots/Screen Recordings**
37 |
39 |
40 | **Platform Information**
41 | -
43 |
44 | -
46 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_standalone.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report (standalone)
3 | about: Report a bug in the standalone application
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 | ---
8 |
9 |
28 |
29 | **Describe the bug**
30 |
31 |
32 | **To Reproduce**
33 |
35 |
36 | **Screenshots/Screen Recordings**
37 |
39 |
40 | **Platform Information**
41 |
43 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: enhancement
6 | assignees: ''
7 | ---
8 |
9 |
24 |
--------------------------------------------------------------------------------
/.github/RELEASE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | # What's new
2 |
3 |
4 | ---
5 |
6 | **For installation instructions and further guidance, see [the Getting Started guide on the ntsc-rs website](https://ntsc.rs/docs/getting-started/).**
7 |
--------------------------------------------------------------------------------
/.github/workflows/build-workspace.yml:
--------------------------------------------------------------------------------
1 | name: Build Workspace
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | tags:
8 | - 'v[0-9]+.[0-9]+.[0-9]+'
9 | - 'v[0-9]+.[0-9]+.[0-9]+-*'
10 | workflow_dispatch:
11 |
12 | env:
13 | CARGO_TERM_COLOR: always
14 |
15 | jobs:
16 | build-linux:
17 | runs-on: ubuntu-22.04
18 |
19 | steps:
20 | - name: Checkout
21 | uses: actions/checkout@v4
22 | with:
23 | submodules: recursive
24 |
25 | # https://github.com/actions/runner-images/issues/9546
26 | - name: Fix broken packages
27 | run: sudo apt-get remove libunwind-*
28 |
29 | - name: Install gstreamer
30 | uses: awalsh128/cache-apt-pkgs-action@v1
31 | with:
32 | packages: libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libatk1.0-dev libgtk-3-dev pkg-config
33 | version: 4.0
34 |
35 | - uses: Swatinem/rust-cache@v2
36 |
37 | - name: Build
38 | run: cargo build --release --workspace
39 |
40 | - name: Build OpenFX plugin
41 | run: cargo xtask build-ofx-plugin --release
42 |
43 | - name: Archive Linux OpenFX plugin
44 | uses: actions/upload-artifact@v4
45 | if: ${{ github.ref_type == 'tag' }}
46 | with:
47 | name: ntsc-rs-linux-openfx
48 | path: crates/openfx-plugin/build/
49 |
50 | - name: Package Linux binaries
51 | run: |
52 | mkdir ntsc-rs-linux-standalone
53 | cp target/release/ntsc-rs-standalone ntsc-rs-linux-standalone
54 | cp target/release/ntsc-rs-cli ntsc-rs-linux-standalone
55 |
56 | - name: Archive Linux binary
57 | uses: actions/upload-artifact@v4
58 | if: ${{ github.ref_type == 'tag' }}
59 | with:
60 | name: ntsc-rs-linux-standalone
61 | path: ntsc-rs-linux-standalone
62 |
63 | build-windows:
64 | runs-on: windows-2022
65 |
66 | steps:
67 | - name: Checkout
68 | uses: actions/checkout@v4
69 | with:
70 | submodules: recursive
71 |
72 | - name: Set up workspace path
73 | run: echo "FAST_WORKSPACE=D:\workspace" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
74 |
75 | - name: Copy Git repo to D drive
76 | run: |
77 | Copy-Item -Path "${{ github.workspace }}" -Destination "${{ env.FAST_WORKSPACE }}" -Recurse
78 |
79 | # Put the Chocolatey temp directory in a place where we can use the cache action to save and restore it.
80 | - name: Set Chocolatey temp directory
81 | run: |
82 | choco config set cacheLocation --value "D:\chocolatey_cache"
83 | echo "CHOCO_TEMP=D:\chocolatey_cache" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
84 |
85 | - name: Get current GStreamer package version
86 | run: echo "GST_PACKAGE_VERSION=$(choco info -y --limit-output gstreamer)" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
87 |
88 | - name: Restore Chocolatey cache
89 | id: choco-cache-restore
90 | uses: actions/cache/restore@v4
91 | with:
92 | path: ${{ env.CHOCO_TEMP }}
93 | key: choco-${{ github.job }}-${{ env.GST_PACKAGE_VERSION }}
94 |
95 | - name: Install gstreamer
96 | # Some things to note:
97 | # - GStreamer adds some environment variables, which we need to pick up.
98 | # - GSTREAMER_1_0_ROOT_MSVC_X86_64 cannot be hardcoded because it can be installed on different drive letters,
99 | # seemingly chosen at random.
100 | # - We need to export said path to the environment variables so that later steps can use it.
101 | run: |
102 | choco install -y gstreamer gstreamer-devel
103 | Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
104 | refreshenv
105 | echo "$($Env:GSTREAMER_1_0_ROOT_MSVC_X86_64)bin"
106 | echo "$($Env:GSTREAMER_1_0_ROOT_MSVC_X86_64)bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
107 | echo "GSTREAMER_1_0_ROOT_MSVC_X86_64=$Env:GSTREAMER_1_0_ROOT_MSVC_X86_64" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
108 |
109 | - name: Save Chocolatey cache
110 | id: choco-cache-save
111 | uses: actions/cache/save@v4
112 | with:
113 | path: ${{ env.CHOCO_TEMP }}
114 | key: choco-${{ github.job }}-${{ env.GST_PACKAGE_VERSION }}
115 |
116 | - uses: Swatinem/rust-cache@v2
117 | with:
118 | workspaces: ${{ env.FAST_WORKSPACE }}
119 |
120 | - name: Build GUI
121 | run: cargo build --release -p gui
122 | working-directory: ${{ env.FAST_WORKSPACE }}
123 |
124 | - name: Build OpenFX plugin
125 | run: cargo xtask build-ofx-plugin --release
126 | working-directory: ${{ env.FAST_WORKSPACE }}
127 |
128 | - name: Build After Effects plugin
129 | run: |
130 | cargo build --release -p ae-plugin
131 | cp target\release\ae_plugin.dll .\ntsc-rs-ae.aex
132 | working-directory: ${{ env.FAST_WORKSPACE }}
133 |
134 | - name: Package OpenFX plugin
135 | run: cargo xtask build-ofx-plugin --release
136 | working-directory: ${{ env.FAST_WORKSPACE }}
137 |
138 | - name: Archive Windows OpenFX plugin
139 | uses: actions/upload-artifact@v4
140 | if: ${{ github.ref_type == 'tag' }}
141 | with:
142 | name: ntsc-rs-windows-openfx
143 | path: ${{ env.FAST_WORKSPACE }}/crates/openfx-plugin/build/
144 |
145 | - name: Package Windows binary
146 | if: ${{ github.ref_type == 'tag' }}
147 | # Some things to note:
148 | # - Robocopy has a non-zero exit code even when successful. We therefore clear it to 0 so that Actions doesn't
149 | # fail.
150 | run: |
151 | mkdir ntsc-rs-windows-standalone
152 | cd ntsc-rs-windows-standalone
153 | robocopy $Env:GSTREAMER_1_0_ROOT_MSVC_X86_64 .\ *.dll /s /copy:DT; if ($lastexitcode -lt 8) { $global:LASTEXITCODE = $null }
154 | robocopy $Env:GSTREAMER_1_0_ROOT_MSVC_X86_64\share\licenses .\licenses /s /copy:DT; if ($lastexitcode -lt 8) { $global:LASTEXITCODE = $null }
155 | cp ..\target\release\ntsc-rs-standalone.exe .\bin\
156 | cp ..\target\release\ntsc-rs-cli.exe .\bin\
157 | cp ..\target\release\ntsc-rs-launcher.exe .\
158 | working-directory: ${{ env.FAST_WORKSPACE }}
159 |
160 | - name: Archive Windows binary
161 | uses: actions/upload-artifact@v4
162 | if: ${{ github.ref_type == 'tag' }}
163 | with:
164 | name: ntsc-rs-windows-standalone
165 | path: ${{ env.FAST_WORKSPACE }}/ntsc-rs-windows-standalone
166 |
167 | - name: Archive Windows After Effects plugin
168 | uses: actions/upload-artifact@v4
169 | if: ${{ github.ref_type == 'tag' }}
170 | with:
171 | name: ntsc-rs-windows-afterfx
172 | path: ${{ env.FAST_WORKSPACE }}/ntsc-rs-ae.aex
173 |
174 | build-macos:
175 | runs-on: macos-14
176 |
177 | steps:
178 | - name: Checkout
179 | uses: actions/checkout@v4
180 | with:
181 | submodules: recursive
182 |
183 | - name: Set deployment target
184 | run: echo 'MACOSX_DEPLOYMENT_TARGET=10.12' >> $GITHUB_ENV
185 |
186 | - name: Add x86_64 target
187 | run: |
188 | rustup target add x86_64-apple-darwin
189 |
190 | - name: Install packages
191 | run: |
192 | brew install --cask gstreamer-runtime
193 | brew install --cask gstreamer-development
194 |
195 | - name: Setup GStreamer devel
196 | run: |
197 | echo "/Library/Frameworks/GStreamer.framework/Versions/1.0/bin" >> $GITHUB_PATH
198 | echo 'PKG_CONFIG_PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/lib/pkgconfig"' >> $GITHUB_ENV
199 |
200 | - uses: Swatinem/rust-cache@v2
201 |
202 | - name: Build standalone app
203 | run: cargo xtask macos-bundle --release --destdir=build/ntsc-rs-standalone
204 |
205 | - name: Build OpenFX plugin
206 | run: cargo xtask build-ofx-plugin --macos-universal --release --destdir=build/ntsc-rs-openfx
207 |
208 | - name: Build After Effects plugin
209 | run: cargo xtask macos-ae-plugin --macos-universal --release --destdir=build/ntsc-rs-afterfx
210 |
211 | - name: Create .pkg installers for bundles
212 | if: ${{ github.ref_type == 'tag' }}
213 | # Using the "latest" compression setting is slower (50 seconds vs 25ish) but results in a smaller file
214 | # (around 120MB vs around 180MB).
215 | run: |
216 | pkgbuild --install-location /Applications --component build/ntsc-rs-standalone/ntsc-rs.app --min-os-version $MACOSX_DEPLOYMENT_TARGET --compression latest build/ntsc-rs-macos-standalone.pkg
217 | pkgbuild --install-location /Library/OFX/Plugins --component build/ntsc-rs-openfx/NtscRs.ofx.bundle --min-os-version $MACOSX_DEPLOYMENT_TARGET --compression latest build/ntsc-rs-macos-openfx.pkg
218 | pkgbuild --install-location "/Library/Application Support/Adobe/Common/Plug-ins/7.0/MediaCore" --component build/ntsc-rs-afterfx/ntsc-rs.plugin --min-os-version $MACOSX_DEPLOYMENT_TARGET --scripts assets/install_scripts --compression latest build/ntsc-rs-macos-afterfx.pkg
219 |
220 | - name: Archive .pkg installers
221 | uses: actions/upload-artifact@v4
222 | if: ${{ github.ref_type == 'tag' }}
223 | with:
224 | name: ntsc-rs-macos
225 | path: build/ntsc-rs-*.pkg
226 |
227 | # TODO: sign bundles
228 |
229 | release:
230 | runs-on: ubuntu-latest
231 | permissions:
232 | contents: write
233 | needs:
234 | - build-windows
235 | - build-macos
236 | - build-linux
237 | if: ${{ github.ref_type == 'tag' }}
238 |
239 | steps:
240 | - name: Checkout
241 | uses: actions/checkout@v4
242 |
243 | - name: Download artifacts
244 | uses: actions/download-artifact@v4
245 | with:
246 | path: ./artifacts
247 |
248 | - name: Zip Windows/Linux artifacts
249 | run: |
250 | shopt -s extglob
251 | for dir in ntsc-rs-@(windows|linux)*/; do zip -r "${dir%/}.zip" "${dir%/}"; done
252 | working-directory: ./artifacts
253 |
254 | - name: Display structure of downloaded files
255 | run: ls -l
256 | working-directory: ./artifacts
257 |
258 | - name: Create release
259 | uses: ncipollo/release-action@v1
260 | with:
261 | artifacts: "./artifacts/ntsc-rs-*.zip,./artifacts/ntsc-rs-macos/ntsc-rs-*.pkg"
262 | draft: true
263 | bodyFile: ./.github/RELEASE_TEMPLATE.md
264 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | .vscode
3 | .DS_Store
4 | /build
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "crates/openfx-plugin/vendor/openfx"]
2 | path = crates/openfx-plugin/vendor/openfx
3 | url = https://github.com/AcademySoftwareFoundation/openfx
4 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [workspace]
2 | members = ["crates/*", "xtask"]
3 | resolver = "2"
4 |
5 | [workspace.lints.clippy]
6 | too_many_arguments = "allow"
7 | identity_op = "allow"
8 | new_without_default = "allow"
9 | module_inception = "allow"
10 | needless_range_loop = "allow"
11 | type_complexity = "allow"
12 | dbg_macro = "warn"
--------------------------------------------------------------------------------
/LICENSE-APACHE-2.0:
--------------------------------------------------------------------------------
1 | This license applies to all source files except those under /crates/gui.
2 |
3 |
4 | Apache License
5 | Version 2.0, January 2004
6 | http://www.apache.org/licenses/
7 |
8 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
9 |
10 | 1. Definitions.
11 |
12 | "License" shall mean the terms and conditions for use, reproduction,
13 | and distribution as defined by Sections 1 through 9 of this document.
14 |
15 | "Licensor" shall mean the copyright owner or entity authorized by
16 | the copyright owner that is granting the License.
17 |
18 | "Legal Entity" shall mean the union of the acting entity and all
19 | other entities that control, are controlled by, or are under common
20 | control with that entity. For the purposes of this definition,
21 | "control" means (i) the power, direct or indirect, to cause the
22 | direction or management of such entity, whether by contract or
23 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
24 | outstanding shares, or (iii) beneficial ownership of such entity.
25 |
26 | "You" (or "Your") shall mean an individual or Legal Entity
27 | exercising permissions granted by this License.
28 |
29 | "Source" form shall mean the preferred form for making modifications,
30 | including but not limited to software source code, documentation
31 | source, and configuration files.
32 |
33 | "Object" form shall mean any form resulting from mechanical
34 | transformation or translation of a Source form, including but
35 | not limited to compiled object code, generated documentation,
36 | and conversions to other media types.
37 |
38 | "Work" shall mean the work of authorship, whether in Source or
39 | Object form, made available under the License, as indicated by a
40 | copyright notice that is included in or attached to the work
41 | (an example is provided in the Appendix below).
42 |
43 | "Derivative Works" shall mean any work, whether in Source or Object
44 | form, that is based on (or derived from) the Work and for which the
45 | editorial revisions, annotations, elaborations, or other modifications
46 | represent, as a whole, an original work of authorship. For the purposes
47 | of this License, Derivative Works shall not include works that remain
48 | separable from, or merely link (or bind by name) to the interfaces of,
49 | the Work and Derivative Works thereof.
50 |
51 | "Contribution" shall mean any work of authorship, including
52 | the original version of the Work and any modifications or additions
53 | to that Work or Derivative Works thereof, that is intentionally
54 | submitted to Licensor for inclusion in the Work by the copyright owner
55 | or by an individual or Legal Entity authorized to submit on behalf of
56 | the copyright owner. For the purposes of this definition, "submitted"
57 | means any form of electronic, verbal, or written communication sent
58 | to the Licensor or its representatives, including but not limited to
59 | communication on electronic mailing lists, source code control systems,
60 | and issue tracking systems that are managed by, or on behalf of, the
61 | Licensor for the purpose of discussing and improving the Work, but
62 | excluding communication that is conspicuously marked or otherwise
63 | designated in writing by the copyright owner as "Not a Contribution."
64 |
65 | "Contributor" shall mean Licensor and any individual or Legal Entity
66 | on behalf of whom a Contribution has been received by Licensor and
67 | subsequently incorporated within the Work.
68 |
69 | 2. Grant of Copyright License. Subject to the terms and conditions of
70 | this License, each Contributor hereby grants to You a perpetual,
71 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
72 | copyright license to reproduce, prepare Derivative Works of,
73 | publicly display, publicly perform, sublicense, and distribute the
74 | Work and such Derivative Works in Source or Object form.
75 |
76 | 3. Grant of Patent License. Subject to the terms and conditions of
77 | this License, each Contributor hereby grants to You a perpetual,
78 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
79 | (except as stated in this section) patent license to make, have made,
80 | use, offer to sell, sell, import, and otherwise transfer the Work,
81 | where such license applies only to those patent claims licensable
82 | by such Contributor that are necessarily infringed by their
83 | Contribution(s) alone or by combination of their Contribution(s)
84 | with the Work to which such Contribution(s) was submitted. If You
85 | institute patent litigation against any entity (including a
86 | cross-claim or counterclaim in a lawsuit) alleging that the Work
87 | or a Contribution incorporated within the Work constitutes direct
88 | or contributory patent infringement, then any patent licenses
89 | granted to You under this License for that Work shall terminate
90 | as of the date such litigation is filed.
91 |
92 | 4. Redistribution. You may reproduce and distribute copies of the
93 | Work or Derivative Works thereof in any medium, with or without
94 | modifications, and in Source or Object form, provided that You
95 | meet the following conditions:
96 |
97 | (a) You must give any other recipients of the Work or
98 | Derivative Works a copy of this License; and
99 |
100 | (b) You must cause any modified files to carry prominent notices
101 | stating that You changed the files; and
102 |
103 | (c) You must retain, in the Source form of any Derivative Works
104 | that You distribute, all copyright, patent, trademark, and
105 | attribution notices from the Source form of the Work,
106 | excluding those notices that do not pertain to any part of
107 | the Derivative Works; and
108 |
109 | (d) If the Work includes a "NOTICE" text file as part of its
110 | distribution, then any Derivative Works that You distribute must
111 | include a readable copy of the attribution notices contained
112 | within such NOTICE file, excluding those notices that do not
113 | pertain to any part of the Derivative Works, in at least one
114 | of the following places: within a NOTICE text file distributed
115 | as part of the Derivative Works; within the Source form or
116 | documentation, if provided along with the Derivative Works; or,
117 | within a display generated by the Derivative Works, if and
118 | wherever such third-party notices normally appear. The contents
119 | of the NOTICE file are for informational purposes only and
120 | do not modify the License. You may add Your own attribution
121 | notices within Derivative Works that You distribute, alongside
122 | or as an addendum to the NOTICE text from the Work, provided
123 | that such additional attribution notices cannot be construed
124 | as modifying the License.
125 |
126 | You may add Your own copyright statement to Your modifications and
127 | may provide additional or different license terms and conditions
128 | for use, reproduction, or distribution of Your modifications, or
129 | for any such Derivative Works as a whole, provided Your use,
130 | reproduction, and distribution of the Work otherwise complies with
131 | the conditions stated in this License.
132 |
133 | 5. Submission of Contributions. Unless You explicitly state otherwise,
134 | any Contribution intentionally submitted for inclusion in the Work
135 | by You to the Licensor shall be under the terms and conditions of
136 | this License, without any additional terms or conditions.
137 | Notwithstanding the above, nothing herein shall supersede or modify
138 | the terms of any separate license agreement you may have executed
139 | with Licensor regarding such Contributions.
140 |
141 | 6. Trademarks. This License does not grant permission to use the trade
142 | names, trademarks, service marks, or product names of the Licensor,
143 | except as required for reasonable and customary use in describing the
144 | origin of the Work and reproducing the content of the NOTICE file.
145 |
146 | 7. Disclaimer of Warranty. Unless required by applicable law or
147 | agreed to in writing, Licensor provides the Work (and each
148 | Contributor provides its Contributions) on an "AS IS" BASIS,
149 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
150 | implied, including, without limitation, any warranties or conditions
151 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
152 | PARTICULAR PURPOSE. You are solely responsible for determining the
153 | appropriateness of using or redistributing the Work and assume any
154 | risks associated with Your exercise of permissions under this License.
155 |
156 | 8. Limitation of Liability. In no event and under no legal theory,
157 | whether in tort (including negligence), contract, or otherwise,
158 | unless required by applicable law (such as deliberate and grossly
159 | negligent acts) or agreed to in writing, shall any Contributor be
160 | liable to You for damages, including any direct, indirect, special,
161 | incidental, or consequential damages of any character arising as a
162 | result of this License or out of the use or inability to use the
163 | Work (including but not limited to damages for loss of goodwill,
164 | work stoppage, computer failure or malfunction, or any and all
165 | other commercial damages or losses), even if such Contributor
166 | has been advised of the possibility of such damages.
167 |
168 | 9. Accepting Warranty or Additional Liability. While redistributing
169 | the Work or Derivative Works thereof, You may choose to offer,
170 | and charge a fee for, acceptance of support, warranty, indemnity,
171 | or other liability obligations and/or rights consistent with this
172 | License. However, in accepting such obligations, You may act only
173 | on Your own behalf and on Your sole responsibility, not on behalf
174 | of any other Contributor, and only if You agree to indemnify,
175 | defend, and hold each Contributor harmless for any liability
176 | incurred by, or claims asserted against, such Contributor by reason
177 | of your accepting any such warranty or additional liability.
178 |
179 | END OF TERMS AND CONDITIONS
180 |
--------------------------------------------------------------------------------
/LICENSE-ISC:
--------------------------------------------------------------------------------
1 | This license applies to all source files except those under /crates/gui.
2 |
3 | Copyright © valadaptive
4 |
5 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6 |
7 | THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
8 |
--------------------------------------------------------------------------------
/LICENSE-MIT:
--------------------------------------------------------------------------------
1 | This license applies to all source files except those under /crates/gui.
2 |
3 | Copyright © valadaptive
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/MAINTAINING.md:
--------------------------------------------------------------------------------
1 | # Drafting a new release
2 |
3 | 1. Bump the version of the `gui` crate. I don't update the version numbers of some other crates, even if maybe I should. This should be done even if there are no changes to the GUI itself--it's considered the "canonical" version number that shows up on the releases page.
4 | 2. Update the third-party credits and licenses for the GUI. Instructions for this are in that crate's README.
5 | 3. If you make changes to the OpenFX plugin, After Effects plugin, or effect settings, bump those versions as well. For the AE plugin, the plugin version is taken from the PiPL in build.rs and not the Cargo.toml.
6 | 4. Commit the changes and tag them. The tag will trigger a CI build that produces artifacts.
7 | 5. Once the CI build finishes, there will be a draft release on the Releases page. You'll need to provide a summary of the changes since last version, and then you can publish the release.
8 |
9 | # Various notes
10 |
11 | - You'll need to clone with `--recurse-submodules` (or use `git submodule update --init --recursive` in the repo if you've already cloned it) in order to build the OpenFX plugin, because it imports the `openfx` repo as a submodule.
12 | - Benchmarking is done with `RAYON_NUM_THREADS=1 cargo bench --bench filter_profile`. Benchmarks with multithreading enabled are probably also a good idea.
13 | - Development of the GUI will require gstreamer to be installed. You can do so following [the gstreamer-rs instructions](https://lib.rs/crates/gstreamer), though note that the MacOS instructions are a bit outdated and you can install it with `brew` just fine now.
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | ---
11 |
12 | **ntsc-rs** is a video effect which emulates NTSC and VHS video artifacts. It can be used as an After Effects, Premiere, or OpenFX plugin, or as a standalone application.
13 |
14 | 
15 |
16 | ## Download and Install
17 |
18 | The latest version of ntsc-rs can be downloaded from [the releases page](https://github.com/valadaptive/ntsc-rs/releases).
19 |
20 | After downloading, [read the documentation for how to run it](https://ntsc.rs/docs/standalone-installation/). In particular, ntsc-rs will not work properly on Linux unless you install all of the GStreamer packages listed in the documentation.
21 |
22 | ## More information
23 |
24 | ntsc-rs is a rough Rust port of [ntscqt](https://github.com/JargeZ/ntscqt), a PyQt-based GUI for [ntsc](https://github.com/zhuker/ntsc), itself a Python port of [composite-video-simulator](https://github.com/joncampbell123/composite-video-simulator). Reimplementing the image processing in multithreaded Rust allows it to run at (mostly) real-time speeds.
25 |
26 | It's not an exact port--some processing passes have visibly different results, and some new ones have been added.
27 |
--------------------------------------------------------------------------------
/about.toml:
--------------------------------------------------------------------------------
1 | accepted = [
2 | "Apache-2.0",
3 | "Apache-2.0 WITH LLVM-exception",
4 | "MIT",
5 | "ISC",
6 | "BSD-2-Clause",
7 | "BSD-3-Clause",
8 | "BSL-1.0",
9 | "OFL-1.1",
10 | "LicenseRef-UFL-1.0",
11 | "GPL-3.0",
12 | "CDDL-1.0",
13 | "Zlib",
14 | "Unicode-DFS-2016",
15 | "Unicode-3.0",
16 | "MPL-2.0",
17 | "Ubuntu-font-1.0",
18 | ]
19 |
--------------------------------------------------------------------------------
/assets/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/valadaptive/ntsc-rs/93e533d2564d86b283ca22f119db34b538a33049/assets/icon.ico
--------------------------------------------------------------------------------
/assets/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/valadaptive/ntsc-rs/93e533d2564d86b283ca22f119db34b538a33049/assets/icon.png
--------------------------------------------------------------------------------
/assets/icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/install_scripts/postinstall:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | set -e
3 |
4 | PLUGIN_BUNDLE="$DSTROOT/ntsc-rs.plugin"
5 |
6 | if [ -d "$PLUGIN_BUNDLE" ]; then
7 | echo "Signing After Effects plugin with ad-hoc signature..."
8 | /usr/bin/codesign --force --deep --sign - "$PLUGIN_BUNDLE"
9 | echo "After Effects plugin signed successfully."
10 | else
11 | echo "After Effects plugin not found at expected location. Skipping signing."
12 | exit 1
13 | fi
14 |
15 | exit 0
16 |
--------------------------------------------------------------------------------
/assets/macos_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/valadaptive/ntsc-rs/93e533d2564d86b283ca22f119db34b538a33049/assets/macos_icon.png
--------------------------------------------------------------------------------
/assets/macos_icon_less_detail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/valadaptive/ntsc-rs/93e533d2564d86b283ca22f119db34b538a33049/assets/macos_icon_less_detail.png
--------------------------------------------------------------------------------
/crates/ae-plugin/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "ae-plugin"
3 | version = "0.1.0"
4 | edition = "2021"
5 | license = "MIT OR ISC OR Apache-2.0"
6 |
7 | [lib]
8 | crate-type = ["cdylib"]
9 |
10 | [target.'cfg(any(windows, target_os="macos"))'.dependencies]
11 | after-effects = {git = "https://github.com/virtualritz/after-effects", rev = "c70729a", features = ["catch-panics"]}
12 | premiere = {git = "https://github.com/virtualritz/after-effects", rev = "c70729a"}
13 | ntscrs = { path = "../ntscrs" }
14 |
15 | [target.'cfg(any(windows, target_os="macos"))'.build-dependencies]
16 | pipl = {git = "https://github.com/virtualritz/after-effects", rev = "c70729a"}
17 |
18 | [dependencies]
19 | raw-window-handle = "0.6.2"
20 | rfd = "0.15.3"
21 |
22 | [lints]
23 | workspace = true
24 |
--------------------------------------------------------------------------------
/crates/ae-plugin/README.md:
--------------------------------------------------------------------------------
1 | # ntsc-rs After Effects plugin
2 |
3 | ntsc-rs can be used from After Effects and Premiere! When built, the plugin can be found under the "Stylize" category.
4 |
5 | ## Building the plugin
6 |
7 | See [the documentation on the ntsc-rs website](https://ntsc.rs/docs/building-from-source/) for up-to-date information.
8 |
--------------------------------------------------------------------------------
/crates/ae-plugin/build.rs:
--------------------------------------------------------------------------------
1 | #[rustfmt::skip]
2 | fn main() {
3 | #[cfg(any(windows, target_os = "macos"))]
4 | {
5 | const PF_PLUG_IN_VERSION: u16 = 13;
6 | const PF_PLUG_IN_SUBVERS: u16 = 28;
7 |
8 | const EFFECT_VERSION_MAJOR: u32 = 1;
9 | const EFFECT_VERSION_MINOR: u32 = 5;
10 | const EFFECT_VERSION_PATCH: u32 = 3;
11 | use pipl::*;
12 | pipl::plugin_build(vec![
13 | Property::Kind(PIPLType::AEEffect),
14 | Property::Name("NTSC-rs"),
15 | Property::Category("Stylize"),
16 |
17 | #[cfg(target_os = "windows")]
18 | Property::CodeWin64X86("EffectMain"),
19 | #[cfg(target_os = "macos")]
20 | Property::CodeMacIntel64("EffectMain"),
21 | #[cfg(target_os = "macos")]
22 | Property::CodeMacARM64("EffectMain"),
23 |
24 | Property::AE_PiPL_Version { major: 2, minor: 0 },
25 | Property::AE_Effect_Spec_Version { major: PF_PLUG_IN_VERSION, minor: PF_PLUG_IN_SUBVERS },
26 | Property::AE_Effect_Version {
27 | version: EFFECT_VERSION_MAJOR,
28 | subversion: EFFECT_VERSION_MINOR,
29 | bugversion: EFFECT_VERSION_PATCH,
30 | stage: Stage::Develop,
31 | build: 1,
32 | },
33 | Property::AE_Effect_Info_Flags(0),
34 | Property::AE_Effect_Global_OutFlags(
35 | OutFlags::NonParamVary |
36 | OutFlags::DeepColorAware |
37 | OutFlags::SendUpdateParamsUI
38 | ),
39 | Property::AE_Effect_Global_OutFlags_2(
40 | OutFlags2::ParamGroupStartCollapsedFlag |
41 | OutFlags2::SupportsSmartRender |
42 | OutFlags2::FloatColorAware |
43 | OutFlags2::RevealsZeroAlpha |
44 | OutFlags2::SupportsThreadedRendering |
45 | OutFlags2::SupportsGetFlattenedSequenceData
46 | ),
47 | Property::AE_Effect_Match_Name("ntsc-rs"),
48 | Property::AE_Reserved_Info(8),
49 | Property::AE_Effect_Support_URL("https://ntsc.rs/docs/after-effects-plugin/"),
50 | ]);
51 | println!("cargo:rustc-env=EFFECT_VERSION_MAJOR={EFFECT_VERSION_MAJOR}");
52 | println!("cargo:rustc-env=EFFECT_VERSION_MINOR={EFFECT_VERSION_MINOR}");
53 | println!("cargo:rustc-env=EFFECT_VERSION_PATCH={EFFECT_VERSION_PATCH}");
54 | println!("cargo:rustc-cfg=with_premiere");
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/crates/ae-plugin/src/handle.rs:
--------------------------------------------------------------------------------
1 | use core::slice;
2 | use std::{
3 | borrow::{Borrow, BorrowMut},
4 | marker::PhantomData,
5 | mem::{MaybeUninit, transmute},
6 | ptr::NonNull,
7 | };
8 |
9 | use after_effects::{Error, suites};
10 |
11 | #[cfg(not(target_os = "macos"))]
12 | type HandleInner = *mut std::os::raw::c_void;
13 | #[cfg(target_os = "macos")]
14 | type HandleInner = *mut std::os::raw::c_char;
15 |
16 | pub struct SliceHandle {
17 | handle: NonNull,
18 | _ty: PhantomData,
19 | len: usize,
20 | suite: suites::Handle,
21 | }
22 |
23 | impl SliceHandle {
24 | pub fn new_uninit(len: usize) -> Result>, Error> {
25 | let handle_suite = suites::Handle::new()?;
26 | let handle = NonNull::new(handle_suite.new_handle((len * std::mem::size_of::()) as u64))
27 | .ok_or(Error::OutOfMemory)?;
28 |
29 | Ok(SliceHandle {
30 | handle: handle as _,
31 | _ty: PhantomData,
32 | len,
33 | suite: handle_suite,
34 | })
35 | }
36 |
37 | pub fn lock(&mut self) -> Result, Error> {
38 | let ptr = self.suite.lock_handle(self.handle.as_ptr());
39 | let data = NonNull::new(ptr as *mut T).ok_or(Error::BadCallbackParameter)?;
40 |
41 | Ok(LockedHandle { data, parent: self })
42 | }
43 | }
44 | impl Drop for SliceHandle {
45 | fn drop(&mut self) {
46 | self.suite.dispose_handle(self.handle.as_ptr());
47 | }
48 | }
49 |
50 | impl SliceHandle {
51 | pub fn new(len: usize, value: T) -> Result {
52 | let mut handle = Self::new_uninit(len)?;
53 |
54 | {
55 | let mut locked = handle.lock()?;
56 | let data: &mut [MaybeUninit] = locked.borrow_mut();
57 | for i in data.iter_mut() {
58 | i.write(value);
59 | }
60 | }
61 |
62 | Ok(unsafe { transmute::>, SliceHandle>(handle) })
63 | }
64 | }
65 |
66 | pub struct LockedHandle<'a, T> {
67 | data: NonNull,
68 | parent: &'a mut SliceHandle,
69 | }
70 |
71 | impl Borrow<[T]> for LockedHandle<'_, T> {
72 | fn borrow(&self) -> &[T] {
73 | unsafe { slice::from_raw_parts(self.data.as_ptr(), self.parent.len) }
74 | }
75 | }
76 |
77 | impl BorrowMut<[T]> for LockedHandle<'_, T> {
78 | fn borrow_mut(&mut self) -> &mut [T] {
79 | unsafe { slice::from_raw_parts_mut(self.data.as_ptr(), self.parent.len) }
80 | }
81 | }
82 |
83 | impl Drop for LockedHandle<'_, T> {
84 | fn drop(&mut self) {
85 | self.parent.suite.unlock_handle(self.parent.handle.as_ptr());
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/crates/ae-plugin/src/window_handle.rs:
--------------------------------------------------------------------------------
1 | use raw_window_handle::{
2 | DisplayHandle, HandleError, HasDisplayHandle, HasWindowHandle, RawWindowHandle,
3 | Win32WindowHandle, WindowHandle,
4 | };
5 |
6 | pub struct WindowAndDisplayHandle {
7 | raw_handle: Win32WindowHandle,
8 | }
9 |
10 | impl WindowAndDisplayHandle {
11 | /// Safety: The window handle must be valid for however long you intend to use it for
12 | pub unsafe fn new(raw_handle: Win32WindowHandle) -> Self {
13 | Self { raw_handle }
14 | }
15 | }
16 |
17 | impl HasWindowHandle for WindowAndDisplayHandle {
18 | fn window_handle(&self) -> Result, HandleError> {
19 | Ok(unsafe { WindowHandle::borrow_raw(RawWindowHandle::Win32(self.raw_handle)) })
20 | }
21 | }
22 |
23 | impl HasDisplayHandle for WindowAndDisplayHandle {
24 | fn display_handle(&self) -> Result, HandleError> {
25 | Ok(DisplayHandle::windows())
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/crates/gui/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "gui"
3 | version = "0.9.3"
4 | edition = "2024"
5 | default-run = "ntsc-rs-standalone"
6 | license = "GPL-3.0"
7 | repository = "https://github.com/valadaptive/ntsc-rs/tree/main/crates/gui"
8 |
9 | [dependencies]
10 | ntscrs = { path = "../ntscrs" }
11 | eframe = { version = "0.31.1", features = ["persistence", "x11", "wayland"] }
12 | env_logger = "0.11.3"
13 | fontique = { git = "https://github.com/valadaptive/parley", rev = "a3b6cee" }
14 | snafu = "0.8.3"
15 | logos = "0.15"
16 | gstreamer = {version = "0.23", features = ["serde"]}
17 | gstreamer-base = "0.23"
18 | gstreamer-video = "0.23"
19 | gstreamer-pbutils = "0.23"
20 | gst-plugin-webp = { version = "0.13.4", features = ["static"] }
21 | futures-lite = "2.3.0"
22 | async-executor = "1.12.0"
23 | log = "0.4.20"
24 | rfd = { version = "0.15.3", default-features = false, features = ["xdg-portal", "async-std"] }
25 | rand = "0.9.0"
26 | tinyjson = "2.5.1"
27 | open = "5.1.4"
28 | serde = "1.0"
29 | trash = "5.0.0"
30 | blocking = "1.6.1"
31 | clap = { version = "4.5.17", features = ["cargo", "string"] }
32 | color-eyre = "0.6.3"
33 | console = "0.15.8"
34 |
35 | [build-dependencies]
36 | embed-resource = "3.0.1"
37 |
38 | [[bin]]
39 | name = "ntsc-rs-standalone"
40 |
41 | [[bin]]
42 | name = "ntsc-rs-launcher"
43 |
44 | [[bin]]
45 | name = "ntsc-rs-cli"
46 |
47 | [lints]
48 | workspace = true
49 |
--------------------------------------------------------------------------------
/crates/gui/README.md:
--------------------------------------------------------------------------------
1 | # ntsc-rs standalone GUI
2 |
3 | ntsc-rs can be used as a standalone GUI application. It uses gstreamer for media encoding, decoding, and playback.
4 |
5 | ## Building
6 |
7 | See [the documentation on the ntsc-rs website](https://ntsc.rs/docs/building-from-source/) for up-to-date information.
8 |
9 | ## Updating third-party license credits
10 |
11 | After installing or updating Cargo dependencies, you'll need to regenerate the list of third-party licenses using [cargo-about](https://github.com/EmbarkStudios/cargo-about):
12 |
13 | ```bash
14 | $ cargo about generate --format=json -o about.json
15 | ```
16 |
17 | when inside the `gui` crate folder.
18 |
19 | If you get a "failed to satisfy license requirements" error, you'll need to add the failing third-party crate's license identifier to [`about.toml`](../../about.toml).
--------------------------------------------------------------------------------
/crates/gui/build.rs:
--------------------------------------------------------------------------------
1 | use std::env;
2 | extern crate embed_resource;
3 |
4 | fn main() {
5 | if env::var_os("CARGO_CFG_WINDOWS").is_some() {
6 | embed_resource::compile("icon.rc", embed_resource::NONE)
7 | .manifest_required()
8 | .unwrap();
9 | }
10 |
11 | if env::var("CARGO_CFG_TARGET_OS").is_ok_and(|os| os == "macos") {
12 | println!("cargo:rustc-link-arg=-headerpad_max_install_names");
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/crates/gui/icon.rc:
--------------------------------------------------------------------------------
1 | ntscrs_icon ICON "..\\..\\assets\\icon.ico"
--------------------------------------------------------------------------------
/crates/gui/src/app/app_state.rs:
--------------------------------------------------------------------------------
1 | use std::thread::JoinHandle;
2 |
3 | use eframe::egui::{Rect, pos2};
4 | use serde::{Deserialize, Serialize};
5 | use snafu::ResultExt;
6 |
7 | use crate::gst_utils::{gstreamer_error::GstreamerError, ntsc_pipeline::VideoScale};
8 |
9 | use super::error::{ApplicationError, GstreamerInitSnafu};
10 |
11 | #[derive(Debug)]
12 | pub struct VideoZoom {
13 | pub scale: f64,
14 | pub fit: bool,
15 | }
16 |
17 | #[derive(Debug, Serialize, Deserialize)]
18 | pub struct VideoScaleState {
19 | pub scale: VideoScale,
20 | pub enabled: bool,
21 | }
22 |
23 | impl Default for VideoScaleState {
24 | fn default() -> Self {
25 | Self {
26 | scale: Default::default(),
27 | enabled: true,
28 | }
29 | }
30 | }
31 |
32 | #[derive(Debug)]
33 | pub struct AudioVolume {
34 | pub gain: f64,
35 | // If the user drags the volume slider all the way to 0, we want to keep track of what it was before they did that
36 | // so we can reset the volume to it when they click the unmute button. This prevents e.g. the user setting the
37 | // volume to 25%, dragging it down to 0%, then clicking unmute and having it reset to some really loud default
38 | // value.
39 | pub gain_pre_mute: f64,
40 | pub mute: bool,
41 | }
42 |
43 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
44 | pub enum EffectPreviewMode {
45 | #[default]
46 | Enabled,
47 | Disabled,
48 | SplitScreen,
49 | }
50 |
51 | #[derive(Debug)]
52 | pub struct EffectPreviewSettings {
53 | pub mode: EffectPreviewMode,
54 | pub preview_rect: Rect,
55 | }
56 |
57 | impl Default for EffectPreviewSettings {
58 | fn default() -> Self {
59 | Self {
60 | mode: Default::default(),
61 | preview_rect: Rect::from_min_max(pos2(0.0, 0.0), pos2(0.5, 1.0)),
62 | }
63 | }
64 | }
65 |
66 | impl Default for AudioVolume {
67 | fn default() -> Self {
68 | Self {
69 | gain: 1.0,
70 | gain_pre_mute: 1.0,
71 | mute: false,
72 | }
73 | }
74 | }
75 |
76 | #[derive(Default, PartialEq, Eq)]
77 | pub enum LeftPanelState {
78 | #[default]
79 | EffectSettings,
80 | RenderSettings,
81 | }
82 |
83 | /// Used for the loading screen (and error screen if GStreamer fails to initialize). We initialize GStreamer on its own
84 | /// thread, and return the result via a JoinHandle.
85 | #[derive(Debug)]
86 | pub enum GstreamerInitState {
87 | Initializing(Option>>),
88 | Initialized(Result<(), ApplicationError>),
89 | }
90 |
91 | impl GstreamerInitState {
92 | pub fn check(&mut self) -> &mut Self {
93 | if let Self::Initializing(handle) = self {
94 | if handle.as_ref().is_some_and(|h| h.is_finished()) {
95 | // In order to be able to "move" the error between enum variants, we need to be able to mem::take the
96 | // join handle.
97 | let res = handle
98 | .take()
99 | .unwrap()
100 | .join()
101 | .unwrap()
102 | .context(GstreamerInitSnafu);
103 | *self = Self::Initialized(res);
104 | }
105 | }
106 |
107 | self
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/crates/gui/src/app/dnd_overlay.rs:
--------------------------------------------------------------------------------
1 | use eframe::egui::{self, DroppedFile};
2 |
3 | pub trait UiDndExt {
4 | fn show_dnd_overlay(&mut self, text: impl Into) -> Option>;
5 | }
6 |
7 | impl UiDndExt for egui::Ui {
8 | fn show_dnd_overlay(&mut self, text: impl Into) -> Option> {
9 | let max_rect = self.max_rect();
10 |
11 | let pointer_in_drop_area = self.ctx().input(|input| {
12 | input
13 | .pointer
14 | .latest_pos()
15 | .is_some_and(|p| max_rect.contains(p))
16 | });
17 |
18 | if pointer_in_drop_area {
19 | let files = self.ctx().take_dropped_files_last_frame();
20 | if files.is_some() {
21 | return files;
22 | }
23 | }
24 |
25 | let dragging_files = self
26 | .ctx()
27 | .input(|input| !input.raw.hovered_files.is_empty());
28 | if !dragging_files {
29 | return None;
30 | }
31 |
32 | let overlay_size = max_rect.size();
33 | let area = egui::Area::new(self.auto_id_with("dnd_overlay"))
34 | .fixed_pos(max_rect.left_top())
35 | .default_size(overlay_size);
36 | area.show(self.ctx(), |ui| {
37 | ui.allocate_ui(overlay_size, |ui| {
38 | egui::Frame::NONE
39 | .fill(ui.visuals().extreme_bg_color.gamma_multiply(0.8))
40 | .stroke(ui.style().visuals.widgets.noninteractive.bg_stroke)
41 | .show(ui, |ui| {
42 | ui.centered_and_justified(|ui| {
43 | ui.heading(text);
44 | });
45 | });
46 | });
47 | });
48 |
49 | None
50 | }
51 | }
52 |
53 | pub trait CtxDndExt {
54 | fn update_dnd_state(&self);
55 | fn take_dropped_files_last_frame(&self) -> Option>;
56 | }
57 |
58 | impl CtxDndExt for egui::Context {
59 | fn update_dnd_state(&self) {
60 | // Due to event order, dropped files may come in before the pointer position is updated. To avoid this, we need
61 | // to delay handling them by one frame.
62 | //
63 | // TODO: Remove this once winit 0.31 comes out and its DnD rework makes it into egui.
64 | let files_id = egui::Id::new("dropped_files_last_frame");
65 |
66 | let dropped_files = self.input_mut(|input| {
67 | if input.raw.dropped_files.is_empty() {
68 | None
69 | } else {
70 | Some(std::mem::take(&mut input.raw.dropped_files))
71 | }
72 | });
73 |
74 | self.data_mut(|data| {
75 | data.remove_temp::>(files_id);
76 |
77 | if let Some(dropped_files) = dropped_files {
78 | data.insert_temp(files_id, dropped_files);
79 | }
80 | });
81 | }
82 |
83 | fn take_dropped_files_last_frame(&self) -> Option> {
84 | let files_id = egui::Id::new("dropped_files_last_frame");
85 | self.data_mut(|data| data.remove_temp::>(files_id))
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/crates/gui/src/app/error.rs:
--------------------------------------------------------------------------------
1 | use ntscrs::settings::{ParseSettingsError, sval_json};
2 | use snafu::Snafu;
3 |
4 | use crate::gst_utils::{gstreamer_error::GstreamerError, ntsc_pipeline::PipelineError};
5 |
6 | #[derive(Debug, Snafu)]
7 | #[snafu(visibility(pub(crate)))]
8 | pub enum ApplicationError {
9 | #[snafu(display("Error initializing GStreamer: {source}"))]
10 | GstreamerInit { source: GstreamerError },
11 |
12 | #[snafu(display("Error loading video: {source}"))]
13 | LoadVideo { source: GstreamerError },
14 |
15 | #[snafu(display("Error creating pipeline: {source}"))]
16 | CreatePipeline { source: PipelineError },
17 |
18 | #[snafu(display("Error creating render job: {source}"))]
19 | CreateRenderJob { source: GstreamerError },
20 |
21 | #[snafu(display("Error during render job: {source}"))]
22 | RenderJobPipeline { source: GstreamerError },
23 |
24 | #[snafu(display("Error reading JSON: {source}"))]
25 | JSONRead { source: std::io::Error },
26 |
27 | #[snafu(display("Error parsing JSON: {source}"))]
28 | JSONParse {
29 | #[snafu(source(from(ParseSettingsError, Box::new)))]
30 | source: Box,
31 | },
32 |
33 | #[snafu(display("Error creating presets directory: {source}"))]
34 | CreatePresetsDirectory { source: std::io::Error },
35 |
36 | #[snafu(display("Error creating preset: {source}"))]
37 | CreatePresetFile { source: std::io::Error },
38 |
39 | #[snafu(display("Error creating preset: {source}"))]
40 | CreatePresetJSON { source: sval_json::Error },
41 |
42 | #[snafu(display("Error deleting preset: {source}"))]
43 | DeletePreset {
44 | #[snafu(source(from(trash::Error, Box::new)))]
45 | source: Box,
46 | },
47 |
48 | #[snafu(display("Error renaming preset: {source}"))]
49 | RenamePreset { source: std::io::Error },
50 |
51 | #[snafu(display("Error installing preset: {source}"))]
52 | InstallPreset { source: std::io::Error },
53 |
54 | #[snafu(display("Filesystem error: {source}"))]
55 | Fs { source: std::io::Error },
56 |
57 | #[snafu(display("Only one file at a time can be dropped here"))]
58 | DroppedMultipleFiles,
59 | }
60 |
--------------------------------------------------------------------------------
/crates/gui/src/app/executor.rs:
--------------------------------------------------------------------------------
1 | use std::{
2 | pin::Pin,
3 | sync::{Arc, Mutex, Weak},
4 | task::{Context, Poll, Wake, Waker},
5 | };
6 |
7 | use async_executor::{Executor, Task};
8 | use eframe::egui;
9 | use futures_lite::{Future, FutureExt};
10 | use gstreamer::glib::clone::Downgrade;
11 | use log::trace;
12 |
13 | use super::{AppFn, ApplessFn, NtscApp};
14 |
15 | struct AppExecutorInner {
16 | executor: Arc>,
17 | exec_future: Pin + Send>>,
18 | waker: Waker,
19 | egui_ctx: egui::Context,
20 | tasks: Vec>>,
21 | }
22 |
23 | impl AppExecutorInner {
24 | pub fn spawn(&mut self, future: impl Future