Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Okay, I've found what I needed - and hopefully this helps someone else as well!</p> <p><strong>First and foremost, you want to output the ffmpeg data to a text file on the server.</strong> </p> <pre><code>ffmpeg -i path/to/input.mov -vcodec videocodec -acodec audiocodec path/to/output.flv 1&gt; block.txt 2&gt;&amp;1 </code></pre> <p><strong>So, the ffmpeg output is block.txt. Now in PHP, let's do this!</strong></p> <pre><code>$content = @file_get_contents('../block.txt'); if($content){ //get duration of source preg_match("/Duration: (.*?), start:/", $content, $matches); $rawDuration = $matches[1]; //rawDuration is in 00:00:00.00 format. This converts it to seconds. $ar = array_reverse(explode(":", $rawDuration)); $duration = floatval($ar[0]); if (!empty($ar[1])) $duration += intval($ar[1]) * 60; if (!empty($ar[2])) $duration += intval($ar[2]) * 60 * 60; //get the time in the file that is already encoded preg_match_all("/time=(.*?) bitrate/", $content, $matches); $rawTime = array_pop($matches); //this is needed if there is more than one match if (is_array($rawTime)){$rawTime = array_pop($rawTime);} //rawTime is in 00:00:00.00 format. This converts it to seconds. $ar = array_reverse(explode(":", $rawTime)); $time = floatval($ar[0]); if (!empty($ar[1])) $time += intval($ar[1]) * 60; if (!empty($ar[2])) $time += intval($ar[2]) * 60 * 60; //calculate the progress $progress = round(($time/$duration) * 100); echo "Duration: " . $duration . "&lt;br&gt;"; echo "Current Time: " . $time . "&lt;br&gt;"; echo "Progress: " . $progress . "%"; } </code></pre> <p>This outputs the percentage of time left.</p> <p>You can have this as the only piece of text echoed out to a page, and from another page you can perform an AJAX request using jQuery to grab this piece of text and output it into a div, for example, to update on your page every 10 seconds. :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload