python - OpenCV:FFMPEG:标签 0x00000021/'!???' 未找到(格式 'mp4/MP4 (MPEG-4 Part 14)')'

标签 python opencv ffmpeg mp4

尝试运行 python 脚本时出现错误。我正在尝试基于 pyimagesearch 制作一个项目教程。

代码:
在第一个脚本中:

filename = tempVideo.path[tempVideo.path.rfind("/") + 1:]
    s3.upload_file(tempVideo.path, self.conf["s3_bucket"],
        filename, ExtraArgs={"ACL": "public-read",
        "ContentType": "video/mp4"})

在主脚本中:
tempVideo = TempFile(ext=".mp4")
    writer = cv2.VideoWriter(tempVideo.path, 0x21, 30, (W, H),
        True)

我收到的错误:
OpenCV: FFMPEG: tag 0x00000021/'!???' is not found (format 'mp4 / MP4 (MPEG-4 Part 14)')'
Exception in thread Thread-4:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pi/Desktop/pi-security-camera/pyimagesearch/notifications/twilionotifier.py", line 27, in _send
    "ContentType": "video/mp4"})
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/boto3/s3/inject.py", line 131, in upload_file
    extra_args=ExtraArgs, callback=Callback)
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/boto3/s3/transfer.py", line 279, in upload_file
    future.result()
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/s3transfer/futures.py", line 106, in result
    return self._coordinator.result()
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/s3transfer/futures.py", line 265, in result
    raise self._exception
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/s3transfer/tasks.py", line 255, in _main
    self._submit(transfer_future=transfer_future, **kwargs)
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/s3transfer/upload.py", line 549, in _submit
    upload_input_manager.provide_transfer_size(transfer_future)
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/s3transfer/upload.py", line 237, in provide_transfer_size
    transfer_future.meta.call_args.fileobj))
  File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/s3transfer/utils.py", line 245, in get_file_size
    return os.path.getsize(filename)
  File "/usr/lib/python3.7/genericpath.py", line 50, in getsize
    return os.stat(filename).st_size
FileNotFoundError: [Errno 2] No such file or directory: './/13675f07-ecec-48ae-97bf-32109eb3ed7d.mp4'

感谢您的建议:)

最佳答案

我有同样的错误。这对我有用:

fourcc = cv2.VideoWriter_fourcc(*"mp4v")
tempVideo = TempFile(ext=".mp4")
writer = cv2.VideoWriter(tempVideo.path, fourcc, 30, (W, H), True)

关于python - OpenCV:FFMPEG:标签 0x00000021/'!???' 未找到(格式 'mp4/MP4 (MPEG-4 Part 14)')',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61762229/

相关文章:

javascript - 如何使用 JS 抓取一个显示其内容的网站?

python - 将渲染的 Holoview 图添加到交互式 Bokeh APP

python - 在 jupyter 笔记本中以原始分辨率显示图像

Android - 同时将两个或多个 WAV 文件合并(合并)为一个(混合)

python - 如何在函数中使用局部变量并返回它?

python - 当属性不遵守命名规则时,Python 中的数据类

c++ - OpenCV VideoWriter 打不开

c++ - 获取2维cv::Mat的nonZero元素的值

linux - FFmpeg Drawbox 错误?

xcode - 如何在后台在xcode中运行系统命令