CrypticSignal/av-converter
소개
A web app to convert an audio/video file to another format. Uses ffmpeg.wasm
디자인 및 미디어측정된 스타 증가
- in 24h
- 0
- in 7 days
- +2
- in 15 days
- +2
- in 1 month
- +2
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalAV converter
Convert audio and video files right in your browser using FFmpeg and WebAssembly. Your file is not uploaded.
Try this web app at av-converter.com
Table of contents
Audio/Video Converter
Convert audio and video files in your browser. The conversion runs on your device with FFmpeg compiled to WebAssembly, so your file is not uploaded.
Audio
Convert a file, or the audio in a video, to AAC, AC3, ALAC, DTS, FLAC, MP3, Opus, Vorbis or WAV, each with its own settings (such as bitrate).
- The output contains exactly one audio track: the first, unless you pick another once the file's information has loaded (the picker appears for files with several).
- MKA, and outputs that keep the video, can instead hold all audio tracks. MKA does so by default.
- Keeping the video copies it unchanged, into the input's own container (e.g. MP4 stays MP4) when that container can hold the chosen audio format, and into MKV otherwise. For MKV to MKV it also copies the subtitles and attachments.
Video
Choose Video instead of Audio to re-encode the video with any of the video encoders in FFmpeg's WebAssembly build (H.264, H.265, AV1, VP8, VP9, MPEG-4, Theora, ProRes, DNxHR, FFV1, GIF, animated WebP and PNG, and many older, uncompressed and image codecs).
- Containers and quality: each encoder offers only the containers it can be written to, and has its own quality settings where it has any.
- Audio: it can be re-encoded to any audio format the container can hold, with that format's settings (AAC by default where the container allows it), left as it is (the default for MKV and NUT, which hold almost any audio format), or removed. Audio formats that hold at most two channels, such as MP3, always downmix audio with more to stereo.
- Size and frame rate: every encoder can change the frame rate, width and height (all "Original" by default; with only the width or the height set, the other keeps the aspect ratio). Encoders that only allow certain frame sizes (such as DV, H.261 and H.263) resize the video to fit.
- Trimming: to convert only part of the video, drag the start and end handles under the video preview. Browsers can't preview every format FFmpeg reads, but the handles still work then.
AV1 can be encoded with libaom or SVT-AV1, and AV1 input is decoded with dav1d (the FFmpeg cores in vendor/ffmpeg-core include all three; see its README). libaom is the first choice, because it was faster in our benchmarks in the browser (the numbers are in the FFmpeg core README) and also works without multi-threading. SVT-AV1 and H.265 need a browser that allows multi-threading (the page must be cross-origin isolated).
Manual command
Tick Write my own FFmpeg command to type everything after ffmpeg -i <input> yourself. Manual command mode uses your own stream mapping.
File size and memory
There's no limit on the input file's size: FFmpeg reads it directly from disk.
The converted file is written to disk too. FFmpeg writes it to the browser's private storage for the site (the origin private file system, a folder only this site can read, which needs no permission), and the browser downloads it from there. Normally it's never held in memory (see the fallback below), so its size is limited by disk space rather than by memory. The disk needs room for the file twice over while it downloads, for the copy in the private storage and the downloaded one, and the browser has to allow the site that much storage (roughly 60% of the disk's size in Chrome, Edge and Safari, and 10% of it up to 10 GiB in Firefox; less in private windows).
The copy in the private storage is deleted one second after the page starts the download (the page can't tell when the browser actually starts it). In Chromium on Linux the download survives this: the browser has opened the file by then and carries on reading it, and the wait needed was only a few milliseconds (of 20 downloads each, all failed with no wait, 1 failed after 2 ms, and none failed from 5 ms up, even with every CPU core busy, or for 2 GiB files). Other browsers and operating systems haven't been tested. A browser set to ask where to save each download isn't supported: the download may fail if the copy is deleted while it waits for an answer. If the tab is closed within that second, or during a conversion, the copy is deleted the next time the site is opened. Because the copy is gone, the page can't offer a link to download it again: if the browser blocks the automatic download, the conversion has to be run again. (A file held in memory, as below, does get the link.)
Where the browser can't keep the file on disk (some private windows, older browsers), FFmpeg holds it in memory instead, as it does if the site's storage fills up part-way through a conversion, which is then tried again in memory. A very large output, such as a long video with "Keep the video", can then make the browser run out of memory. The page warns about this beforehand when the file is large for the device's memory (in browsers that report it) and the browser reports less storage than the file needs (Chrome never reports more than 10 GiB of remaining storage, however much it allows, and Firefox limits a site to 10 GiB, so a reading of 10 GiB is taken to mean "plenty" and doesn't trigger the warning).
If the browser kills the tab for lack of memory during a conversion, the page says so the next time it loads.
Peak increase in Chromium's memory use during a conversion, in headless Chromium on a machine with 15 GiB of memory (scripts/measure-memory.ts; the first three rows are the median of three runs, the 1 and 1.5 GiB rows are one run each, and the 2, 4 and 6 GiB rows are the latest of two or three runs). "On disk" is how the converter normally works. "In memory" is the fallback described above, measured with the private storage switched off, so it only applies to a browser that can't keep the file on disk:
| Conversion | Output | On disk (the default) | In memory (the fallback) |
|---|---|---|---|
| WAV to WAV | 300 MiB | 0.15 GiB | 0.98 GiB |
| WAV to WAV | 600 MiB | 0.16 GiB | 2.08 GiB |
| MP4 to AAC, keeping the video | 600 MiB | 0.36 GiB | 2.38 GiB |
| MP4 to AAC, keeping the video | 1 GiB | 0.55 GiB | 4.96 GiB |
| MP4 to AAC, keeping the video | 1.5 GiB | 1.02 GiB | 5.85 GiB |
| MP4 to AAC, keeping the video | 2 GiB | 1.12 GiB | ran out of memory |
| MP4 to AAC, keeping the video | 4 GiB | 1.16 GiB | ran out of memory |
| MP4 to AAC, keeping the video | 6 GiB | 1.13 GiB | ran out of memory |
The "ran out of memory" results are therefore only a limit for a browser that has to use the fallback. On disk, memory use stops growing with the file's size at about 1.1 to 1.2 GiB. 6 GiB was the largest output tried, not a limit.
Run locally
With Docker
docker compose -f docker/dev/docker-compose.yml up --build --watch
Open http://localhost:3000. Watch mode syncs frontend changes and restarts or rebuilds services when needed. Downloader rebuilds interrupt active downloads and recordings. Restart the command after changing the Compose configuration.
Without Docker
Install Python 3.12+, Node.js 26+, Yarn, and FFmpeg, with the executables on your PATH. Start the backend:
python -m pip install -r downloader/requirements.txt
python downloader/server.py
In another terminal, start the frontend:
yarn install
yarn dev
Open http://localhost:3000. Vite proxies download requests to http://127.0.0.1:8000; set DOWNLOADER_URL to use another backend. Local downloads need the Vite development server, not the static preview server.
Video Downloader
A separate page at /download that downloads a video or its audio from a link, using yt-dlp on the server. Unlike the converter, it runs on the server and is protected by a password. It isn't linked from the site.
To use it: open /download, enter the password and the video's URL, choose what to download (best quality, audio only, MP4 or MP3), and click Download. Keep the page open until the file is ready.
YouTube cookies
If YouTube asks yt-dlp to sign in, export your YouTube cookies in Netscape format and save them as cookies.txt in the project root. Without the file, downloads are anonymous. Cookies are login credentials, so never commit them, and expect to replace them when they expire.
Password
Every download needs the downloader's password.
How it works: the password's SHA-256 hash is kept on the server, in downloader-password.env in the project root, and never committed. Docker Compose passes it to the downloader as the DOWNLOADER_PASSWORD_SHA256 environment variable. The download page sends the password with each download request, and the downloader hashes it and compares it with the saved hash. If no hash is set, every download is refused.
To set or change the password, run this on the server, from the project root:
python3 set_password.py
It asks for the new password, saves its hash, and restarts the downloader if it's running, so the new password applies straight away. setup.sh runs it the first time, and deploy.py stops if no password has been set.
Locally, run python3 set_password.py too. The Docker setup picks the file up automatically; without Docker, start the backend with env $(cat downloader-password.env) python downloader/server.py.
Limits
At most three downloads run at once (set MAX_CONCURRENT_DOWNLOADS to change it); further requests are refused until one finishes. In production, Nginx also lets each IP address start at most 10 downloads a minute (with a burst of 5), which limits password guessing. Downloads have no file-size limit, and live recordings have no duration limit. A download stops if free disk space drops below 1 GiB.
A completed download is kept for up to ten minutes. Its link can be used once; the file is removed when that transfer ends, or when the link expires.
Production
First-time setup of an Ubuntu server, from your normal account:
sudo bash setup.sh
It installs Docker and Node.js, opens ports 80 and 443, builds the site, gets a TLS certificate for the domain set at the top of setup.sh, and schedules certificate renewal (docker/prod/renew-cert.sh). The domain's DNS must already point at the server. Use sudo bash setup.sh --local for HTTP only, without a certificate.
Updates: run yarn deploy (or python3 deploy.py). It pulls the latest code, rebuilds the backend images and the website, restarts what changed and reloads Nginx. Each step is commented in deploy.py. There is no automatic rollback, and active downloads are interrupted.
Production requires cookies.txt in the project root (setup.sh creates an empty one). After replacing it, run:
docker compose -f docker/prod/docker-compose.yml up -d downloader
Tests
Run backend tests (offline; yt-dlp is never run):
python -m unittest discover -s downloader -p "test_*.py"
Run frontend tests:
yarn test
Lint the frontend with ESLint, including React's hooks rules, and type-check the scripts in scripts/:
yarn lint
Three scripts in scripts/ test or measure the converter in a real browser (Chromium, through Playwright), against the production build. CI doesn't run them:
yarn build
npx playwright install chromium # once
# Tests "Keep the video" for every container and audio format that offers it.
# Needs ffmpeg and ffprobe on your PATH.
node scripts/test-keep-video.ts
# Checks which video encoders hang on the multi-threaded core without -threads 4.
node scripts/test-threads.ts path/to/video.mp4
# Measures the browser's memory use while converting large files (see "File size and memory").
# Needs ffmpeg on your PATH, and Linux.
node scripts/measure-memory.ts
All three print one line per case and a summary. test-keep-video exits with 1 if any case fails; --containers mp4,avi and --formats AAC,MP3 limit what it tests. test-threads also takes --only libx264,gif, --rounds and --timeout. measure-memory takes --sizes 300,600 (in MiB), --conversions wav,keep-video, --output disk,memory and --runs. Each script's header comment lists all its options.
GitHub Actions runs both suites, the linter (which also type-checks the scripts) and the frontend build on every push to master and on pull requests.
Code layout
| Path | What it does |
|---|---|
src/formats.tsx |
One entry per output format: its label, extension, FFmpeg arguments and settings panel. |
src/videoEncoders.tsx |
One entry per video encoder: its label, the containers it can be written to, its FFmpeg arguments and settings panel. |
src/components/ |
Small shared form controls (select, slider, yes/no radio, file input), the status panel, and the video trimmer. |
src/utils/createFFmpegArgs.ts |
Builds the full FFmpeg command: which streams to include (-map), the format's arguments, and the shared options (keep the video, downmix to stereo). |
src/utils/convertFile.ts |
Runs FFmpeg (WebAssembly) in the browser and downloads the result. |
src/utils/ffmpegWorker.ts |
The worker that runs the FFmpeg core: a copy of ffmpeg.wasm's own, which can also mount a folder whose file is kept on disk. |
src/utils/diskFileSystem.ts |
The file system behind that folder: it passes FFmpeg's reads and writes to a file in the browser's private storage, so the converted file isn't held in memory. |
src/utils/outputStorage.ts |
The page's side of the private storage: where converted files go, reading one back to download it, and deleting them. |
src/pages/Homepage.tsx |
The converter page. |
src/utils/manualCommand.ts |
Checks and builds the arguments for a manual FFmpeg command. |
src/pages/DownloadPage.tsx |
The video downloader page, which streams progress from the backend. |
scripts/test-keep-video.ts |
Tests "Keep the video" for every container and audio format that offers it, in Chromium (see Tests). |
scripts/test-threads.ts |
Checks which video encoders need -threads 4 on the multi-threaded FFmpeg core, in Chromium (see Tests). |
scripts/measure-memory.ts |
Measures the browser's memory use while converting large files, with the converted file on disk and in memory, in Chromium (see Tests). |
downloader/server.py |
The yt-dlp backend. |
set_password.py |
Sets the downloader's password, saving its hash in downloader-password.env. |
docker/prod/nginx.conf, nginx-http.conf |
Nginx for HTTPS, and HTTP only (local mode and first certificate). Both include locations.conf, the site's routes, which adds the security headers in security-headers.conf and app-headers.conf. |
logging/index.ts |
Records real visitors' page visits (path, approximate city and country, time zone, device model, platform and browser; not the IP address) in Loki, viewable in Grafana at /grafana/. IP geolocation by DB-IP. |
vendor/ffmpeg-core/ |
The multi-threaded and single-threaded FFmpeg WebAssembly cores, which Vite bundles as content-hashed assets. Pages that aren't cross-origin isolated (no SharedArrayBuffer) fall back to the single-threaded core. They're built from ffmpeg.wasm's source: the npm release's Opus encoder crashes, and it can't decode or encode AV1. Its README explains why and how to rebuild them. |
vendor/ffmpeg-core/patches/ |
The patches that add AV1 support to those cores, applied to ffmpeg.wasm when they're rebuilt. See its README. |
To add an output format:
- Add its name to
Codecinsrc/formats.tsx. - Add any settings it needs to
FormatSettingsandDEFAULT_SETTINGS(prefixed with the format's name, e.g.mp3Bitrate). - Add an entry to
FORMATSwith its label, extension, FFmpegargsand settingsPanel. - Add a case to the
formatslist insrc/utils/createFFmpegArgs.test.ts, with the arguments it should produce.
To add a video encoder:
- Add an entry to
VIDEO_ENCODERSinsrc/videoEncoders.tsx, keyed by its FFmpeg name. Give it the containers it can be written to (the first is the default), its FFmpegargs, and a settingsPanelif it has any. - Add any settings it needs to
FormatSettingsandDEFAULT_SETTINGSinsrc/formats.tsx. - Check that the cores can write each container you list. The encoder has to be in the build (see
vendor/ffmpeg-core/README.md).
License
관련 프로젝트 살펴보기
불러오는 중…