Jump to content

Tool:Clip2commons

From Wikitech
Toolforge tools
clip2commons
Website https://clip2commons.toolforge.org/
Description Browser-based video uploader for Wikimedia Commons. Inspects and converts local video files in the contributor’s browser, then uploads through the Commons MediaWiki Action API.
Keywords Wikimedia Commons, video, WebCodecs, VP9, upload, browser-side conversion
Author(s) Dev Jadiya (Dev_Jadiyatalk)
Maintainer(s) Dev Jadiya (View all)
Source code https://gitlab.wikimedia.org/toolforge-repos/clip2commons
License MIT License
Issues https://phabricator.wikimedia.org/project/profile/8922/


clip2commons (also known as c2c) is a stable, Toolforge-hosted, browser-based tool for uploading video files to Wikimedia Commons. It inspects and, when necessary, converts a video in the contributor's browser, then uploads it using Wikimedia OAuth 2.0 and the Commons MediaWiki Action API.

Unlike a server-side conversion queue, clip2commons performs media processing on the contributor's device. The application is served as static frontend assets; it does not receive video files through a clip2commons application server.

clip2commons complements video2commons rather than replacing it. clip2commons works with local files selected on the device. Use video2commons when importing from a URL or when its server-side workflow better fits the task.

clip2commons and video2commons compared

The main difference is where media processing happens. clip2commons processes a selected local file in the contributor’s browser. video2commons uses a server-side task queue and can import media from URLs. The tools therefore suit different workflows.

Capabilityclip2commonsvideo2commons
Where conversion runsIn the contributor’s browser, using WebCodecs where supportedOn the server, through a queued task
Input sourceLocal files selected from the deviceLocal uploads and supported media URLs
Waiting for a conversion queueNo shared server-side conversion queue; encoding speed depends on the deviceTasks can wait for available server-side processing capacity
Browser/device requirementsRequires a compatible browser for conversion; supported pass-through files may work without encoding supportConversion is performed server-side, so local WebCodecs support is not required
Large or long mediaSubject to clip2commons’ browser, storage, duration and file-size limits listed belowMay be a better fit for media that exceeds clip2commons’ client-side limits, subject to video2commons’ own limits
URL importNot supported; choose a local fileSupported for compatible source URLs
Best fitLocal files, with processing performed on the contributor’s deviceURL imports or workflows better suited to server-side processing

Choose the tool based on the source and constraints. These tools are complementary, not interchangeable in every case. Limits and supported inputs can change, so check each tool’s live interface and documentation before starting a large upload.

Quick start

  1. Open clip2commons.
  2. Sign in using your Wikimedia account and approve the OAuth authorization request.
  3. Select one or more local video files, or add them using the file picker/drag-and-drop interface.
  4. Review the detected media information and complete the file title, description, date, licence, categories and other applicable metadata.
  5. Choose the desired output mode and resolution. Review any warnings about file size, browser capabilities, duplicate files or metadata.
  6. Start the conversion and upload. Keep the browser tab open until the upload finishes; long jobs may take time and browser storage or network conditions can affect recovery.
  7. After publication, follow the result link to review the file page and any post-upload warnings.

Commons requires an autoconfirmed account for uploads through this tool. In general, this means an account at least four days old with at least ten edits; Commons applies the actual eligibility check.

System architecture

System architecture and data flow of clip2commons
System architecture and data flow of clip2commons. The diagram is shown at a large width to keep the labels readable.

The application is a Vue 3 and TypeScript single-page application built with Vite and Wikimedia Codex. The built static assets are hosted on Toolforge. The principal processing and data boundaries are:

  • Contributor's browser: file selection, probing, metadata editing, encoding, upload orchestration and progress display.
  • Local media processing: mediabunny reads source data on demand; WebCodecs performs supported decode/encode work in a Web Worker. Conversion output is written to the browser's Origin Private File System (OPFS) when a writable output file can be created. If not, the application uses an in-memory buffer and applies a lower limit where appropriate.
  • Browser persistence: IndexedDB stores upload-resume checkpoints and related upload metadata. OPFS stores encoded output when available. OAuth state and tokens use browser storage according to the session/remember-me flow.
  • Wikimedia services: Wikimedia OAuth handles authorization; the Commons Action API handles account checks, file queries, chunk upload, finalization, captions and transcode-status queries. Optional integrations use MinT for translation suggestions and the Wikidata Action API for media statements.

