abhivachan's avatar

Get uploaded video Duration and dimension

Get uploaded video Duration and dimension.

In my site, users will upload the videos, images. If the users upload the video, I would like to find the play duration, size and dimension. I am planning to use the http://www.getid3.org/ library. I would like to know the best way to incorporate this library with laravel framework. Please help me.

0 likes
11 replies
abhivachan's avatar

Thank you. Just adding the entry in the composer.json is enough or I have to follow other steps for laravel specific.

ohffs's avatar

If you just add it via composer then you should be good to go.

1 like
abhivachan's avatar

Hi

I have followed the instruction and updated the composer.json and run the composer.update. Now I can see the folder php-ffmpeg in vendor directory. I am getting FFMpeg not found error. I am using laravel 5.3 and homestead. Do I need to add any path to find FFMpeg in laravel configuration. Please help.

// Upload files $output = $this->_upload($request, 'file', '/files/'); $ffmpeg = FFMpeg::create(); if(file_exists($output)) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime_type = finfo_file($finfo, $output); finfo_close($finfo); if (preg_match('/video/*/', $mime_type)) { $video_attributes = _get_video_attributes($output, $ffmpeg_path); return $video_attributes['hours'] . ':' . $video_attributes['mins'] . ':' . $video_attributes['secs'] . '.' . $video_attributes['ms']; } }

abhivachan's avatar

When I add the line use FFMpeg\FFMpeg; in the controller, I am getting Unload to load FFProbe on this line $ffmpeg = FFMpeg::create();

ohffs's avatar

You'll have to install ffmpeg on your homestead box - try apt-get install ffmpeg inside the VM and see how you get on :-)

1 like
abhivachan's avatar

Yes I have installed it and it looks like I have to specify the location

$ffmpeg = FFMpeg::create([ 'ffmpeg.binaries' => '/usr/bin/ffmpeg', 'ffprobe.binaries' => '/usr/bin/ffprobe' ]);

ohffs's avatar

Ah! I'd assumed it would try and find them by itself - live and learn! Hope it works ok now :-)

abhivachan's avatar

Finally everything works fine. Thank you very much for your help.

1 like
ohffs's avatar

Yay! :-) Always glad to hear something works! Hope your project works out! :-)

Please or to participate in this conversation.