mencoder生成空的.avi文件

时间:2011-10-18 06:06:46

标签: python video mencoder

我从python脚本调用mencoder来生成各种.png文件的电影:

import sys, os
command =   ''.join([
            'mplayer\mencoder.exe ',
            'mf://frames/out_*.png ',
            '-mf type=png:w=800:h=600:fps=10 -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o out.avi '
            ])
print "executing", command
os.system(command)

mencoder给了我一个4KB out.avi和这个输出:

    C:\Windows\system32\cmd.exe /c python make_video.py
    executing mplayer\mencoder.exe mf://frames/out_*.png -mf type=png:w=800:h=600:fps=10 -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o out.avi
    MEncoder Sherpya-SVN-r34118-4.2.5 (C) 2000-2011 MPlayer Team
    success: format: 16  data: 0x0 - 0x0
    MF file format detected.
    [mf] search expr: frames/out_*.png
    [mf] number of files: 129 (516)
    VIDEO:  [MPNG]  800x600  24bpp  10.000 fps    0.0 kbps ( 0.0 kbyte/s)
    [V] filefmt:16  fourcc:0x474E504D  size:800x600  fps:10.000  ftime:=0.1000
    Opening video filter: [expand osd=1]
    Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
    ==========================================================================
    Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
    Selected video codec: [ffpng] vfm: ffmpeg (FFmpeg PNG)
    ==========================================================================

    Flushing video frames.
    Filters have not been configured! Empty file?
    Writing index...
    Writing header...
    ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

    Video stream:      nan kbit/s  (-2147483648 B/s)  size: 0 bytes  0.000 secs  0 frames

请帮忙。

1 个答案:

答案 0 :(得分:4)

我想这是一个老线程,但我遇到了同样的问题,所以我想分享我的解决方案以防其他人遇到同一个网页。

当尝试从源文件夹位置外部运行mencoder时,基本上会出现错误。所以要让它工作,只需将CD放入包含源图像的文件夹中,然后从那里运行命令。

或者您可以修改python脚本并添加一行,在运行mencoder之前将当前路径更改为源图像路径。就像是: os.chdir(sourcefolder)#其中sourcefolder是源图像的位置

干杯! -Kevin