Why doesn't the video open using Image.Video.open(filename)

When I try to open a file, an object with the isOpened false field is returned. How can I fix this?

iex(1)> Image.Video.open("/home/rodion/IdeaProjects/work/pioneer_media_server/files/243f408a-5f60-4e69-904f-1dcdee50ecf0.mp4")
{:ok,
 %Evision.VideoCapture{
   fps: 0.0,
   frame_count: 0.0,
   frame_width: 0.0,
   frame_height: 0.0,
   isOpened: false,
   ref: #Reference<0.1771084477.600440856.109699>
 }}

As you can tell by the return value, Image.Video.open/2 is wrapper around Evision.VideoCapture.open/3. Pinging @cocoa since she will have a better idea than I do.

I would first check there is a video backend configured in your evision installation that can handle .mp4 files. On my Mac I see:

iex> Image.Video.available_backends
[:images, :opencv_mjpeg, :avfoundation]

Where :avfoundation is the Mac OS library that opens .mp4 files. If your platform is different you might need evision to be configured and built with ffmpeg since I believe the prebuilt evision NIF does not include ffmpeg for licensing reasons.

1 Like