ffmpeg - 使用FFMPEG gpu python从视频中读取帧

标签 ffmpeg python-3.6

import os
import subprocess

class FFMPEGFrames:
    def __init__(self, output):
        self.output = output

    def extract_frames(self, input, fps):
        output = input.split('/')[-1].split('.')[0]

        if not os.path.exists(self.output + output):
            os.makedirs(self.output + output)

        query = "ffmpeg -y -hwaccel cuvid -c:v h264_cuvid -resize 1024x70 -i " + input + " -vf scale_npp=format=yuv420p,hwdownload,format=yuv420p -vf fps=" + str(fps) + " -pix_fmt yuvj420p -color_range 2 -vframes 1 -y " + self.output + output + "/output%06d.jpg"
        response = subprocess.Popen(query, shell=True, stdout=subprocess.PIPE).stdout.read()
        s = str(response).encode('utf-8')

我收到了这个错误:

Impossible to convert between the formats supported by the filter 'Parsed_fps_0' and the filter 'auto_scaler_0'

Error reinitializing filters!

Failed to inject frame into filter network: Function not implemented

Error while processing the decoded data for stream #0:0

Conversion failed!

最佳答案

您可能错过了一条错误消息:

Only '-vf fps' read, ignoring remaining -vf options: Use ',' to separate filters

结合你的-vf合而为一。另外,考虑替换-pix_fmt yuvj420p使用格式过滤器,因此所有过滤都可以在一个过滤器图中,您可以准确选择过滤器图中出现的位置。

关于ffmpeg - 使用FFMPEG gpu python从视频中读取帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59307933/

相关文章:

ffmpeg 静音音频

python-3.x - 如何使用帧单元制作 TIME 字幕(.srt、.smi 等)

c - 流搜索顺序对 ffmpeg av_seek_frame() 有影响吗?

pandas - 根据 pandas 中另一列的值创建新列

ffmpeg - 我们指定使用 ffmpeg 的 Mozilla、MacOS 和 Safari 版本有什么区别?

ffmpeg - 如何使用 ffmpeg 将一组 PPM 文件转换为单个 .mp4 视频

python - aws Sagemaker 的 AnnotationConsolidation lambda 事件的空字典

python - django-cors-headers 不适用于 DRF(Django Rest Framework)

python - CI 中的 datetime.strptime 失败

python - Python3.x RuntimeError:事件循环已关闭