# Source of the conversion engine

> Bilingual on purpose: the `/licenses/` page is served in English and Spanish,
> and this document is served as plain text from `/licenses/ffmpeg/SOURCE.md`.
> English first, then the Spanish version. The verbatim license texts linked from
> here stay in their original language, because they are legal texts and a
> translation of them is not the same document.

The binary this site distributes is `public/ffmpeg/ffmpeg-core.wasm`, a
WebAssembly build of FFmpeg. It is compiled with `--enable-gpl`, so it is
distributed under the **GNU GPL version 2 or later**. This note is the
"corresponding source" the GPL (section 2) requires to be locatable, and the
license text is in [`GPL-2.0.txt`](GPL-2.0.txt), next to this file.

The data here is read from the `Dockerfile` and `build/ffmpeg.sh` of the
ffmpeg.wasm project itself, at the commit that published the package we serve.
This file is maintained by hand.

## What is distributed, and how it is verified

| | |
|---|---|
| Package | `@ffmpeg/core@0.12.10` (npm) |
| Files | `ffmpeg-core.js`, `ffmpeg-core.wasm` (32 MB) |
| sha256 | in [`checksums.txt`](checksums.txt) |
| License | GPL-2.0-or-later (as declared in the package's own `package.json`) |

The binary is served **unmodified**: byte for byte the one the ffmpeg.wasm
project publishes. `node scripts/fetch-ffmpeg-core.mjs --verify` checks it
against the recorded sha256, and running the script without arguments downloads
it again from the npm tarball (it warns you if the hash ever changes). We apply
no patches and no obfuscation, so the corresponding source is exactly what is
below.

## The source, in full

Project: <https://github.com/ffmpegwasm/ffmpeg.wasm> (MIT for the JS wrapper;
the FFmpeg binary inside it is GPL-2.0-or-later)
Commit that published `@ffmpeg/core@0.12.10`: <https://github.com/ffmpegwasm/ffmpeg.wasm/tree/c3a76385>

Complete archive, served from this site next to the binary: [`ffmpeg-core-0.12.10-source.tar`](/ffmpeg/ffmpeg-core-0.12.10-source.tar). It holds FFmpeg, every library below and the build recipe, with the commit of each project listed in its `README.txt`.

