Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP and FFMPEG - Performing intelligent video conversion
    primarykey
    data
    text
    <p>I have an oddly difficult task to perform. I thought it would be easy, but all my efforts have been fruitless.</p> <p>I'm converting videos uploaded to a php script from various formats (.avi, .mpg, .wmv, .mov, etc.) to a single .flv format. The conversion is working great but what I'm having trouble with is the resolution of the videos.</p> <p>This is the command I'm currently running (with PHP vars):</p> <p><code>ffmpeg -i $original -ab 96k -b 700k -ar 44100 -s 640x480 -acodec mp3 $converted</code></p> <p>Both $original and $converted contain the full paths to those files. My problem is that this always converts to 640x480 (like I'm telling it to) even when the source is smaller. Obviously, this is a waste of disk space and bandwidth when the video is downloaded. Also, this doesn't account for input videos being in any aspect ratio other than 4:3, resulting in a "squished" conversion if I upload a 16:9 video.</p> <p>There are 3 things I need to do:</p> <ol> <li>Determine the aspect ratio of the original video.</li> <li>If not 4:3, pad top and bottom with black bars.</li> <li>Convert to 640x480 if either dimension of the original is larger or a 4:3 aspect ratio relating to the width/height of the original (whichever is closer to 640x480).</li> </ol> <p>I've run <code>ffmpeg -i</code> on a few videos, but I don't see a consistent format or location to find the original's resolution from. Once I'm able to figure that out, I know I can "do the math" to figure out the right size and specify padding to fix the aspect ratio with -padttop, -padbottom, etc.</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.
 

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