Rich_Morin

Rich_Morin

I want to extract selected images from downloaded video files. I’d like to know whether Membrane is a reasonable tool for this job, whether anyone else has done similar tasks with it, etc. I’m also unsure about how its “pipeline” approach would fit a “random access” use case.

For purposes of discussion, assume that I’ll be using VLC media player to download videos from web sites such as YouTube, storing them as MP4 files. Because I’ll be processing the images, I’d like to get them into Nx tensor format.

Can someone give me some advice, clues, and/or suggestions?

Showing Posts 1 to 6

kwando

kwando

I would use ffmpeg to extract images from the video files. Could probably skip VLC and use ffmpeg directly as well.

Then loading the extracted images from disk and do whatever I have to do in nx :slight_smile:

Probably not gonna be the most efficient way of doing it, but might be good enough :slight_smile:

No idea on how membrane works.

kokolegorille

kokolegorille

I am also using ffmpeg to extract images from video, there is a ffmpex wrapper, but I wrote a simple one.

Membrane is good if You want to receive or stream rtmp, or webrtc…

But for YT, I would check this python package, and maybe use erlport to interface python script.

https://github.com/pytube/pytube

There are tools to transform images from/to nx…

by @kip

and

by @cocoa

Rich_Morin

Rich_Morin OP

It seems like FFmpeg only extracts images in PNG format. This might work well with ExPNG, but I think I’ll want to get them into Nx format at some point. Suggestions?

kokolegorille

kokolegorille

It can use more format… like jpg. But if You want them in nx, the 2 packages have a to_nx() function.

kwando

kwando

The wonderful image library can load images and convert them to/from tensors

Edit: didn’t notice you already got this suggestion;)

kip

kip

ex_cldr Core Team

As of image version 0.21.0 which I just published you can leverage the Evision.VideoCapture module to extract images from a video.

You can therefore use either the more idiomatic API in Image.Video or simply leverage the code that is there to use Evision directly.

Depending on the codec support of the OpenCV installation on your system I suspect you may not need to use the FFMEG CLI approach any more.

Example using Image

# Extract using a frame offset
iex> {:ok, video} = Image.Video.open("./test/support/video/video_sample.mp4")
iex> {:ok, _image} = Image.Video.image_from_video(video, frame: 0)

# Extract using a millisecond offset
iex> {:ok, _image} = Image.Video.image_from_video(video, millisecond: 0)

# Capturing images from a camera (note that seeking is not supported
# on image streams. On MacOS you will receive a prompt to permit the
# app to access the camera. You may need to restart the BEAM and/or
# your system if capturing fails immediately after granting permission.
iex> {:ok, video} = Image.Video.open(:default_camera)
iex> {:ok, _image} = Image.Video.image_from_video(video)

Example using Evision directly

# Extract by frame offset
video = Evision.VideoCapture.videoCapture(video_filename)
true = Evision.VideoCapture.set(video, Evision.cv_CAP_PROP_POS_FRAMES(), frame_offset),
cv_image = Evision.VideoCapture.read(video)

Using images in Nx

Both Image and Evision support zero-copy “export” of images to Nx. Just call Image.to_nx/1 or Evision.Mat.to_nx/1 as appropriate.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews