gpt4 book ai didi

ffmpeg - 无法打开文件 v_YoYo_g07_c04.jpeg av_interleaved_write_frame() : Input/output error

转载 作者:行者123 更新时间:2023-12-04 23:26:06 25 4
gpt4 key购买 nike

以下代码的目的是从视频列表中提取帧。
为此,我在 python 3.5 中定义了extract_frames 函数 调用 extract_frame 函数 .在后者中, ffmpeg 给出了提取帧的指令

def extract_frames(vidlist,vidDir,outputDir):
f = open(vidlist, 'r')
vids = f.readlines()
f.close()
vids = [video.rstrip() for video in vids]
for vid in vids:
videoName = os.path.join(vidDir,vid.split('.')[0]+".avi")
frameName = os.path.join(outputDir, vid.split('.')[0]+".jpeg")
extract_frame(videoName,frameName)
extract_frames(trainlist01, ucf101_path,training_output)

这样:
ucf101_path = "/local/common-data/UCF/UCF-101" # Path to the root dataset
trainlist01="/local/common-data/UCF/ucfTrainTestlist/trainlist01.txt"
training_output = '/local/common-data/UCF/tmp_frames/train/'

在哪里 trainlist01.txt 包含一组如下的行(第一列是视频的路径,第二列是视频的类):

ApplyEyeMakeup/v_ApplyEyeMakeup_g08_c01.avi 1 ......

视频名 框架名 例如对应于:
videoname="/local/common-data/UCF/UCF-101/YoYo/v_YoYo_g07_c04.avi"
framename="/local/common-data/UCF/tmp_frames/test/YoYo/v_YoYo_g07_c04.jpeg"

错误由以下函数返回
import subprocess

def extract_frame(videoName,frameName):

if not os.path.exists(videoName):
print('%s does not exist!' % videoName)
return False
# call ffmpeg and grab its stderr output
p = subprocess.call('ffmpeg -i %s -r 1 -s qvga -t 1 -f image2 %s' % (videoName,frameName), shell=True)
return p

错误是:
[image2 @ 0x422ff80] 无法打开文件:/local/common-data/UCF/tmp_frames/train/YoYo/v_YoYo_g25_c05.jpeg
av_interleaved_write_frame():输入/输出错误


和输出文件 训练输出 我应该得到我的框架是空的。

文件和文件夹广告子文件夹都可以。

我的代码有什么问题?

编辑 1

在/local/common-data/UCF/tmp_frames/train/中创建子文件夹 YoYo/并再次运行代码后,我得到了这个新错误:
Could not get frame filename number 2 from pattern '/local/common-data/UCF/tmp_frames/train/YoYo/v_YoYo_g25_c05‌​.jpeg' (either set updatefirst or use a pattern like %03d within the filename pattern) av_interleaved_write_frame(): Invalid argument

最佳答案

使用以下命令解决了问题:

p = subprocess.call('ffmpeg -i %s  -vf scale=224:-1 %s' % (videoName,frameName), shell=True)

关于ffmpeg - 无法打开文件 v_YoYo_g07_c04.jpeg av_interleaved_write_frame() : Input/output error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46938481/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com