The video file is sent to Wikimedia Commons as the upload; it is not uploaded to a clip2commons conversion server. Description or caption text is sent to MinT only when the contributor explicitly requests a translation suggestion. Other API requests carry the data needed for their specific operation.

Video conversion and output storage

Video processing and encoding workflow of clip2commons
Video processing and encoding workflow of clip2commons. The diagram is shown at a large width to keep the decision branches and labels readable.

Input inspection

clip2commons probes a selected file using mediabunny and requires a primary video track. It reads available container, track, codec, dimensions, duration and related metadata. A file with no primary video track is not accepted as a video input, including in audio-only extraction mode.

Output paths

  • Pass-through: when the source is in a recognized WebM/Matroska container with VP8 or VP9 video, and no effective trim or incompatible output mode is selected, the original file can be uploaded without re-encoding.
  • Video conversion: other supported video inputs are converted in the browser to WebM with VP9 video. Opus audio is retained where applicable unless video-only mode is selected. The contributor can choose the output resolution and trim the clip before conversion.
  • Audio-only extraction: for a video file that contains an audio track, the tool can discard the picture and produce Opus audio in an Ogg container. A file that has no audio track cannot use this path.

Conversion runs in a Web Worker using mediabunny and the WebCodecs APIs. Depending on the browser and device, codec operations may use hardware acceleration. Actual capability is feature-detected; browser brand/version alone does not guarantee support.

Output storage

When the browser can create and write an OPFS output file, mediabunny writes encoded output incrementally to disk-backed storage. If that output path is unavailable or cannot be used, the tool falls back to an in-memory BufferTarget. Memory-backed output is subject to a lower file-size ceiling because the completed output occupies JavaScript memory.

Upload, recovery and publication

Chunked upload and publication workflow of clip2commons
Chunked upload and publication workflow of clip2commons. The diagram is shown at a large width to make the upload, retry and recovery paths readable.

Before upload, clip2commons checks the Wikimedia account, relevant upload permission and autoconfirmed eligibility, and obtains a Commons CSRF token. It sanitizes and validates the title, checks filename availability and builds the file-page wikitext in the browser.

The upload client sends the payload to the Commons MediaWiki Action API in 5 MiB chunks. Commons stages the chunks in its upload stash. After a chunk is accepted, clip2commons advances the confirmed offset and attempts to persist the file key and offset in IndexedDB. IndexedDB persistence is best-effort; if browser storage is unavailable or fails, resumability may be reduced.

Resuming an interrupted upload

A resume requires the same bytes as the original upload and a still-valid Commons stash. For a converted file, the saved encoded output must remain available; for pass-through, the original file must be supplied again and pass the resume identity checks. A newly encoded file must not be combined with chunks from an earlier encoding. The tool checks the saved stash state before continuing. Commons stash data is temporary and may expire (typically after about six hours), so a resume is not guaranteed indefinitely.

Chunk requests use bounded retries for selected transient errors. If retries are exhausted, the tool reports the failure and may offer a resume when sufficient local and server-side state remains.

Warnings and final publication

Commons can return upload warnings during finalization. clip2commons presents these to the contributor and requires an explicit decision before retrying finalization with `ignorewarnings=1`. Confirming the warning does not require sending the already accepted chunks again.

Publication is the commit point. Once Commons reports successful finalization, the file and its description page are published. clip2commons does not automatically delete or roll back a published file if a later caption edit, Wikidata operation or transcode-status query fails. If a finalization request fails or its response is lost, the resulting server state may be ambiguous; check Commons before attempting a fresh upload to avoid creating duplicates.

Authentication, translation and post-upload integrations

OAuth authentication and post-publication workflow of clip2commons
OAuth authentication and post-publication workflow of clip2commons. The diagram is shown at a large width to keep the authentication and post-publication paths readable.

Wikimedia OAuth

Sign-in uses Wikimedia OAuth 2.0 with an authorization-code flow and PKCE. The browser stores the one-time state and verifier while authorization is in progress, validates the callback and exchanges the code for a token. clip2commons does not ask the contributor to enter their Wikimedia password into the tool. API calls use the resulting authorization token.

