1
$\begingroup$

I asked here for a solution how single video images can be extracted very fast from avi files.

Piotr Wendykier gave a solution for Mathematica 11.3.

Now I'm using Mathematica 12 and his solution does not work anymore.

Why

i = MediaTools`Private`$MFReadNextFrame[]

does not read an image out of the video as in version 11.3?

In[1]:= file = 
 URLSave["http://mirrors.standaloneinstaller.com/video-sample/\
Panasonic_HDC_TM_700_P_50i.avi", "c:\\tmp\\sample.avi"]

Out[1]= "c:\\tmp\\sample.avi"

In[2]:= Needs["MediaTools`"]

In[3]:= MediaTools`Private`$MFInitReader[file]

Out[3]= MediaTools`Private`$MFInitReader["c:\\tmp\\sample.avi"]

In[4]:= AbsoluteTiming[i = MediaTools`Private`$MFReadNextFrame[];]

Out[4]= {1.9*10^-6, Null}

In[5]:= MediaTools`Private`$MFFinalizeReader[]

Out[5]= MediaTools`Private`$MFFinalizeReader[]

In[6]:= ImageDimensions[i]

During evaluation of In[6]:= ImageDimensions::imginv: Expecting an image or graphics instead of MediaTools`Private`$MFReadNextFrame[].

Out[6]= ImageDimensions[MediaTools`Private`$MFReadNextFrame[]]
$\endgroup$

1 Answer 1

4
$\begingroup$

In Mathematica 12 we have renamed these private functions. The following code works in 12.0:

In[1]:= file = 
 URLSave["http://mirrors.standaloneinstaller.com/video-sample/\
Panasonic_HDC_TM_700_P_50i.avi", "c:\\tmp\\sample.avi"]

Out[1]= "c:\\tmp\\sample.avi"

In[2]:= Needs["MediaTools`"]

In[3]:= MediaTools`Private`$MFInitVideoReader[file]

Out[3]= True

In[4]:= AbsoluteTiming[i = MediaTools`Private`$MFReadNextVideoFrame[];]

Out[4]= {0.0411032, Null}

In[5]:= MediaTools`Private`$MFFinalizeVideoReader[]

Out[5]= True

In[6]:= ImageDimensions[i]

Out[6]= {1920, 1080}

These functions have usage documentation:

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you very much for your help. $\endgroup$
    – mrz
    Commented Sep 9, 2019 at 10:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.