Install the ncmdump library
masterTo use ncmdump as a dependency in your Rust project, add it to your Cargo.toml or use cargo add.
ncmdump = "0.8.0"Or via CLI:
cargo add ncmdumprepository·master·Indexed 41 days ago
https://github.com/iqiziqi/ncmdump.rsA Rust tool and library for decrypting and converting .ncm and .qmc music files into raw audio formats such as .flac and .mp3. It provides a command-line interface for batch processing and a library for programmatic access to audio data, metadata (via NcmInfo), and album art.
To use ncmdump as a dependency in your Rust project, add it to your Cargo.toml or use cargo add.
ncmdump = "0.8.0"Or via CLI:
cargo add ncmdumpTo use ncmdump in your Rust project, add it to your Cargo.toml dependencies or use cargo add.
ncmdump = "0.8.0"You can install the ncmdump command-line tool using Cargo or by downloading the pre-built binary from the GitHub Releases page.
cargo install ncmdump-binThe ncmdump binary is a command-line tool used to decrypt and dump encrypted music files (such as .ncm or .qmc formats) into standard audio formats like .mp3 or .flac. It supports multi-threaded processing to handle multiple files efficiently.
To use the tool, you typically provide input files and specify an output directory. The tool automatically detects the underlying audio format (MP3 or FLAC) and injects the original metadata and album art into the decrypted file.
# Example conceptual usage (actual CLI flags are defined in the Command module)
ncmdump <input_files> --output <output_dir>To use ncmdump in your Rust project, add it to your Cargo.toml dependencies. Alternatively, if you have cargo-edit installed, you can use the cargo add command.
ncmdump = "0.7.3"cargo add ncmdumpTo extract music data from an .ncm file using the library, use Ncmdump::from_reader to parse the file and get_data() to retrieve the raw music bytes.
use std::fs::File;
use std::path::Path;
use anyhow::Result;
use ncmdump::Ncmdump;
fn main() -> Result<()> {
use std::io::Write;
let file = File::open("res/test.ncm")?;
let mut ncm = Ncmdump::from_reader(file)?;
let music = ncm.get_data()?;
let mut target = File::options()
.create(true)
.write(true)
.open("res/test.flac")?;
target.write_all(&music)?;
Ok(())
}To extract music data from an .ncm file, use Ncmdump::from_reader to parse the file and get_data() to retrieve the raw music bytes.
use std::fs::File;
use std::path::Path;
use anyhow::Result;
use ncmdump::Ncmdump;
fn main() -> Result<()> {
use std::io::Write;
let file = File::open("res/test.ncm")?;
let mut ncm = Ncmdump::from_reader(file)?;
let music = ncm.get_data()?;
let mut target = File::options()
.create(true)
.write(true)
.open("res/test.flac")?;
target.write_all(&music)?;
Ok(())
}The following options are available when using the ncmdump binary:
Usage: ncmdump [OPTIONS] [FILES]...
Arguments:
[FILES]... Specified the files to convert
Options:
-o, --output <OUTPUT> Specified the output directory. Default it's the same directory with input file
-v, --verbose Verbosely list files processing
-h, --help Print help
-V, --version Print versionTo decrypt an .ncm file, use the Ncmdump::from_reader method to create an Ncmdump instance from a file reader. You can then retrieve the decrypted audio data using the get_data() method. The resulting bytes can be written to a new file (e.g., a .flac file).
use std::fs::File;
use std::io::{Error, Write};
use std::path::Path;
use ncmdump::Ncmdump;
fn main() -> Result<(), Error> {
let file = File::open("res/test.ncm")?;
let mut ncm = Ncmdump::from_reader(file).expect("Can't create dump");
let music = ncm.get_data().expect("Can't get data");
let mut target = File::options()
.create(true)
.write(true)
.open("res/test.flac")?;
target.write_all(&music)?;
Ok(())
}The ncmdump binary is used to convert .ncm files to raw music data (e.g., .flac).
Basic Command:
ncmdump [FILES]...
Options:
-o, --output <OUTPUT>: Specify the output directory. If not provided, it defaults to the same directory as the input file.-v, --verbose: Verbosely list files being processed.-h, --help: Print help information.-V, --version: Print version information.ncmdump [FILES]...The get_data() method extracts and decrypts the actual audio stream from the NCM file. It returns the raw audio bytes (e.g., FLAC or MP3 data) as a Vec<u8>}.
# use std::fs::File;
# use std::io::Write;
# use ncmdump::Ncmdump;
# use anyhow::Result;
fn main() -> Result<()> {
let file = File::open("res/test.ncm")?;
let mut ncm = Ncmdump::from_reader(file)?;
let music = ncm.get_data()?;
let mut target = File::options()
.create(true)
.write(true)
.open("res/test.flac")?;
target.write_all(&music)?;
Ok(())
}The QmcDump struct provides a wrapper around a reader to decrypt and extract music data from QMC-formatted files (e.g., .qmcflac). It implements the std::io::Read and std::io::Seek traits, meaning it can be used like any other standard Rust reader. To extract the entire decrypted payload into a byte vector, use the get_data() method.
use std::fs::File;
use ncmdump::QmcDump;
fn main() -> anyhow::Result<()> {
// 1. Open the encrypted QMC file
let file = File::open("res/test.qmcflac")?;
// 2. Wrap it in QmcDump
let mut qmc = QmcDump::from_reader(file)?;
// 3. Extract the decrypted music data
let music = qmc.get_data()?;
// 4. Save to a new file (e.g., .flac)
let mut target = File::create("res/test.flac")?;
target.write_all(&music)?;
Ok(())
}