PHP and Flash movies

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • LL2000

    PHP and Flash movies

    Hello!

    I'd like to allow users to upload Flash movies to my website and have
    them displayed in a page.

    There are certain things that I either need in order to display them
    correctly, such as the version of Flash, the width/height of the movie, etc.

    Does anyone know if there is any existing code available to do this?
    Ideally, I would like to not ask for -anything- from the user, except
    for the actual Flash movie.

    Thanks for your help!
  • Chung Leong

    #2
    Re: PHP and Flash movies


    "LL2000" <liquidN0SPAMla ughter2000@yaho o.co.uk> wrote in message
    news:rhZZd.6894 6$ug2.45137@fe2 .news.blueyonde r.co.uk...[color=blue]
    > Hello!
    >
    > I'd like to allow users to upload Flash movies to my website and have
    > them displayed in a page.
    >
    > There are certain things that I either need in order to display them
    > correctly, such as the version of Flash, the width/height of the movie,[/color]
    etc.[color=blue]
    >
    > Does anyone know if there is any existing code available to do this?
    > Ideally, I would like to not ask for -anything- from the user, except
    > for the actual Flash movie.
    >
    > Thanks for your help![/color]

    Here's something I wrote. Not terribly efficient or well written but works.

    function ExtractSWFInfo( $path) {
    // read the data
    $data = file_get_conten ts($path);

    // signature
    $sign = substr($data, 0, 3);
    if($sign == 'CWS' || $sign == 'FWS') {

    $compressed = ($sign{0} == 'C');
    $version = ord($data{3});

    // file length
    extract(unpack( 'Vlength', substr($data, 4, 4)));

    $data = substr($data, 8);
    if($compressed) {
    $data = gzuncompress($d ata);
    }

    // frame coordinates, first 5 bit is the number of bit per coord
    $b = ord($data{0});
    $nb = $b >> 3;
    $bin = decbin($b & 0x07);
    $bits = substr('000', 0, - strlen($bin)); // 0-padded
    $bits .= $bin;

    // read the bits
    $index = 1;
    for($bits_requi red = $nb * 4; $bits_required > 0; $bits_required -= 8) {
    $bin = decbin(ord($dat a{$index++}));
    $bits .= substr('0000000 0', 0, - strlen($bin));
    $bits .= $bin;
    }

    // cut bitstring into four parts
    $coord_bits = array();
    for($i = 0, $j = 0; $i < 4; $i++, $j += $nb) {
    $coord_bits[$i] = substr($bits, $j, $nb);
    }

    // convert from bin to integer
    $coord = array();
    for($i = 0; $i < 4; $i++) {
    $num = bindec(substr($ coord_bits[$i], 1));
    if(substr($coor d_bits[$i], 0, 1) == '1') {
    $num = -$num;
    }
    $coord[$i] = $num;
    }

    // get the dimension in pixels
    $width = round($coord[1] / 20);
    $height = round($coord[3] / 20);

    // frame rate and count
    extract(unpack( 'Cframerate_dec im/Cframerate/vframecount', substr($data,
    $index, 4)));

    return compact('compre ssed', 'length', 'version', 'width', 'height',
    'framerate', 'framecount');
    }
    return false;
    }

    $file = "C:/Documents and Settings/cleong/Desktop/cow_test.swf";

    var_dump(Extrac tSWFInfo($file) );




    Comment

    • LL2000

      #3
      Re: PHP and Flash movies

      Chung Leong wrote:[color=blue]
      > "LL2000" <liquidN0SPAMla ughter2000@yaho o.co.uk> wrote in message
      > news:rhZZd.6894 6$ug2.45137@fe2 .news.blueyonde r.co.uk...
      >[color=green]
      >>Hello!
      >>
      >>I'd like to allow users to upload Flash movies to my website and have
      >>them displayed in a page.
      >>
      >>There are certain things that I either need in order to display them
      >>correctly, such as the version of Flash, the width/height of the movie,[/color]
      >
      > etc.
      >[color=green]
      >>Does anyone know if there is any existing code available to do this?
      >>Ideally, I would like to not ask for -anything- from the user, except
      >>for the actual Flash movie.
      >>
      >>Thanks for your help![/color]
      >
      >
      > Here's something I wrote. Not terribly efficient or well written but works.[/color]
      <snip>

      Thank you very much. That's perfect. You've saved me hours of work and
      restored my belief in newsgroups :)

      LL.

      Comment

      Working...