This is a browser application: build-time variables prefixed with `VITE_` are included in the built frontend bundle and must not be treated as server-only secrets. The OAuth configuration must match the registered Wikimedia OAuth consumer and its permitted callback URLs.

Translation suggestions

When requested, clip2commons sends description or caption text to Wikimedia's MinT service and displays the resulting suggestion for the contributor to review. Translation is optional. The contributor remains responsible for checking the suggested text before using it.

Structured captions and Wikidata

After the Commons file has been published, the tool can write structured file captions to the file's MediaInfo entity. If the contributor selects a Wikidata item, the tool can optionally add a media statement: P10 for video or P51 for audio-only output. These are separate post-publication operations. A failure in either operation does not undo the Commons upload.

Transcode status

After upload, clip2commons queries Commons for the file's transcode status and displays the reported job states. This status reflects Commons-side derivative processing, which occurs after the source file is published. Automatic polling is bounded; a manual refresh is available in the interface.

Features

  • Browser-side media probing and conversion using mediabunny and WebCodecs.
  • Pass-through upload for compatible WebM/Matroska files using VP8 or VP9 video when the selected mode and trim settings permit it.
  • Output resolution choices: 1080p, 720p, 480p or source/original resolution.
  • Trim video before upload; extract audio-only output or remove audio for video-only output.
  • Sequential batch queue of up to 50 files, with shared metadata support and the ability to add files to the queue after it has started.
  • Chunked Commons uploads, progress reporting and best-effort resumable upload state.
  • Live filename availability checking and automatic renaming when a filename is already taken.
  • Optional exact-file duplicate detection using SHA-1 for eligible files up to 100 MiB. A detected match is advisory; it is not proof that two files are semantically identical.
  • Commons category autocomplete and multilingual file captions/description fields.
  • Licence selection, including common presets and additional licence templates queried from Commons.
  • Provenance questions for own work, third-party material, public-domain material, VRT permission and AI-generated work.
  • Optional AI-generated work metadata, including engine and prompt where supplied by the contributor.
  • Optional Wikidata linking, MinT translation suggestions and post-upload transcode-status display.
  • Screen wake lock while supported long-running work is active, to reduce interruptions when a device would otherwise lock its screen.
  • Interface available in eight languages: English, Hindi, Arabic (right-to-left), French, Spanish, German, Chinese and Portuguese.
  • Keyboard accessibility and Wikimedia Codex-based interface components.

Limits and browser requirements

Limits are enforced by the application and can vary by browser capability and device. They are not the same as Commons' own server-side upload limit.

Limit or requirementCurrent behaviour
Ordinary file-size threshold1 GiB (the tool may warn and continue above this threshold)
Hard file-size ceiling2 GiB on an unrestricted device
Memory-constrained device with writable OPFS outputUp to 1 GiB
Memory-constrained device without usable OPFS outputUp to 200 MiB, because encoded output is buffered in memory
Maximum duration60 minutes
Batch queueUp to 50 files; files are processed sequentially in the browser tab
Upload chunk size5 MiB
Duplicate-check eligibilityFiles up to 100 MiB; skipped on devices classified as memory-limited
Resume availabilityRequires IndexedDB/local state, the original payload bytes and an unexpired Commons stash; stash availability is temporary (typically about six hours)

The application checks for a secure context (HTTPS), Web Workers, WebCodecs decode/encode support and VP9 encoder support for conversion. Already-compatible pass-through files may be uploaded in browsers that cannot encode, provided the required upload path is available. Current capability messages recommend a recent Chromium-based browser, Safari 26.1 or newer, or Firefox 138+ on desktop for local encoding. Feature detection in the running browser is authoritative.

On iOS and devices that report limited memory, the application applies a more conservative file-size cap. If OPFS output cannot be written, the lower memory-buffered limit applies. Encoding speed and whether the browser can finish a long job depend on the device, available memory/storage, resolution, source codec and browser implementation.

