# 1. Clone both repos
git clone https://github.com/meatlabs/meatholes.git
git clone https://github.com/trinitycode/trinitympeg.git
# 2. Build MeatHoles as a shared lib
cd meatholes
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED=ON
make -j$(nproc)
sudo make install # installs libmeatholes.so
# 3. Build TrinityMPEG with MeatHoles support
cd ../../trinitympeg
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DMEATHOLES_ROOT=/usr/local \
-DENABLE_ZERO_COPY=ON
make -j$(nproc)
sudo make install # installs libtrinitympeg.so
MeatHoles is a lightweight, high‑throughput data‑sharding library that excels at partitioning large binary blobs (e.g., video frames, audio samples, subtitle packets) into “holes” that can be processed in parallel without lock‑contention.
TrinityMPEG is a modern, open‑source MPEG‑2/4/HEVC transcoding engine that provides real‑time encoding/decoding, adaptive bitrate streaming (ABR), and built‑in DRM support. meatholes trinitympeg hit better
When combined, MeatHoles can dramatically improve the “hit” rate of TrinityMPEG – i.e., the proportion of frames that are successfully processed within the target latency budget. The result is: 0600) for the ring buffer
| Metric (baseline) | With MeatHoles | Δ | |-------------------|----------------|---| | 30‑second live‑encode latency (95 %ile) | 620 ms | –38 % | | CPU utilisation (average) | 78 % | –22 % | | Cache‑miss ratio (L3) | 12 % | –45 % | | ABR‑rebuffer events (per 1 h) | 6 | –4 | mount the process’s /proc/self/fd with nosuid
The following write‑up explains why the gains happen, how to integrate the two components, and best‑practice patterns to “hit better” in production.
| Area | Recommendation | Rationale |
|------|----------------|-----------|
| Monitoring | Export hole_created, hole_processed, cache_miss_rate, worker_cpu_pct as Prometheus metrics. | Early detection of back‑pressure or mis‑sized holes. |
| Observability | Enable TrinityMPEG’s built‑in frame‑level tracing (TRINITY_LOG_LEVEL=debug) only on staging, not in prod. | High‑resolution logs help tune hole size but add overhead. |
| Fail‑Safe | Wrap process_hole in a try/catch and fallback to a single‑threaded mode if a worker repeatedly crashes. | Guarantees continuity even when a rare hardware fault occurs. |
| Graceful Drain | On SIGTERM, stop ingest, set sharder.flush_mode(true), and let workers finish pending holes before exiting. | Prevents truncated GOPs in VOD assets. |
| Security | Use memfd_create + fchmod(fd, 0600) for the ring buffer; mount the process’s /proc/self/fd with nosuid,nodev. | Keeps raw video payload out of other processes’ address spaces. |
| ABR Integration | Feed the encoder’s QP (quantisation parameter) statistics from each hole into the multiplexer’s bitrate ladder algorithm. | Enables per‑hole bitrate adaptation rather than per‑segment, smoothing viewer QoE. |
| Testing | Run a “hole‑size sweep” benchmark: vary target_hole_size from 1 KB to 16 KB on a representative 4 K HDR stream, capture latency & CPU. | Empirically confirms the optimal sweet spot for your hardware. |