Always enable compression (such as compression=2 in asammdf ). It reduces file size by up to 70% without sacrificing read speeds.
// Create MF4 file MDF4_FILE* mdf = mdf4_create("out.mf4", MDF4_COMPRESSION_DEFLATE);
The "new" CLI and Python methods are roughly 4x faster than the old GUI workflow.
import os from asammdf import MDF def convert_blf_to_mf4(blf_path, output_path, dbc_folder=None): """ Converts a Vector BLF file to an ASAM MF4 file using asammdf. """ print(f"Loading BLF file: blf_path") # Open the BLF file directly using MDF.convert # asammdf handles the underlying extraction seamlessly try: # If you have DBC files for decoding network traffic, pass them in a dict # e.g., databases = 'CAN': [('path/to/file.dbc', 0)] where 0 is the channel index databases = None if dbc_folder and os.path.exists(dbc_folder): dbc_files = [os.path.join(dbc_folder, f) for f in os.listdir(dbc_folder) if f.endswith('.dbc')] if dbc_files: # Assigning all DBCs to CAN channel 1 as an example databases = 'CAN': [(dbc, 0) for dbc in dbc_files] print(f"Found len(dbc_files) DBC files for decoding.") # Perform the conversion mdf_converted = MDF.convert(blf_path, databases=databases) # Save as MF4 mdf_converted.save(output_path, overwrite=True) print(f"Conversion successful! Saved to: output_path") except Exception as e: print(f"Error during conversion: e") # Example Usage if __name__ == "__main__": blf_file = "raw_log_2026.blf" mf4_file = "decoded_log_2026.mf4" dbc_dir = "./databases" convert_blf_to_mf4(blf_file, mf4_file, dbc_folder=dbc_dir) Use code with caution. Why this works well:
Download asammdf ( pip install asammdf[gui] ) → run asammdf → drag & drop BLF → File → Convert → MF4.
For modern workflows involving CI/CD pipelines or batch processing thousands of logs, manual conversion is inefficient. The industry is moving toward Python automation.
BLF files can capture relative time, absolute time, or hardware timestamps from specific logging devices (e.g., VN1640, GL2000). When converting to MF4, check your tool's timebase configuration settings. Misconfigured conversion utilities can shift timestamps or lose nanosecond resolution, causing alignment problems when matching the data against external video or GPS logs. 3. Extremely Large Files
# Add as signals to MDF – requires custom group/channel creation # For simplicity, use the command line tool (see below)