Skip to content

JoeldelPilar/vme

Repository files navigation

🎬 vme - Video Metadata Extractor

Go Report Card License: MIT Go Tests Coverage Status

A command-line tool to extract metadata from MP4 video files.

🌟 Features

  • Extract basic, extended, or full metadata from MP4 files.
  • Supports file information, movie information (tags, title, duration), and track information (bitrate, codecs, resolution).
  • Export metadata as JSON or XML files.
  • Upload metadata directly to S3-compatible storage services including AWS S3 and MinIO.
  • Clear and formatted output to the console.

🛠️ Installation

  1. Prerequisites:

    • Go (version 1.22 or later)
    • FFmpeg (with ffprobe available in your system's PATH)
  2. Get the package:

    go install github.com/joeldelpilar/vme@latest

🚀 Usage

vme [flags] <mp4-file>

🔍 Flags

  • -b: Basic metadata (file information only).
  • -e: Extended metadata (file and movie information).
  • -f: Full metadata (file, movie, and track information).
  • -o: Output format (json/xml) - exports metadata to a file instead of console output.

S3 Integration Flags

  • -s3-upload: Enable uploading metadata files to S3 storage.
  • -s3-bucket: S3 bucket name (required when using -s3-upload).
  • -s3-region: AWS region (default: "us-east-1").
  • -s3-endpoint: Custom endpoint URL for S3-compatible services like MinIO.
  • -s3-ssl: Use SSL for S3 connection (default: true, set to false for local development).

🌍 Environment Variables

When using S3 integration, the following environment variables are required:

  • VME_S3_ACCESS_KEY: S3 access key for authentication.
  • VME_S3_SECRET_KEY: S3 secret key for authentication.

🛠️ Make Commands

To enable the installation of the vme command, you can use the following commands:

make build
make install
make clean

Examples

  • Extract basic metadata from local file:

    vme -b video.mp4
  • Extract full metadata from S3/MinIO and save as JSON:

    vme -f -o json s3://my-bucket/video.mp4 \
        -s3-endpoint https://minio.example.com \
        -s3-bucket output-bucket \
        -s3-upload
  • Using MinIO with custom endpoint and SSL disabled:

    # Set required environment variables
    export VME_S3_ACCESS_KEY="your_access_key"
    export VME_S3_SECRET_KEY="your_secret_key"
    
    # Run command
    vme -f \
        -s3-endpoint https://your-minio-server.com \
        -s3-bucket your-bucket \
        -s3-ssl=false \
        -o json \
        -s3-upload \
        s3://input-bucket/path/to/video.mp4

    This will:

    1. Download the video from S3/MinIO
    2. Extract full metadata
    3. Save it as JSON
    4. Upload the metadata file back to the specified bucket

When using the -o flag and not using the -s3-upload flag, the metadata will be exported to a file named <input-filename>-metadata.<format> in the current directory. For example, if your input file is video.mp4 and you use -o json, the output will be saved as video-metadata.json.

Example output

Example output

🧪 Local Testing with Docker

If you want to test the S3 functionality locally without using actual cloud services, you can use MinIO running in Docker.

Setting Up MinIO in Docker

  1. Start MinIO with Docker:

    docker run -p 9000:9000 -p 9001:9001 --name minio \
      -e "MINIO_ROOT_USER=minioadmin" \
      -e "MINIO_ROOT_PASSWORD=minioadmin" \
      bitnami/minio:latest
  2. Access the MinIO web interface at http://localhost:9001 and log in with:

    • Username: minioadmin
    • Password: minioadmin
  3. Create a new bucket (e.g., "test-bucket") through the web interface.

Using vme with Local MinIO

Once MinIO is running, you can use vme to upload metadata to it:

# Set environment variables for authentication
export VME_S3_ACCESS_KEY=minioadmin
export VME_S3_SECRET_KEY=minioadmin

# Extract and upload metadata to local MinIO
vme -f -o json -s3-upload -s3-bucket test-bucket -s3-endpoint http://localhost:9000 -s3-ssl=false video.mp4

This setup is perfect for development and testing of the S3 integration functionality without requiring actual cloud resources.

⚙️ How it Works

The tool uses ffprobe (from the FFmpeg suite) to analyze the MP4 file and extract metadata. The extracted data is then formatted and displayed in the console or exported to a file in the specified format.

When using S3 integration, the tool creates a client to the specified S3 service (AWS S3 or a compatible alternative like MinIO) and uploads the exported metadata file.

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue.

👨‍💻 Author

🙏 Acknowledgments

  • Uses the FFmpeg project for media analysis.
  • Inspired by the need for a simple and effective MP4 metadata extraction tool.

About

Video Metadata Extractor

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published