【问题标题】:django-videothumbs and "list index out of range" errordjango-videothumbs 和“列表索引超出范围”错误
【发布时间】:2012-05-18 18:02:39
【问题描述】:

我正在使用django-videothumbs 视频字段是:

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

在上传、视频上传但在创建缩略图时出现此错误:

异常值:列表索引超出范围 异常位置:/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

提前致谢

【问题讨论】:

    标签: django video


    【解决方案1】:

    您检查过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)
    

    【讨论】:

    • 不需要检查长度..就像直方图一样:做某事...
    • @Nicolae,我已经编辑了我的问题。 ffmpeg 已安装,但 django 找不到。提前致谢
    • 我不知道 django-videothumbs,我只是注意到你的代码中有一个小错误。我认为你应该把它作为一个单独的问题,因为现在标题和最初的前提完全无关,要么删除这个问题,要么接受一个答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-12
    相关资源
    最近更新 更多