1

I'm trying to know the size more accurately converted video using ffmpeg, I'm getting the actual size of the original video and output video and dividing the size of 2, the logic when I get the size of another video will multiply the value to know the result.

the purpose of this is because I want to make a progress bar using php and ajax, so by my logic would be.

<?
$total = $select_result;// total original file
$video = 'test.mp4';


//loop ajax
$getID3 = new getID3;
$file = $getID3->analyze($video);
$current = $file['filesize'];


$a = $total / $current;
$b = $a * 100;
print number_format($b,0).'%';
?>

ffmpeg command will always be this

exec("ffmpeg -i $video -ar 22050 -ab 32 -f mp4 -s 320x240 teste1.mp4")

but by my logic does not work, each video is a different value, it is possible to do this calculation?

Niels Keurentjes
  • 41,402
  • 9
  • 98
  • 136
moderadorkl25
  • 213
  • 1
  • 2
  • 10
  • 1
    would it work to call `filesize("teste1.mp4");` to get the resultant file size? – Orangepill May 28 '13 at 03:50
  • By default, depending on your ffmpeg configuration, ffmpeg will use libx264 with CRF rate control method for MP4 container. Output file size will be unknown until end of encode. – llogan May 28 '13 at 17:34

1 Answers1

0

If the resulting file size differs from the original, then I recommend the following:

  • Find the average ratio by converting a couple of files and get the average ratio between new and old file size.

  • Estimate the new file size by multiplying the current size with the ratio before making the percent calculaton.

  • If the percentage calculation gives a value >100% then use 100%.

For psychological reasons you may want to use a scale factor closer to the maximum factor than the average. Your program will feel faster if it completes before 100% than if it goes to 100% and then stays there for a while.

Klas Lindbäck
  • 33,105
  • 5
  • 57
  • 82