- Build recipe: the `Dockerfile` and `build/*.sh` at that commit
  (<https://github.com/ffmpegwasm/ffmpeg.wasm/blob/c3a76385/Dockerfile>). A copy
  is served from this site in [`build/`](build/README.md), so it can be read
  here without leaving it.
- Toolchain: `emscripten/emsdk:3.1.40`
- FFmpeg: `n5.1.4` (<https://github.com/FFmpeg/FFmpeg/tree/n5.1.4>)

FFmpeg `configure` flags, read from the `--enable-*` string embedded in the
`.wasm` itself (not from memory):

```
--disable-pthreads --disable-w32threads --disable-os2threads
--enable-gpl
--enable-libx264 --enable-libx265 --enable-libvpx --enable-libmp3lame
--enable-libtheora --enable-libvorbis --enable-libopus --enable-zlib
--enable-libwebp --enable-libfreetype --enable-libfribidi --enable-libass
--enable-libzimg
```

Libraries compiled into the binary before FFmpeg, with the repository and the
exact branch the `Dockerfile` at that commit uses. Their full license texts are
in [`libs/`](libs/README.md). No count is given here on purpose: this table is
the list, and it changes if the build does.

| Library | Repository | Branch |
|---|---|---|
| x264 | ffmpegwasm/x264 | `4-cores` |
| x265 | ffmpegwasm/x265 | `3.4` |
| libvpx | ffmpegwasm/libvpx | `v1.13.1` |
| LAME | ffmpegwasm/lame | `master` |
| Ogg | ffmpegwasm/Ogg | `v1.3.4` |
| Theora | ffmpegwasm/theora | `v1.1.1` |
| Opus | ffmpegwasm/opus | `v1.3.1` |
| Vorbis | ffmpegwasm/vorbis | `v1.3.3` |
| zlib | ffmpegwasm/zlib | `v1.2.11` |
| libwebp | ffmpegwasm/libwebp | `v1.3.2` |
| FreeType | ffmpegwasm/freetype2 | `VER-2-10-4` |
| FriBidi | fribidi/fribidi | `v1.0.9` |
| HarfBuzz | harfbuzz/harfbuzz | `5.2.0` |
| libass | libass/libass | `0.15.0` |
| zimg | sekrit-twc/zimg | `release-3.0.5` |

The `Dockerfile` and `build/*.sh` of ffmpeg.wasm clone those branches and build
each library with its own script, so the list above plus those scripts is the
complete, exact recipe. To reproduce the binary you only need to run `make prd`
(the production target) on that commit with Docker.

## Copyright notices

FFmpeg is distributed under GPL-2.0-or-later and its external libraries under
their own licenses: GPL-2.0-or-later for x264 and x265, LGPL for LAME and FriBidi, WTFPL for zimg,
BSD for libvpx, Theora, Vorbis, Opus and libwebp, MIT for HarfBuzz, ISC for
libass, FTL or GPL for FreeType, and the zlib license for zlib. The full text of
each one is in [`libs/`](libs/README.md), and the original copyright notices are
also in the `COPYING` or `LICENSE` file of each repository in the table above and
in `COPYING.LGPLv2.1` / `COPYING.GPLv2` of the FFmpeg tree.

## And our code

fileclay's own code is not part of that build, and we have not modified the
binary. Those are facts, and they are checkable: the recipe above is entirely
upstream's, our source is not in it, and the sha256 in `checksums.txt` matches
the published package. Technically, the binary is loaded at runtime as a
separate file, instantiated inside a worker, and the app talks to it only
through a narrow input/output interface.

The binary carries the GPL, and the terms that apply to it are the ones listed on
the `/licenses/` page.

DM Sans and Manrope are OFL-1.1 and Roboto is Apache-2.0, all served as published,
with their licenses in `licenses/fonts/`.

## What is in this folder

| File | What it is |
|---|---|
| `GPL-2.0.txt` | The GPL v2 text, the one that must travel with the binary |
| `SOURCE.md` | This document: the source manifest |
| `checksums.txt` | sha256 of the two files we serve |
| `libs/` | License text of the 15 libraries compiled inside, plus `manifest.json` |
| `build/` | The `Dockerfile` and `build/*.sh` of the exact commit, served from this site |

Everything here is regenerated and checked by these scripts:

```
npm run licenses:ffmpeg      # downloads the core, the GPL and records the sha256
npm run licenses:libs        # downloads the license texts of the libraries
npm run licenses:recipe      # copies the build recipe
npm run licenses:verify      # checks that the served binary has not changed
```

---

# Fuente del motor de conversión

> Bilingüe a propósito: la página `/licenses/` se sirve en inglés y en español, y
> este documento se sirve como texto plano en `/licenses/ffmpeg/SOURCE.md`. Primero
> el inglés, después el español. Los textos de licencia enlazados desde aquí se
> quedan en su idioma original, porque son textos legales y una traducción no es el
> mismo documento.

El binario que distribuye este sitio es `public/ffmpeg/ffmpeg-core.wasm`, un
build de FFmpeg para WebAssembly. Se compila con `--enable-gpl`, así que se
distribuye bajo la **GNU GPL versión 2 o posterior**. Esta nota es la
"fuente correspondiente" que la GPL (sección 2) pide poder localizar, y el texto
de la licencia está en [`GPL-2.0.txt`](GPL-2.0.txt), en esta misma carpeta.

Los datos salen del `Dockerfile` y del `build/ffmpeg.sh` del propio proyecto
ffmpeg.wasm, en el commit que publicó el paquete que servimos. Este documento se
mantiene a mano.

## Qué se distribuye y cómo se comprueba

| | |
|---|---|
| Paquete | `@ffmpeg/core@0.12.10` (npm) |
| Ficheros | `ffmpeg-core.js`, `ffmpeg-core.wasm` (32 MB) |
| sha256 | en [`checksums.txt`](checksums.txt) |
| Licencia | GPL-2.0-or-later (declarada en el `package.json` del paquete) |

El binario se sirve **sin modificar**: es byte a byte el que publica el proyecto
ffmpeg.wasm. `node scripts/fetch-ffmpeg-core.mjs --verify` lo comprueba contra
el sha256 anotado, y sin argumentos vuelve a descargarlo del tarball de npm (si
el hash cambiara, avisaría). No hay parches ni ofuscaciones aplicadas por
nosotros, así que la fuente correspondiente es exactamente la de abajo.

## La fuente, al completo

Proyecto: <https://github.com/ffmpegwasm/ffmpeg.wasm> (MIT en el envoltorio JS;
el binario de FFmpeg que contiene es GPL-2.0-or-later)
Commit que publicó `@ffmpeg/core@0.12.10`: <https://github.com/ffmpegwasm/ffmpeg.wasm/tree/c3a76385>

Archivo completo, servido desde este sitio junto al binario: [`ffmpeg-core-0.12.10-source.tar`](/ffmpeg/ffmpeg-core-0.12.10-source.tar). Contiene FFmpeg, todas las librerías de abajo y la receta del build, con el commit de cada proyecto en su `README.txt`.

- Receta del build: el `Dockerfile` y los `build/*.sh` de ese commit
  (<https://github.com/ffmpegwasm/ffmpeg.wasm/blob/c3a76385/Dockerfile>). Una
  copia se sirve desde este sitio en [`build/`](build/README.md), para poder
  leerla sin salir de aquí.
- Toolchain: `emscripten/emsdk:3.1.40`
- FFmpeg: `n5.1.4` (<https://github.com/FFmpeg/FFmpeg/tree/n5.1.4>)

Flags de `configure` de FFmpeg, leídos de la cadena `--enable-*` embebida en el
propio `.wasm` (no de memoria):

```
--disable-pthreads --disable-w32threads --disable-os2threads
--enable-gpl
--enable-libx264 --enable-libx265 --enable-libvpx --enable-libmp3lame
--enable-libtheora --enable-libvorbis --enable-libopus --enable-zlib
--enable-libwebp --enable-libfreetype --enable-libfribidi --enable-libass
--enable-libzimg
```

Librerías que se compilan antes que FFmpeg, con el repositorio y la rama exacta
que usa el `Dockerfile` de ese commit. Sus textos de licencia completos están en
[`libs/`](libs/README.md).

| Librería | Repositorio | Rama |
|---|---|---|
| x264 | ffmpegwasm/x264 | `4-cores` |
| x265 | ffmpegwasm/x265 | `3.4` |
| libvpx | ffmpegwasm/libvpx | `v1.13.1` |
| LAME | ffmpegwasm/lame | `master` |
| Ogg | ffmpegwasm/Ogg | `v1.3.4` |
| Theora | ffmpegwasm/theora | `v1.1.1` |
| Opus | ffmpegwasm/opus | `v1.3.1` |
| Vorbis | ffmpegwasm/vorbis | `v1.3.3` |
| zlib | ffmpegwasm/zlib | `v1.2.11` |
| libwebp | ffmpegwasm/libwebp | `v1.3.2` |
| FreeType | ffmpegwasm/freetype2 | `VER-2-10-4` |
| FriBidi | fribidi/fribidi | `v1.0.9` |
| HarfBuzz | harfbuzz/harfbuzz | `5.2.0` |
| libass | libass/libass | `0.15.0` |
| zimg | sekrit-twc/zimg | `release-3.0.5` |

Los `Dockerfile` y `build/*.sh` de ffmpeg.wasm clonan esas ramas y compilan cada
librería con su script, así que la lista de arriba más esos scripts es la receta
completa y exacta. Quien quiera reproducir el binario solo necesita ejecutar
`make prd` (el target de producción) sobre ese commit con Docker.

## Avisos de copyright

FFmpeg se distribuye bajo la GPL-2.0-or-later y sus bibliotecas externas bajo
sus propias licencias: GPL-2.0-or-later para x264 y x265, LGPL para LAME y
FriBidi, WTFPL para zimg, BSD para libvpx, Theora, Vorbis, Opus y libwebp, MIT para HarfBuzz, ISC
para libass, FTL o GPL para FreeType, y la licencia zlib para zlib. El texto
completo de cada una está en [`libs/`](libs/README.md), y los avisos originales
de copyright están además en los ficheros `COPYING` o `LICENSE` de cada
repositorio de la tabla de arriba y en `COPYING.LGPLv2.1` / `COPYING.GPLv2` del
árbol de FFmpeg.

## Y nuestro código

El código de fileclay no forma parte de esa compilación, y no hemos modificado
el binario. Son hechos, y se pueden comprobar: la receta de arriba es toda de
ffmpeg.wasm, nuestro código no está en ella, y el sha256 de `checksums.txt`
coincide con el del paquete publicado. Técnicamente, el binario se carga en
tiempo de ejecución como fichero separado, se instancia dentro de un worker, y
la app se comunica con él solo a través de una interfaz estrecha de entrada y
salida.

El binario lleva la GPL, y los términos que le aplican son los que se listan en
la página `/licenses/`.

DM Sans y Manrope son OFL-1.1 y Roboto es Apache-2.0, y se sirven tal cual se
publican, con sus licencias en `licenses/fonts/`.

## Qué hay en esta carpeta

| Fichero | Qué es |
|---|---|
| `GPL-2.0.txt` | Texto de la GPL v2, el que hay que entregar con el binario |
| `SOURCE.md` | Este documento: el manifiesto de fuentes |
| `checksums.txt` | sha256 de los dos ficheros que servimos |
| `libs/` | Textos de licencia de las 15 librerías compiladas dentro, y `manifest.json` con su listado |
| `build/` | El `Dockerfile` y los `build/*.sh` del commit exacto, servidos desde este sitio |

Todo esto se regenera y se comprueba con estos scripts:

```
npm run licenses:ffmpeg      # descarga el núcleo, el GPL y anota los sha256
npm run licenses:libs        # descarga las licencias de las librerías
npm run licenses:recipe      # copia la receta de build
npm run licenses:verify      # comprueba que el binario servido no ha cambiado
```
