• Pages

  • Categories

  • Recent Comments

  • Meta


  • View G. Jakub Kwaczynski's profile on LinkedIn
    Я в контакте
    Which couch You wanna surf today?



    Recent tracks:




    Media cyfrowe

    3camp.pl - trójmiejski barcamp

    Państwowa Wyższa Szkoła Filmowa, Telewizyjna i Teatralna w Łodzi

    Beuth Hochschule Berlin

    FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video
    SANYO dostarcza najnowszych rozwiązań IP CCTV w jakości HD

    GCC, the GNU Compiler Collection Quicktime Streaming Server

    posted by admin on Apr 3

    During video file conversions in ffmpeg, preservation of aspect ratio may fail. This circumstance created demand to solve this issue in an “automagic” manner.
    Aspect ratio is divided into Display Aspect Ratio as well as Pixel Aspect Ratio. The php class “php-getid3″ analyzes virtually any media file and returns the latter (PAR) as a numeric value, from which one can derive the DAR by means of following equation:

    width / (height * PAR)

    Example:
    You want to process an mpg file made from a DVD sequence. It will most probably (given PAL system) have the dimensions of 720×576 and the PAR=0.7031, which is (Width/Height)*(9/16)=0.7031 for a panorama (DAR=16:9) video.
    ffmpeg _might_ squeeze or squish such a video, giving Your result a DAR of 4:3 located in the header of the file.
    In order to avoid this, include this code in Your php after installing php-getid3, which will return the proper DAR:

    require_once('/usr/share/php-getid3/getid3.php');

    $this->getID3 = new getID3;

    function get_aspect($resolution,$file) {
    $widthheight=explode("x",$resolution);
    $fileinfo = $this->getID3->analyze($file);
    getid3_lib::CopyTagsToComments($fileinfo);
    $par=@$fileinfo['video']['pixel_aspect_ratio'];
    if ($widthheight[0]/($par*$widthheight[1])<=4/3) return "4:3";
    else return "16:9";
    }

    Neat.

    Leave a Reply