ffmpeg Error: Pattern type 'glob' was selected but globbing is not support ed by this libavformat build

ffmpeg Error: Pattern type 'glob' was selected but globbing is not support ed by this libavformat build

我正在尝试将作为单个帧的“.jpg”文件组转换为 1 个 mpeg 视频“.mp4”

我使用的示例参数:

frame duration  = 2 secs
frame rate      = 30  fps
encoder         = libx264 (mpeg)
input pattern   = "*.jpg"
output pattern  = video.mp4

根据 (https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images) 处的 ffmpeg wiki 说明,我发出了这个命令:

ffmpeg -framerate 1/2 -pattern_type glob -i "*.jpg" -c:v libx264 -r 30 -pix_fmt yuv420p video.mp4

但是我收到了这个错误:

[image2 @ 049ab120] Pattern type 'glob' was selected but globbing is not 
supported by this libavformat build *.jpg: Function not implemented

这可能意味着我的 build/version 的 API 模式匹配命令已更改。顺便说一句,这是我的 windows 32 位 ffmpeg 下载版本 (ffmpeg-20150702-git-03b2b40-win32-static)。

如何使用 ffmpeg 使用模式匹配来选择一组文件?

-pattern_type glob requires glob.h.

glob 在 POSIX 标准中定义,默认在 Windows 上不可用。

Create/rename 您的文件使用顺序文件命名 image###.jpg 然后使用顺序通配符如 -i image%03d.jpg 作为输入。

你可以在Python写一个脚本,支持Windows的glob模块:

import subprocess
import glob
import os

filenames = glob.glob('*.png')
path = os.path.abspath("").replace("\", "/")
print(path)
duration = 0.05

with open("ffmpeg_input.txt", "wb") as outfile:
    for filename in filenames:
        outfile.write(f"file '{path}/{filename}'\n".encode())
        outfile.write(f"duration {duration}\n".encode())

command_line = f"ffmpeg -r 60 -f concat -safe 0 -i ffmpeg_input.txt -c:v libx265 -pix_fmt yuv420p {path}\out.mp4"
print(command_line)

pipe = subprocess.Popen(command_line, shell=True, stdout=subprocess.PIPE).stdout
output = pipe.read().decode()
pipe.close()