s3-hls-transcoder · Media infrastructure · Public source

From guest uploads to a shared wedding gallery

A wedding website for 100 attendees became a media engineering project: preserve every uploaded original, present the best copy of each capture, and make phone videos stream in their actual orientation. The decisions behind the gallery and its self-hosted processing workers.

I started this for my sister's wedding website. With 100 attendees, there would be photos and videos scattered across phones, shared albums, and text conversations. Texting pictures and iCloud photo sharing were the existing approach, but coordinating exchanges across that group was not the experience I wanted.

I wanted guests to upload into one gallery. Someone might contribute an original photo; someone else might upload a compressed copy they had received in a message. Both should be able to contribute without checking what everyone else had already uploaded. The gallery should make sense of the collection afterward.

I am my own customer for this project: I built the application and the processing behind it for an event I am helping organize. That gave me a concrete product requirement. Keep every contribution, but spare people the work of sorting through repeated copies and finding a playable version of each video.

Status, 4 October 2026: uploads, the gallery, streaming playback, duplicate detection, and preferred-copy selection are implemented. Guest use is still ahead; there are no observed event results yet. The 100 attendees describe the intended audience, not measured adoption or a load-test result.

Keep the originals; organize the presentation

The most important rule is that every uploaded original is retained. Deduplication changes what the gallery presents, not which contributions survive in storage.

That separates two responsibilities. The original collection preserves what guests supplied. The viewing collection presents a deduplicated, optimized set, using a preferred source within each group of duplicate copies.

The definition of a duplicate matters. A compressed or resized copy of the same capture is a candidate for consolidation. A crop, an edit, or the next photograph in a burst remains a separate contribution. Looking similar is not enough to make two images interchangeable.

Within a duplicate group, resolution and file size help choose the preferred source; for comparable video duration, bitrate is another useful signal. These are practical quality heuristics, not a perceptual-quality guarantee. A larger file can reflect a different codec or less efficient compression rather than more detail.

Keeping the originals makes those decisions revisable. A grouping can be corrected, a preference can change, and optimized media can be regenerated without asking guests to upload again. The presentation can improve without rewriting the archive.

A small contract between the application and the worker

The gallery owns the user experience and the decisions about which contributions belong together. The public s3-hls-transcoder project supplies background media processing over S3-compatible object storage.

The video worker reads source objects and writes HLS output: playlists and video segments that a player can use for streaming. A companion image worker computes PDQ perceptual hashes, which the application can use when looking for duplicate candidates. The application remains responsible for deciding what those candidates mean.

The integration has three main steps:

Application uploads an original → source bucket
Worker reads the original      → destination bucket with derived media
Application reads a mapping    → player loads the HLS playlist and segments

The worker never modifies or deletes source objects. Its destination contains the derived output and bookkeeping. A per-source mapping tells the application where the playable output lives, so the gallery does not need to reconstruct the worker's internal storage paths.

This also makes processing state part of the product. Upload completion and playback readiness are separate events. The application can show that a video is processing, then use its mapping when output becomes available. The worker's error records give the operator a way to distinguish a failed source from one that is still waiting.

Identical bytes and similar pictures need different treatment

For video, the worker computes a SHA-256 content identifier. Two source objects with identical bytes can point to the same encoded output instead of paying the encoding and storage cost twice.

A perceptual match makes a weaker claim. It suggests that two videos look alike, but it does not establish that one upload should replace the other. The worker therefore logs perceptual video matches without using them to repoint or delete existing output. Similarly, the image worker produces hashes rather than making the gallery's duplicate decisions itself.

That boundary keeps a reusable processing component from acquiring authority over the meaning of someone's photographs. Exact-byte reuse belongs in the worker; decisions about distinct contributions belong in the application.

Shared output introduces a second responsibility: tracking references. If two source objects use one encoded video, removing one mapping must not make the output disappear from under the other.

The reverse-reference index is updated in a deliberate order: add the new reference, write the mapping, then remove a superseded reference. An interruption can leave an extra stale reference for cleanup to check. The ordering avoids dropping the reference before the mapping has safely moved. It chooses the recoverable bookkeeping error over prematurely deleting something still in use.

Portrait video exposed the landscape assumption

Handling portrait video was the hardest part. A landscape encoding ladder seems reasonable until the inputs are ordinary phone recordings.

There are two dimensions to the problem. First, a video can store landscape-shaped frames with metadata telling the player to rotate them. The dimensions reported for the encoded frames are not necessarily the dimensions the viewer sees. The probe accounts for display rotation before choosing output sizes, while FFmpeg handles rotation during decoding.

Second, every streaming rendition needs to preserve that displayed shape. The earlier pipeline fitted video inside fixed landscape rectangles and padded the remaining space. That could turn a portrait recording into a narrow picture inside a wide frame with black bars.

The revised ladder uses the short edge of the displayed video to select rendition sizes and preserves its aspect ratio:

Rendition Landscape source, 1920 × 1080 Portrait source, 1080 × 1920
360p 640 × 360 360 × 640
720p 1280 × 720 720 × 1280
1080p 1920 × 1080 1080 × 1920

Renditions above the source's short-edge resolution are omitted. Smaller sources stay at their own size rather than being enlarged to the lowest configured rung. Output dimensions are rounded to even numbers for the encoder, and source bitrate provides a cap on the target bitrate, with some headroom for re-encoding.

Correcting new uploads is only part of the change. An unchanged source can already have cached output from an older encoder. The re-encoding path checks older mappings and identifies output whose display aspect needs correcting, while avoiding unnecessary re-encoding of layouts that were already right.

That connects back to retaining originals: the pipeline can revisit its own encoding decisions without losing the source or making the contributor repeat the upload.

Fast notifications, with a recovery path

The workers can run periodically or stay running and wake on Redis or HTTP notifications. A wake request changes when a scan starts; it does not replace the scan with an authoritative list of jobs.

Periodic fallback scans remain in place. A missed notification can delay discovery, but the system does not depend on receiving that notification to discover an uploaded source. Requests that arrive during a running pass coalesce into a follow-up pass.

The design accepts the cost of scanning the source collection in exchange for a simpler recovery model. It also uses one active runner per destination bucket, a deliberate limit on processing concurrency. This is an operating tradeoff to measure against the workload, not a claim of unlimited scale.

What I want to learn from the event

The implemented workflow brings uploads, a gallery, streaming video, duplicate detection, and preferred-copy selection together. The next evidence will come from guests using it: whether contributing is straightforward, how long video processing takes, and whether the presented collection preserves the distinctions people care about.

I have not measured those outcomes yet. After the event, I want to add actual usage, examples of duplicate handling, portrait-playback observations, and the operational work the system required.

Being my own customer made the priorities concrete: accept the contributions people actually have, preserve their originals, and make the collection enjoyable to browse. The engineering follows from those priorities, including the boundaries on what the processing worker is allowed to decide.

Implementation references

Implementation links follow the main branch. This is a description of the design and implemented workflow, not a benchmark or an independent reliability assessment.