Privacy and security

  • The video is processed in the contributor's browser and uploaded to Wikimedia Commons; it is not routed through a clip2commons application server.
  • Wikimedia OAuth is used for authorization. The tool does not receive the user's Wikimedia password.
  • The app's OAuth state and token persistence is handled in browser storage; users should only sign in on the official HTTPS tool URL.
  • Description/caption text is sent to MinT only when the contributor requests a translation suggestion.
  • Commons and Wikidata API requests send the information required for the chosen operation, such as upload bytes, file metadata, captions or a selected Wikidata item.
  • Because this is a client-side app, build-time `VITE_` values are part of the public bundle. They must not contain credentials that depend on being secret from browser users. The OAuth configuration and registered consumer permissions should be reviewed when changing deployment settings.

Troubleshooting

The tool says the browser cannot encode
Use a current browser that passes the tool's WebCodecs and VP9 capability checks. If the file is already in a supported pass-through format, upload may still be possible without re-encoding. Otherwise, use a compatible browser or consider video2commons.
The file is too large
Check the limit shown by the tool. The effective ceiling can be lower on memory-constrained devices, particularly when output must be buffered in memory. Try a desktop browser with writable OPFS output, or trim/reduce the video before uploading. video2commons may be a better fit for files beyond clip2commons' limits.
The upload was interrupted
Reload the tool and follow the resume prompt if it is offered. Resume requires the same original payload and a still-valid Commons stash. If the stash has expired or the encoded output is unavailable, a fresh upload may be necessary.
Commons reports an upload warning
Read the warning before deciding whether to continue. clip2commons asks for explicit confirmation before retrying finalization with warnings ignored. Do not confirm a warning unless you understand and accept it.
The file is published but captions or Wikidata are missing
These operations occur after publication and can fail independently. Review the file page and correct the structured data separately if needed. The original upload is not automatically rolled back.
A finalization request failed or timed out
The request may have reached Commons even if the browser did not receive a usable response. Check Commons for the file before starting another upload.
Report a bug or request a feature
Open the clip2commons Phabricator project and create a task. Include the browser and operating system, approximate source size/duration, selected output mode, the exact error, and a Commons file URL if publication occurred. Do not post OAuth tokens or other credentials.

Development history and contributors

Important development and refinement of clip2commons took place during the Indic Wikimedia Hackathon Hyderabad 2026, held from 26 to 28 June 2026. The hackathon provided dedicated time for collaborative implementation, testing and improving the tool. Contributors involved in this work included:

  • Adhil Ameen
  • Anushka Patel
  • Kavaljeet Singh
  • Reeti Singh

The project continued to be developed after the event. See the source repository for the current code and contribution history.

Development

Source and dependencies

  • Source repository: clip2commons on GitLab
  • Issue tracker: Phabricator project #8922
  • License: MIT
  • Frontend: Vue 3, TypeScript and Vite
  • UI and internationalisation: Wikimedia Codex and vue-i18n
  • Media processing: mediabunny and browser WebCodecs
  • Browser persistence: IndexedDB and OPFS where supported

Run locally

git clone https://gitlab.wikimedia.org/toolforge-repos/clip2commons.git
cd clip2commons
npm install
npm run dev

For OAuth sign-in during local development, register/configure a Wikimedia OAuth consumer with the appropriate local callback URL and set the required `VITE_OAUTH_CLIENT_ID` and `VITE_OAUTH_REDIRECT_URI` values in a local environment file. Set `VITE_OAUTH_CLIENT_SECRET` only when required by the registered consumer configuration; remember that any `VITE_` value is bundled into the client. Do not put personal access tokens or unrelated secrets in the frontend configuration.

Tests and build

npm test
npx vue-tsc --noEmit
npm run build

The automated tests cover reusable modules such as wikitext/licence generation, MediaWiki API wrappers, chunked-upload offsets/retries/resume/warning handling, OAuth PKCE, browser capability detection, IndexedDB resume storage, translation-bundle integrity and transcode-status handling. The encoder worker, mediabunny demuxing and Vue components require browser-level testing and are not fully covered by the unit suite; consult `tests/README.md` for the current coverage and known behavioural gaps.

Deployment

clip2commons is built as a static frontend and served on Toolforge. Follow the deployment workflow documented in the repository's current README and Toolforge Build Service documentation; deployment configuration can change independently of the application code. After a deployment, verify the live page, OAuth callback, file conversion, Commons upload and post-upload status handling.

Maintenance

See also