truehdd/truehdd
About
Tools for inspecting and decoding Dolby TrueHD bitstreams
Developer ToolsMeasured star growth
- in 24h
- 0
- in 7 days
- +3
- in 15 days
- +5
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Originaltruehdd
A command-line tool for decoding Dolby TrueHD audio streams.
Language: English | 简体中文 | 日本語
⚠️ Experimental
This tool is designed for research and development purposes.
It is not intended for production environments or consumer playback systems.💡 Got a new idea?
If you have ideas for useful features, please let us know by opening an issue or starting a discussion.
Overview
truehdd is a command-line interface for the truehd library, enabling decoding of Dolby TrueHD audio streams.
It also reads the Meridian Lossless Packing streams DVD-Audio carries, and checks either against the conformance rules with verify.
Installation
From Source
Requires Rust 1.95.0 or later:
git clone https://github.com/truehdd/truehdd
cd truehdd
cargo build --release
The compiled executable will be located at target/release/truehdd.
Usage
truehdd [OPTIONS] <COMMAND>
Commands:
decode Decode the specified TrueHD stream into PCM audio
info Print stream information
verify Check the specified TrueHD stream against the conformance rules
help Print this message or the help of the given subcommand(s)
Options:
--loglevel <LOGLEVEL> Set the log level [default: info]
[possible values: off, error, warn, info, debug, trace]
--strict Treat warnings as fatal errors (fail on first warning)
--log-format <LOG_FORMAT> Log output format [default: plain]
[possible values: plain, json]
--progress Show progress bars during operations
-h, --help Print help (see more with '--help')
-V, --version Print version
Commands
info - Stream Analysis
Analyzes TrueHD streams and displays detailed information about their structure and properties without performing decoding.
Usage: truehdd info [OPTIONS] <INPUT>
Arguments:
<INPUT> Input TrueHD bitstream
Options:
--loglevel <LOGLEVEL> Set the log level [default: info]
[possible values: off, error, warn, info, debug, trace]
--quick Read only the first ten seconds, and leave the duration unmeasured
--json Print a machine-readable description on stdout
--strict Treat warnings as fatal errors (fail on first warning)
--log-format <LOG_FORMAT> Log output format [default: plain] [possible values: plain, json]
--progress Show progress bars during operations
-h, --help Print help (see more with '--help')
Examples:
# Analyze a TrueHD file
truehdd info movie.thd
# Describe a stream from its first ten seconds
truehdd info --quick movie.thd
# The same, for a program to read
truehdd info --quick --json movie.thd
--quick stops after ten seconds of the stream (12000 access units), which is enough to describe it and to detect a trim without reading a whole film. The duration, size and average data rate need the whole stream, so they are left out, and a change later in the stream goes unseen.
A stream that changes its layout part way through, such as a 5.1 introduction followed by Atmos, is described as one segment for each layout, with the access unit and the time the segment starts at.
Machine-Readable Output:
--json prints one object on stdout in place of the report. This one is shortened to the object presentation:
{
"version": "0.7.0",
"input": "movie.thd",
"complete": false,
"frames": 12000,
"rejectedFrames": 0,
"bytes": 5767168,
"duration": null,
"timestamp": null,
"trimmedSamples": 51200,
"segments": [
{"startFrame": 0, "startTime": 0.0, "frames": 12000, "samples": 480000,
"formatSync": "FBA", "sampleRate": 48000, "variableRate": true,
"peakDataRate": 5997, "substreams": 4, "atmos": true,
"presentations": [
{"index": 3, "channels": 14, "type": "independent", "of": null,
"bedConfiguration": ["LFE"], "dialogueLevel": -31, "mixLevel": 105,
"drcDefault": null, "channelFormat": null, "surroundEx": null,
"channelDistribution": null}
]}
]
}
complete is false for a --quick run, whose duration is null and whose last segment counts only the frames read. duration and startTime are in seconds, and peakDataRate in kbps. rejectedFrames counts candidate frames the extractor refused. trimmedSamples is null when the stream signals no trim, or none within the part read. A presentation's type is copy, downmix or independent, with the presentation it derives from in of. Presentations 0 to 2 list their channelAssignment, and the object presentation its bedConfiguration, with channels counting its elements.
verify - Conformance Checking
Parses a whole stream and reports every conformance check that fires, rather than stopping at the first. Each diagnostic prints its rule ID, severity, access unit and byte.bit position, followed by a summary: a per-rule tally, the stream's format and FIFO peaks against their caps, the branch points a splice leaves behind, which disc formats the stream is legal for, and a verdict.
A stream can be a conformant bitstream and still be inadmissible on every disc format, which is reported as CONFORMANT, NOT DISC-AUTHORABLE and exits 0: the disc rules and the codec rules are different rules.
Usage: truehdd verify [OPTIONS] <INPUT>
Arguments:
<INPUT> Input TrueHD bitstream (use "-" for stdin)
Options:
--fail-on <SEVERITY> Worst severity that still exits 0 [default: error]
[possible values: info, warning, error, fatal]
--max-per-rule <N> Stop printing after this many diagnostics of the same
rule; 0 prints them all [default: 20]
--json Print one JSON object per line instead of the report
--summary-only Print the summary alone
--loglevel <LOGLEVEL> Set the log level [default: info]
[possible values: off, error, warn, info, debug, trace]
--strict Treat warnings as fatal errors (fail on first warning)
--log-format <LOG_FORMAT> Log output format [default: plain] [possible values: plain, json]
--progress Show progress bars during operations
-h, --help Print help (see more with '--help')
Examples:
# Check a stream against the conformance rules
truehdd verify movie.thd
# Treat anything at or above a warning as a failure
truehdd verify --fail-on warning movie.thd
# One JSON object per diagnostic, for tooling
truehdd verify --json movie.thd
decode - Audio Decoding
Decodes TrueHD streams into PCM audio.
Usage: truehdd decode [OPTIONS] <INPUT>
Arguments:
<INPUT> Input TrueHD bitstream (use "-" for stdin)
Options:
--output-path <PATH> Output path for audio and metadata files
--format <FORMAT> Audio format for output (presentation 3 always uses CAF)
[default: caf] [possible values: caf, pcm, w64]
--presentation <SELECTION> Presentations to decode: an index (0-3), a list (0,1,3), "all",
or "max" for the highest available presentation [default: max]
--no-estimate-progress Disable progress estimation
--bed-conform Enable bed conformance for Atmos content
--metadata-only Write only object audio metadata, skipping PCM output
--json Print a machine-readable result summary on stdout
--warp-mode <WARP_MODE> Specify warp mode when not present in metadata
[possible values: normal, warping, prologiciix, loro]
--frame-rate <RATE> Timecode frame rate recorded in the Atmos master [default: 24]
[possible values: 23.976, 24, 25, 29.97, 29.97df, 30]
--probe-range <PROBE_RANGE>
Access units to probe for Atmos metadata with --bed-conform,
where the major sync does not declare the objects
[default: 12000]
--evo-key <KEY> Verify Evolution frame protection with this HMAC-SHA-256 key,
given as hex or as @FILE holding hex
--loglevel <LOGLEVEL> Set the log level [default: info]
--strict Treat warnings as fatal errors (fail on first warning)
--log-format <LOG_FORMAT> Log output format [default: plain]
--progress Show progress bars during operations
-h, --help Print help (see more with '--help')
Output Files:
By default, the maximum available presentation index is chosen for decoding.
When --output-path is specified, the tool generates appropriate output files:
Channel presentation: One of the following files, with presentation index 0, 1, or 2
output.caf- PCM data in Core Audio Formatoutput.pcm- Raw PCM (if--format pcm)output.wav- Wave64 format (if--format w64)
Object presentation: Dolby Atmos master file set, with presentation index 3 (if available)
output.atmos- Essential information about the presentationoutput.atmos.audio- Audio for all bed signals and objects in Core Audio formatoutput.atmos.metadata- 3D positional coordinates for static and dynamic signals
Note: Presentation 3 always uses CAF format regardless of
--formatoption. Use--bed-conformto convert bed channels to 7.1.2 layout.Multiple presentations: selecting a list,
all, or several presentations suffixes every output with its presentation index, for exampleoutput_p1.cafandoutput_p3.atmos, even when only one presentation turns out to exist. Selected presentations are decoded in a single pass, sharing the work their substreams have in common.
Metadata Only:
--metadata-only writes the .atmos header and .atmos.metadata for an object presentation and skips the audio file, which is useful for inspecting or collecting metadata without producing gigabytes of PCM. The metadata is identical to a full decode. The .atmos header still names the audio file it did not write, so the result is a metadata set rather than a loadable master. A presentation without object audio metadata writes nothing.
Evolution Frame Protection:
Evolution frames carry protection words holding a truncated HMAC-SHA-256 over the access unit and the frame itself. Checking them needs the key the encoder used, which is not built in, so --evo-key takes one as hex or as @FILE holding hex. Without it nothing is verified. A mismatch is a warning by default and is counted in the summary; under --strict the first one aborts the decode. Streams with no Evolution frame report zero frames checked rather than a failure.
Machine-Readable Output:
--json prints a single result object on stdout when decoding finishes, so a calling program does not have to guess which files were written:
{
"version": "0.5.0",
"input": "movie.thd",
"frames": 225526,
"skippedFrames": 0,
"concealedFrames": 0,
"branches": 0,
"invalidBranches": 0,
"evoChecked": 0,
"evoFailed": 0,
"samples": 9021040,
"sampleRate": 48000,
"presentations": [
{"index": 3, "format": "damf", "channels": 12,
"files": ["out.atmos", "out.atmos.audio", "out.atmos.metadata"],
"segments": [
{"startFrame": 0, "startTime": 0, "frames": 225526, "samples": 9021040,
"sampleRate": 48000, "format": "damf", "channels": 12,
"bedChannels": 1, "objects": 11,
"files": ["out.atmos", "out.atmos.audio", "out.atmos.metadata"]}
]}
]
}
A stream that changes its layout is written as one set of files for each segment, and segments lists them: the access unit and the time in seconds the segment starts at in the stream, its length, and its own files. bedChannels and objects are null for a segment without object audio metadata. A segment can belong to another presentation than the one before it, as when 5.1 turns into Atmos, so a caller wanting the whole timeline reads the segments of every presentation.
channels is null until the channel count is known. skippedFrames counts frames the extractor could not use and resynchronised past. concealedFrames counts frames that could not be parsed or decoded and were written as silence instead; frames includes them. branches counts seamless branch points that satisfy the decoder buffer model and invalidBranches those that do not; the latter is a conformance finding and does not change the decoded samples. Logs stay on stderr, so stdout carries only this object. Use --log-format json for machine-readable logs as well.
With --log-format json, --progress writes a record to the log about twice a second in place of the bar, on a terminal or not, and whatever the log level:
{"ts":"2026-11-30T05:12:01Z","lvl":"INFO","msg":"Decoded 26240 frames (00:00:21.867)","event":"progress","frames":26240,"samples":1049600,"sampleRate":48000,"time":21.867,"totalFrames":605459}
time is the seconds of the stream decoded so far and samples their count in samples. sampleRate is the rate of the latest access unit, so across a change of rate time is the one to rely on. totalFrames is null when the frames were not counted first: for piped input, or with --no-estimate-progress.
With the plain log format, the bar is drawn only on a terminal. Where the log goes to a pipe or a file, --progress writes the same message as a log line, Decoded 26240 frames (00:00:21.867), at the same pace and whatever the log level.
The exit code identifies which stage failed:
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Unspecified failure |
| 2 | Invalid command line |
| 3 | Input could not be read |
| 4 | Bitstream could not be parsed |
| 5 | Audio could not be decoded |
| 6 | Output could not be written |
| 7 | Stream is non-conformant (verify only) |
With --strict, skipped frames are treated as a failure as well.
Damaged Streams:
A frame that fails to parse or decode is reported, and decoding resumes at the next major sync instead of aborting. Once decoding has started, frames lost that way are written as silence, so what follows stays in sync. Pass --strict to fail on the first problem instead.
Log Codes:
With --log-format json, every warning and error record carries a code that stays the same when its message is reworded:
{"ts":"2026-12-01T04:46:17Z","lvl":"WARN","msg":"Parse error at frame 2: CRC failed on substream_segment for substream 0. Calculated 0x31, Read 0xD3; resuming at next major sync","code":"stream.parse_error","rule":"substream.crc_mismatch"}
A conformance check that fires while the stream is read is logged under its rule id, the one verify reports, such as restart_header.invalid_seamless_branch. The other codes are:
| Code | Meaning |
|---|---|
input.trailing_bytes |
Bytes at the end of the input are not a complete frame |
stream.extract_error |
Frames could not be extracted and were skipped up to the next sync |
stream.parse_error |
A frame could not be parsed |
stream.decode_error |
A frame could not be decoded |
concealment.silence_written |
Frames lost to such an error were written as silence |
evolution.protection_mismatch |
A frame failed the check asked for with --evo-key |
bed_conform.metadata_after_probe |
Atmos metadata arrived after the probe range, so the segment keeps its decoded bed |
bed_conform.bed_exceeds_decoded_channels |
The metadata names a larger bed than was decoded, so the segment keeps its decoded channels |
bed_conform.bed_differs_from_major_sync |
The metadata names another bed than the major sync, which the audio follows |
bed_conform.declared_objects_without_metadata |
The major sync declares objects but no metadata arrived |
output.no_object_audio_metadata |
--metadata-only found no metadata and wrote nothing |
output.finalize_failed |
The output files could not be completed after an error |
stream.extract_error, stream.parse_error and stream.decode_error name the check that failed in rule. An error that ends the command is the last record of the log, at any log level. It has one of the codes above where one applies, and otherwise the code of its exit code: error.input, error.parse, error.decode, error.write, error.nonconformant or error.failure.
Warp Mode Options:
The --warp-mode option controls how Dolby Atmos content handles downmix rendering when the metadata doesn't specify a warp mode:
normal- Direct renderwarping- Direct render with room balanceprologiciix- Dolby Pro Logic IIxloro- Standard (Lo/Ro)
This option only applies when the original OAMD metadata lacks warp mode information. If warp mode is already present in the metadata, this option is ignored.
Timecode Frame Rate:
--frame-rate sets the timecode frame rate recorded in the .atmos header of an Atmos master: 23.976, 24 (the default), 25, 29.97, 29.97df or 30. It states what rate the master's timecode is in and nothing else: no audio is resampled and no metadata is retimed.
Examples:
# Decode a TrueHD file with progress
truehdd decode --progress audio.thd --output-path decoded_audio
# Decode with specific warp mode for content missing this metadata
truehdd decode --warp-mode prologiciix audio.thd --output-path decoded_audio
# Decode every available presentation in one pass
truehdd decode --presentation all audio.thd --output-path decoded_audio
# Decode from ffmpeg pipe
ffmpeg -i movie.mkv -c copy -f truehd - | truehdd decode - --output-path audio
License
Licensed under the Apache License, Version 2.0. See LICENSE and NOTICE for details.
Explore related projects
Loading…