pythonvideoffmpegmoviepypyav

Pims.open Throws "UnkownFormat Error" with "Invalid Argument" On One Machine But Not on Another


I'm trying to do some video processing for a physics experiment, and I want to do it on my much more powerful Windows desktop computer as opposed to my Mac laptop.

The following code works like a dream when run as a Jupyter notebook on my Mac:

import matplotlib as mpl
from mpl_toolkits import mplot3d
import pims
import trackpy as tp 

@pims.pipeline
def gray(image):
    return image[:, :, 1]  # Take just the green channel

frames = gray(pims.open('output.mp4'))

but on my Windows machine I get this error:

---------------------------------------------------------------------------
UnknownFormatError                        Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_12152/704954007.py in <module>
      1 #Actually converts the video. Might be VERY processor intensive... or not?
----> 2 frames = gray(pims.open('output.mp4')) #Make the File Name whatever file you like!

~\miniconda3\lib\site-packages\pims\api.py in open(sequence, **kwargs)
    207             warn(message)
    208             exceptions += message + '\n'
--> 209     raise UnknownFormatError("All handlers returned exceptions:\n" + exceptions)
    210 
    211 

UnknownFormatError: All handlers returned exceptions:
<class 'pims.pyav_reader.PyAVReaderTimed'> errored: [Errno 22] Invalid argument: 'output.mp4'
<class 'pims.pyav_reader.PyAVReaderIndexed'> errored: [Errno 22] Invalid argument: 'output.mp4'
<class 'pims.imageio_reader.ImageIOReader'> errored: Could not load meta information
=== stderr ===

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
C:\Users\Callum\OneDrive - The University of Chicago\output.mp4: Invalid argument
<class 'pims.moviepy_reader.MoviePyReader'> errored: MoviePy error: failed to read the duration of file output.mp4.
Here are the file infos returned by ffmpeg:

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
output.mp4: Invalid argument

output.mp4 is just a run of the mill video file taken on a CCD camera; I've tried converting it to a .MOV, I've tried other video files taken on different cameras, and I've tried running the file through FFmpeg to impose a 30 fps framerate; everything I've tried works fine on my Mac and throws the above error on my Windows machine.

For reference, I installed necessary packages for this code on both machines this morning, so it should all be up to date and the same on both.

Any ideas as to what's up? Thanks!


Solution

  • Figured out the problem! I was sharing files between the two machines using Microsoft OneDrive, which created an alias for the video files without actually downloading them! Jupyter Notebook couldn't tell the difference in the file explorer, but when PIMS (or more precisely PyAv) tried to load the file, there was nothing there, causing an error. When I downloaded the file to the machine, everything once again worked fine.

    Posting this in case this ever happens to anyone else! Thanks.