Media Converter Screenshot - Setting to % duration instead of # of seconds

filegasm

Member
YetiShare User
YetiShare Supporter
Jul 1, 2015
34
0
6
Like the title says, I'd like to know of a way to configure the Media Converter Plugin to get the screenshot based from the percentage of the video's total duration (e.g. 50%), instead of having an absolute number of seconds (e.g. 15 seconds).

Is there a way for the convert.php to read and know the the video's total duration with/without encoding it

define("SCREENSHOT_SECONDS", '24'); <--- change this to percentage of video duration instead
define("SCREENSHOT_ONLY", true); <--- no conversion of video/audio to happen
 

paypal1352

New Member
YetiShare User
Wurlie User
Mar 2, 2012
297
2
0
i think this will work

$file=$(ffmpeg -i $localFile 2>&1)
$duration="${ff#*Duration: }"

and do whatever you want with $duration, divide by 2 and you should have your 50%
 

filegasm

Member
YetiShare User
YetiShare Supporter
Jul 1, 2015
34
0
6
paypal1352 said:
i think this will work

$file=$(ffmpeg -i $localFile 2>&1)
$duration="${ff#*Duration: }"

and do whatever you want with $duration, divide by 2 and you should have your 50%
I don't get it. Can you please elaborate that code above and what each variable does/represents? I'm thinking about knowing how to make ffmpeg output the total video duration by seconds into a variable so I can substitute it to the 'define' function.

define("SCREENSHOT_SECONDS", $duration );

And I want to know if that code above would actually worked on your site, since I don't want to test it in the live site without being sure.
 

paypal1352

New Member
YetiShare User
Wurlie User
Mar 2, 2012
297
2
0
I'm not gonna have time to test this anytime soon unfortunately, but as far as I can tell it should work, i got the code from stackoverflow

ffmpeg -i $localFile 2>&1

this gets a whole bunch of info on the file with path stored in $localFile
and $duration="${ff#*Duration: }" isolates the duration, which is what you're looking for,

i believe this will give you a format like this for ex 01:50:04 or something like that, so you'd have to take that variable and divide it by 2 (not literally), i'm not well versed enough in php to tell you how to divide time, but i know theres a whole bunch of ways to do it.