2012-05-10 160 views
0

Im爲:Django的videothumbs和使用<a href="https://github.com/macmichael01/django-videothumbs" rel="nofollow">django-videothumbs</a> 視頻領域「列表索引超出範圍」錯誤

video = videothumbs.VideoThumbField(upload_to='videos', sizes=((125,125),(300,200),)) 

在上傳,上傳的視頻,但在創建縮略圖我有這樣的錯誤:

Exception Value: list index out of range Exception Location:/library/videothumbs.py in generate_thumb, line 51

和第51行:

for c in range(len(histogram[0])): 
    ac = 0.0 
    for i in range(n): 
     ac = ac + (float(histogram[i][c])/n) 
     avg.append(ac) 

視頻檔案有什麼問題?

編輯: 與print histogram我:

sh: ffmpeg: command not found 

但在終端:

FFmpeg version CVS, Copyright (c) 2000-2004 Fabrice Bellard 
Mac OSX universal build for ffmpegX 
configuration: --enable-memalign-hack --enable-mp3lame --enable-gpl --disable-vhook -- disable-ffplay --disable-ffserver --enable-a52 --enable-xvid --enable-faac --enable-faad --enable-amr_nb --enable-amr_wb --enable-pthreads --enable-x264 
libavutil version: 49.0.0 
libavcodec version: 51.9.0 
libavformat version: 50.4.0 
built on Apr 15 2006 04:58:19, gcc: 4.0.1 (Apple Computer, Inc. build 5250) 
usage: ffmpeg [[infile options] -i infile]... {[outfile options] outfile}... 
Hyper fast Audio and Video encoder 

在此先感謝

回答

0

你檢查的histogram[0]價值?最有可能histogram沒有任何元素。

我會改變代碼:

if len(histogram) > 0: 
    for c in range(len(histogram[0])): 
    ac = 0.0 
    for i in range(n): 
     ac = ac + (float(histogram[i][c])/n) 
     avg.append(ac) 
+0

不需要檢查長度.. 只是不喜歡它 如果直方圖: 做某事 –

+0

@Nicolae,我已經編輯我的問題。已安裝ffmpeg,但django無法找到。在此先感謝 – TheNone

+0

我沒有Django的videothumbs的知識,我只是注意到,小錯在你的代碼。在我看來,你應該只是做它作爲一個單獨的問題,因爲現在的標題和最初的前提是完全無關的,並刪除了這個問題,或者接受一個答案。 –

相關問題