使用ming从png图像创建一个flv视频

时间:2011-12-14 10:41:54

标签: php flash flv libming

我正在尝试从几个png生成一个flv视频,但输出视频似乎已损坏,没有播放器可以播放它。

<?php
$video = new SWFMovie();
$video->setDimension(640, 360);

$img = new SWFShape();
$png = fopen("/home/damiano/a.dbl", "rb");
$img->addFill(new SWFBitmap($png));
fclose($png);

$video->add($img);

header('Content-type: application/x-shockwave-flash');
$video->output();
?>

浏览器不显示任何内容(甚至几毫秒),也不显示vlc播放器和其他内容。要抓取视频到文件我使用:

curl 'http://localhost/ming.php' > vid.flv

导入png有什么问题?为什么我不能看视频?我错过了什么?

1 个答案:

答案 0 :(得分:0)

我使用过此代码。

       //Muse addition below   - creates flv and thumbnail of file and uploads it           
            $target_file_name = replaceexts($new_file_name,"flv");              
            $flvtarget ="$imagedir".$target_file_name;
            //echo substr(sprintf('%o', fileperms('../3/uploades/video')), -4);
        //    @chmod($configfile, 0777);
         //   //echo "../3/uploades/video/".$new_file_name;
            //$permission = is_writeable($configfile);
            move_uploaded_file($_FILES['myfile']['tmp_name'], "../3/uploades/video/".$new_file_name);
          //   @chmod($configfile, 0777); 
            $imgtarget ="$imagedir".replaceexts($new_file_name,"jpg");           
            //video
        //Original:
                  // $cmd = "/usr/bin/ffmpeg -v 0 -i $upload_path -acodec pcm_s16le -s 320x240 -b 512k -ab 128k -ar 44100 -bt 40000k $flvtarget"; 
        //Options Meaning:
        // Input file options
        //  -v 0 -- Logging verbosity level -- I guess 0 means - "Silent"

        // Output file options:
        // -acodec pcm_s16le: force audio codec to the selected (pcm_s16le)  -- WHy?
        // -s 320x320 -- frame size
        // -b 512k -- video bit rate
        // -ab 128k -- audio bitrate

        //Added:

        // -ar 44100 -- set the audio sampling frequency.  Default is 44100.  So shouldn't be necessary to add this option, but apparently is necessary, to force it.


            //exec($cmd);

            //video
    //       $cmd = "/usr/bin/ffmpeg -v 0 -i $upload_path -acodec pcm_s16le -s 320x240 -b 512k -ab 128k $flvtarget";
     //   $cmd = "/usr/bin/ffmpeg -v 0 -i $upload_path -acodec pcm_s16le -s vga -b 512k -ab 128k  -aspect 4:3 -target flv $flvtarget";                   



     $cmd = "/usr/bin/ffmpeg -i $upload_path -s 320x240 -b 512k -ab 128k -acodec libmp3lame -ar 22050 -f flv $flvtarget";
            exec($cmd);
            //thumb  
            $cmd = "/usr/bin/ffmpeg -i $upload_path -deinterlace -an -ss 2 -t 00:00:01 -r 1 -y -s 80x60 -vcodec mjpeg -f mjpeg $imgtarget 2>&1";   
            exec($cmd);