qq_42519463 2021-05-07 09:31 采纳率: 62.5%
浏览 97

求问这段代码哪里要改

"""
After moving all the files using the 1_ file, we run this one to extract
the images from the videos and also create a data file we can use
for training and testing later.
"""
import csv
import glob
import os
import os.path
import subprocess
from subprocess import call

def extract_files():
    """After we have all of our videos split between train and test, and
    all nested within folders representing their classes, we need to
    make a data file that we can reference when training our RNN(s).
    This will let us keep track of image sequences and other parts
    of the training process.

    We'll first need to extract images from each of the videos. We'll
    need to record the following data in the file:

    [train|test], class, filename, nb frames

    Extracting can be done with ffmpeg:
    `ffmpeg -i video.mpg image-%04d.jpg`
    """
    data_file = []
    folders = ['E:/Graduation Project/UCF-101_video_classification-master/data/train/', 'E:/Graduation Project/UCF-101_video_classification-master/data/test/']

    for folder in folders:
        class_folders = glob.glob(folder + '*')

        for vid_class in class_folders:
            class_files = glob.glob(vid_class + '/*.avi')

            for video_path in class_files:
                # Get the parts of the file.
                video_parts = get_video_parts(video_path)

                train_or_test, classname, filename_no_ext, filename = video_parts

                # Only extract if we haven't done it yet. Otherwise, just get
                # the info.
                if not check_already_extracted(video_parts):
                    # Now extract it.
                    src = train_or_test + '/' + classname + '/' + \
                        filename
                    dest = train_or_test + '/' + classname + '/' + \
                        filename_no_ext + '-%04d.jpg'
                    subprocess.call(["ffmpeg", "-i", src, dest])

                # Now get how many frames it is.
                nb_frames = get_nb_frames_for_video(video_parts)

                data_file.append([train_or_test, classname, filename_no_ext, nb_frames])

                print("Generated %d frames for %s" % (nb_frames, filename_no_ext))

运行结果:

Generated 0 frames for data
'ffmpeg' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
Generated 0 frames for data
'ffmpeg' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
Generated 0 frames for data
'ffmpeg' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
Generated 0 frames for data
'ffmpeg' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
Generated 0 frames for data
'ffmpeg' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
Generated 0 frames for data
'ffmpeg' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
Generated 0 frames for data
'ffmpeg' �����ڲ����ⲿ���Ҳ���ǿ����еij���

一堆这个东西。根据代码最后一行,说明没有成功从视频中提取帧,所以能帮忙看看哪里的问题吗?

  • 写回答

1条回答 默认 最新

  • GitCode 官方 企业官方账号 2021-05-08 17:35
    关注

    我已经在你的上一个问题PyCharm运行出现AttributeError里面回答了,今天下午刚刚有时间更新了回答,你可以看一下,https://ask.csdn.net/questions/7426138

    评论

报告相同问题?

悬赏问题

  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
  • ¥40 串口调试助手打开串口后,keil5的代码就停止了
  • ¥15 电脑最近经常蓝屏,求大家看看哪的问题
  • ¥60 高价有偿求java辅导。工程量较大,价格你定,联系确定辅导后将采纳你的答案。希望能给出完整详细代码,并能解释回答我关于代码的疑问疑问,代码要求如下,联系我会发文档
  • ¥50 C++五子棋AI程序编写
  • ¥30 求安卓设备利用一个typeC接口,同时实现向pc一边投屏一边上传数据的解决方案。
  • ¥15 SQL Server analysis services 服务安装失败