plutuss/getid3-laravel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

plutuss/getid3-laravel

Composer 安装命令:

composer require plutuss/getid3-laravel

包简介

A wrapper around james-heinrich/getid3 to extract various information from media files.

README 文档

README

Laravel:

Note

The getID3 package, developed by James Heinrich, is a powerful tool for analyzing metadata of audio and video files. Here are some of its capabilities:

  1. Metadata Extraction: getID3 can extract various types of metadata from multimedia files, including information about format, codec, duration, bitrate, sample rate, and much more.
  2. Support for Various Formats: The package supports a wide range of audio and video formats, including MP3, WAV, FLAC, OGG, AAC, WMA, AVI, MPEG, QuickTime, and many others.
  3. Tag Processing: It is also capable of analyzing and extracting information from metadata tags, such as ID3 tags for MP3 files or similar tags for other formats.
  4. Character Encoding Detection: getID3 can automatically detect the text encoding used in metadata, allowing for proper handling of different languages and special characters.
  5. Stream Information Retrieval: This package can analyze the structure of multimedia files and provide information about the audio and video streams contained within them.
  6. Flexibility and Customization: getID3 provides various options and settings for users, allowing them to customize its behavior according to the specific needs and requirements of their projects.

Note

These capabilities make the getID3 package a valuable tool for developers working with multimedia files, as well as for creating applications that require analysis and processing of audio and video data.

 composer require plutuss/getid3-laravel
php artisan vendor:publish --provider="Plutuss\Providers\GetId3ServiceProvider"

Use Facade MediaAnalyzer

  • uploadFile()
  • fromLocalFile()
  • fromUrl()
<?php

use Plutuss\Facades\MediaAnalyzer;
use Illuminate\Http\Request;

class MediaAnalyzerController extends Controller
{
    public function index(Request $request)
    {
    
    // To add a file locally it must be in storage.
    // So that the Storage facade can read it.
    // The default disk value is taken from the .env file FILESYSTEM_DISK
      $media = MediaAnalyzer::fromLocalFile('/video.mov');
      
      $media->getAllInfo();  

          // OR
      $media = MediaAnalyzer::fromLocalFile(
             path: 'files/video.mov',
             disk: 'public',  // "local", "ftp", "sftp", "s3"
         );
         
      $media->getAllInfo();  
         
         
         // Request file
      $media = MediaAnalyzer::uploadFile($request->file('video'));
      
      $media->getAllInfo();
  
    }
  
}
  • Easy to use: Just pass a URL and get structured metadata
  • Supports multiple media types: Images, videos, and audio files
     $url = 'https://www.example.com/filename.mp3';
     
     $media = MediaAnalyzer::fromUrl($url)
     
     $media->getAllInfo(); 
     
     // or
     $media->getNestedValue('array.key')  
    $url = 'https://www.example.com/filename.mp3';
    
    // The methods only works on the file by reference
    // setFilePath()
    // setFileName()
    
    MediaAnalyzer::saveFileFromUrl(true) // Default false, if you want to save the file using the link
            ->setDisk('public')          // You specify which disk
            ->setFilePath('music/')     // You specify which path for the file
            ->setFileName('filename')         // You specify what name for the file
            ->fromUrl($url);
  • List of available methods
    
    $media = MediaAnalyzer::uploadFile($request->file('video'))
    
    $media->getAllInfo();
    
    $media->getDuration();
    
    $media->comments();
    
    $media->getResolution();
    
    $media->getImage();
    
    $media->getTitle();
    
    $media->getAlbum();
    
    $media->getPlaytime();
    
    $media->getGenres();
    
    $media->getArtist();
    
    $media->getComposer();
    
    $media->getTrackNumber();
    
    $media->getCopyrightInfo();
    
    $media->getFileFormat();
    
    $media->getNestedValue('array.key')
  • You can also refer to the property
  $media = MediaAnalyzer::uploadFile($request->file('video'))
  
      "video" => array:11 [▶]
      "warning" => array:5 [▶]
      "comments" => array:1 [▶]
      "encoding" => "UTF-8"
      "mime_type" => "video/quicktime"
      "quicktime" => array:11 [▶]
      "playtime_seconds" => 9.56
      "bitrate" => 50294133.891213
      "playtime_string" => "0:10"

    $media->video;
    
    $media->playtime_seconds;
    
    $media->playtime_string;
    
    $media->mime_type;
  • The getNestedValue() method retrieves a value from a deeply nested array using "dot" notation
    $media = MediaAnalyzer::uploadFile($request->file('video'))

          "avdataoffset" => 48
          "avdataend" => 60101538
          "fileformat" => "quicktime"
          "video" => array:11 [▼
            "dataformat" => "quicktime"
            "resolution_x" => 1920.0
            "resolution_y" => 1080.0
            "codec" => "H.264"
            "bits_per_sample" => 24
            "frame_rate" => 25.0
            "bitrate" => 50294133.891213
            "compression_ratio" => 0.040424168829743
          ]
          "warning" => array:5 [▶]
          "comments" => array:1 [▶]


    $media->getNestedValue('video.codec')  // H.264
    $media->getNestedValue('video.resolution_x')   //  1920.0

plutuss/getid3-laravel 适用场景与选型建议

plutuss/getid3-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.21k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2024 年 04 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「audio」 「video」 「laravel」 「mp3」 「getid3」 「mp4」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 plutuss/getid3-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 plutuss/getid3-laravel 我们能提供哪些服务?
定制开发 / 二次开发

基于 plutuss/getid3-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.21k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-30