PHP code example of plutuss / getid3-laravel

1. Go to this page and download the library: Download plutuss/getid3-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

plutuss / getid3-laravel example snippets




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();
  
    }
  
}



     $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);


    
    $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')



  $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;


    $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