2011-12-14 84 views
3

我想从几个PNG生成一个FLV视频,但输出视频似乎已损坏,没有玩家可以播放它。使用鸣从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有什么不对?为什么我不能观看视频?我错过了什么?

+0

如果使用文本编辑器打开`vid.flv`,包含了什么? – 2011-12-14 10:43:33

回答

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);