Metadata-Version: 2.4
Name: mp4analyzer
Version: 1.1.2
Summary: Lightweight MP4 box analyzer
Author-email: Andrew Xin <andrewx@bu.edu>
License: MIT License
        
        Copyright (c) 2025 Andrew Xin
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Multimedia :: Video
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: gui
Requires-Dist: PyQt6>=6.9; extra == "gui"
Requires-Dist: pillow>=11.3; extra == "gui"
Provides-Extra: dev
Requires-Dist: ruff>=0.12; extra == "dev"
Requires-Dist: black>=25.1; extra == "dev"
Requires-Dist: pytest>=8.4; extra == "dev"
Requires-Dist: pyinstaller>=6.15; extra == "dev"
Requires-Dist: PyQt6>=6.9; extra == "dev"
Requires-Dist: pillow>=11.3; extra == "dev"
Dynamic: license-file

# MP4 Analyzer
![CI](https://github.com/andrewx-bu/mp4analyzer/actions/workflows/ci.yml/badge.svg)
![Release](https://github.com/andrewx-bu/mp4analyzer/actions/workflows/release.yml/badge.svg)
![PyPI - Version](https://img.shields.io/pypi/v/mp4analyzer?label=PyPI&color=blue "https://pypi.org/project/mp4analyzer/")
![Code style: black](https://img.shields.io/badge/code%20style-black-black "https://github.com/psf/black")
![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg "https://opensource.org/licenses/MIT")

Tool for analyzing MP4 files, providing both command-line box parsing and GUI-based frame-level analysis.

| CLI | GUI |
| --- | --- |
| <img src="https://github.com/andrewx-bu/mp4analyzer/blob/main/images/cli.png?raw=true" width="400" alt="CLI"> | <img src="https://github.com/andrewx-bu/mp4analyzer/blob/main/images/gui.png?raw=true" width="800" alt="GUI"> |

## Features

### CLI Tool
- Parse and display MP4 box structure
- Extract metadata and technical information (e.g. duration, bitrate, codec info, track details)
- Supports output to JSON. No external dependencies needed

### GUI Application
- Frame-by-frame video analysis with timeline visualization
- Per-frame details: type (I/P/B), byte size, timestamp, and decode vs presentation order
- Requires FFmpeg for video decoding

## Installation and Usage

### CLI Tool
```bash
pip install mp4analyzer
```

### CLI Help
```
usage: mp4analyzer [-h] [-o {stdout,json}] [-d] [-s] [-e] [-c | --no-color] [-j JSON_PATH] file

Analyze MP4 files and display metadata information

positional arguments:
  file                  MP4 file to analyze

options:
  -h, --help            show this help message and exit
  -o {stdout,json}, --output {stdout,json}
                        Output format (default: stdout)
  -d, --detailed        Show detailed box properties and internal fields
  -s, --summary         Show concise summary instead of full analysis
  -e, --expand          Expand all arrays and large data structures
  -c, --color           Enable colored output (default: True)
      --no-color        Disable colored output
  -j JSON_PATH, --json-path JSON_PATH
                        Path to save JSON output. If specified, JSON will be saved even if
                        output format is not json.

Examples:
  mp4analyzer video.mp4                    # Basic analysis with color
  mp4analyzer -d video.mp4                 # Detailed view with box properties
  mp4analyzer -s video.mp4                 # Quick summary
  mp4analyzer -e -d video.mp4              # Expand arrays/matrices in details
  mp4analyzer --no-color video.mp4         # Disable ANSI colors
  mp4analyzer -o json video.mp4            # JSON to stdout
  mp4analyzer -j output.json video.mp4     # Save JSON to file (in addition to stdout)
```

### GUI Application
Download and run the executable from GitHub [Releases](https://github.com/andrewx-bu/mp4analyzer/releases). The application will not run without FFmpeg.

## Supported MP4 Boxes
Currently parsed box types: `ftyp`, `moov`, `mvhd`, `trak`, `tkhd`, `mdhd`, `iods`, `edts`, `elst`, `hdlr`, `minf`, `vmhd`, `smhd`, `dinf`, `dref`, `url `, `stbl`, `stsd`, `avc1`, `avcC`, `colr`, `pasp`, `mp4a`, `esds`, `mdat`, `free`, `stts`, `ctts`, `stss`, `sdtp`, `stsc`, `stsz`, `stco`, `sgpd`, `sbgp`

## Development
```bash
# Setup
uv sync --extra dev

# Run tests
uv run pytest

# Build GUI app
uv run python build_exe.py

# Build CLI package
uv build
```

### Built With
![Technologies](https://go-skill-icons.vercel.app/api/icons?i=python,qt,ffmpeg,pytest,githubactions,&perline=5&theme=dark)
