How to Get Video Details Including Orientation Duration Using FFMPEG

Oct 20th, 2015

How to Get Video Details Including Orientation Duration Using FFMPEG
Here I am going to get details related to FFMPEG including orientation, duration.

Step to get details related to FFMPEGincluding orientation, duration.

1. Get Video duration:

$ffmpeg_path = “/usr/bin/ffmpeg”; //Path to your FFMPEG

$video_path = “/vidoes/myvideo.mov”; // Path to your Video
$command = $ffmpeg_path . ‘ -i “‘ . $video_path . ‘” -vstats 2>&1’;
$output = shell_exec($command);
$regex_duration = “/Duration: ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}).([0-9]{1,2})/”;
if (preg_match($regex_duration, $output, $regs)) {
$hours = $regs [1] ? $regs [1] : null;
$mins = $regs [2] ? $regs [2] : null;
$secs = $regs [3] ? $regs [3] : null;
}
$video_Length = $hours . “:” . $mins . “:” . $secs;

 

2. Get Video thumbnail:

$save_video_thumbnail = ‘thumbnails/myvideo_thumbnail’;

$cmd = “$ffmpeg_path -i $video_path -ss 00:00:03 -s 404×694 -vframes 1 $save_video_thumbnail”;

$output = shell_exec($command);

Notes: In Above 00:00:03 is duration when thumbnail is generated. We can set this as per requirement.

3. Get Video Orientation:

$ffmpeg_path = “/usr/bin/ffmpeg”; //Path to your FFMPEG
$video_path = “/vidoes/myvideo.mov”; // Path to your Video

$command = $ffmpeg_path . ‘ -i “‘ . $video_path . ‘” -vstats 2>&1’;
$output = shell_exec($command);
$out_arr = explode(“n”, $output);
foreach($out_arr as $line) {
if( preg_match(‘/^Stream.*Video:/’, trim($line)) ) {
/* match line: Stream #0.0(und): Video: h264 (High), yuv420p, 640×360 [PAR 1:1 DAR 16:9], 597 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc */
$line_arr = explode(‘,’, $line);
// get field: 640×360 [PAR 1:1 DAR 16:9]
$target_arr = explode(‘ ‘, $line_arr[3]);
// get parts: 640×360
$dims = explode(‘x’, $target_arr[1]);
$res_x = $dims[0];
$res_y = $dims[1];
}
}
$orientation = (intval($res_x) > intval($res_y)) ? ‘Portrait’ :’Landscape’;
You can drop message for any questions or feedback. Will get back to you soon.

 

Comments are closed.

Let's Discuss Your Project

Get free consultation and let us know your project idea to turn
it into an amazing digital product.

Let’s talk

NEWS & BLOG

Related Blogs

Why should you hire React Native developers for your project?

Hire Developer Jun 19th, 2023

Why should you hire React Native developers for your pr...

Read more
Seven Wearable App Technology Trends to Watch Out for in 2022

Hire Developer Dec 28th, 2020

Seven Wearable App Technology Trends to Watch Out for i...

Read more
How On-demand Grocery Delivery App Benefits Your Store and Expands Business

Hire Developer Jun 9th, 2020

How On-demand Grocery Delivery App Benefits Your Store ...

Read more

INQUIRY

Let's get in touch

UNITED STATES

31236 Meadowview Square,
Delmar, DE 19940, USA

Sales: +1 667 771 6758

UNITED KINGDOM

13 Layton Road, Hounslow,
London, TW3 1YJ

Sales: +44 7404 607567

INDIA

2nd Floor, Sun Avenue One, Bhudarpura, Ayojan Nagar, Nr. Shyamal Cross Road, Ahmedabad, Gujarat-380006

Sales: +91 635-261-6164

For Project Inquiries

biolah

hariantulis

depo 25 bonus 25

depo 25 bonus 25

mndrmndr.com

bonusdeposit.net

https://www.greentourstanzania.com/wp-includes/customize/

https://temp1.novotest.biz/id/

depo 25 bonus 25

https://sumberjo-blitar.desa.id/images

https://sumberjo-blitar.desa.id/data

depo 25 bonus 25 to 5x

depo 25 bonus 25

https://www.greentourstanzania.com/wp-includes/js/product/

https://smpabbs.sch.id/gacor/100/

https://smpabbs.sch.id/gacor/bonus/

deposit 25 bonus 25

depo 25 bonus 25

bonus new member 100

https://ppdb.smk-kosgoro.sch.id/data/depo 25 bonus 25https://jesus.nouvellevie.com/wp-includes/images/Getoko.iddepo 25 bonus 25https://bonus-baru.s3.ap-southeast-1.amazonaws.com/link-daftar-slot-gacor.htmlhttps://bonus-baru.s3.ap-southeast-1.amazonaws.com/scatter-pink-paling-gacor.htmlhttps://worldlisteningproject.org/wp-includes/depo25bonus25/bonus new member 100