2011-09-25 61 views
1

我有一個動態存檔(我的ftp空間上的文件夾),其中是從網絡攝像頭加載的圖像。現在,我想創建一個簡單的幻燈片或視頻與這些圖像,每次用戶想看它。 沒有任何轉換選項或其他....我需要從相機拍攝的圖像構建一個siple timelapse。如何從PHP中的圖片創建動態視頻/幻燈片

我剛剛嘗試這個http://www.maani.us/xml_slideshow/它工作正常(我可以用PHP構建一個swf腳本的動態XML配置文件),但我不能設置時間過渡小於1秒...並且不是免費的...

任何簡單的解決方案? (也是JavaScript,如果它是更好的...) Thanx!

+0

嘗試搜索術語「JPEG MPEG轉換器」,然後添加「PHP」的名詞了。 – Cups

+0

一些幻燈片效果在下面的鏈接https://github.com/letungit90/ffmpeg_memo – Makio

回答

0

是最好的方式,我發現:簡單快捷

<HTML> 
<HEAD> 
<TITLE>Video</TITLE> 
</HEAD> 
<BODY BGCOLOR="#000000"> 
<img name="foto"> 
<SCRIPT LANGUAGE="JavaScript"> 
var Pic = new Array(); 

Pic[0] = '/images/image1.jpg' 
Pic[1] = '/images/image2.jpg' 
Pic[2] = '/images/image3.jpg' 
//this part in real code is replaced with a PHP script that print image location dinamically 

var t; 
var j = 0; 
var p = Pic.length; 
var preLoad = new Array(); 
for (i = 0; i < p; i++) { 
preLoad[i] = new Image(); 
preLoad[i].src = Pic[i]; 
} 
//all images are loaded on client 
index = 0; 
function update(){ 
if (preLoad[index]!= null){ 
document.images['foto'].src = preLoad[index].src; 
index++; 
setTimeout(update, 1000); 
} 

} 
update(); 

</script> 

</BODY> 
</HTML> 
0

PHP是一個純粹的字符串操作語言

你不能在PHP中創建一個幻燈片。這是服務器端語言。

+0

在回答前請閱讀整個問題...請... – Lork

+0

請寫明智的標題/標籤。 –

2

如果你想最終的結果是一個視頻文件,您可以做一些類似於我將Google Streetview全景圖系列轉換爲immersive time-lapse video時所做的操作。

這一切都完成在服務器上使用PHP & ffmpeg。以下是從original source中減去的一些示例代碼。

ffmpeg的命令:

$makeMovieFfmpeg = "ffmpeg -r 4 -f image2 -i dir/%d.jpg -s 800x600 -r 15 -s 800x600 -b 1500kbs myvideo.avi 2>&1"; 

說明:

-r 4 //input framerate of 4fps 
-f image2 //invoke the image2 file demuxer since we're working with a series of images 
-i //location of image files with applied pattern where %d represents numeric sequence 
-s //input image size 
-r //output framerate of 15fps 
-s //output video size 
-b //set the bitrate 
2>&1 //redirects stderr to stdout in order to make output available to PHP 

執行命令:

print_r (exec($makeMovieFfmpeg,$ret,$err)); 
0

ffmpeg的是你的最佳解決方案。 https://www.ffmpeg.org/download.html

快速的方法來創建圖像幻燈片運行以下命令

ffmpeg -framerate 20 \ 
-loop 1 -t 0.5 -i 1.jpg \ 
-loop 1 -t 0.5 -i 2.jpg \ 
-loop 1 -t 0.5 -i 3.jpg \ 
-loop 1 -t 0.5 -i 4.jpg \ 
-c:v libx264 \ 
-filter_complex " \ 
[1:v][0:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b1v]; \ 
[2:v][1:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b2v]; \ 
[3:v][2:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b3v]; \ 
[0:v][b1v][1:v][b2v][2:v][b3v][3:v]concat=n=7:v=1:a=0,format=yuv420p[v]" -map "[v]" out.mp4 

它會創建一個混合效果的幻燈片。

您可以檢查以下備忘錄等效果https://github.com/letungit90/ffmpeg_memo