aviread from video package does not return correct frame

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

aviread from video package does not return correct frame

shall689
Hello,

The issue I am having is that all of the frames output from aviread are the
same frame (I believe frame 53 out of 177 frames).

I am using the octave package video-1.2.4.tar.gz on flatpak octave version
4.4.1.  My OS is Ubuntu 18.04.1 and I am running it as guest on VirtualBox
6.0.

The avi video was converted from a h264  to avi using ffmpeg on a different
computer that had the same octave and video package version but was running
Snappy linux.  Also, Snappy linux had ffmpeg version 3.3.9 whereas the
Ubuntu has version 3.4.4.  Could that be causing the issue?

Stephen





--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: aviread from video package does not return correct frame

shall689
I forgot to mention that I was able to extract all the frame using Matlab.  

Here's the code I used with Matlab:
xyloObj = VideoReader('vid1.avi');

vidWidth = xyloObj.Width;
vidHeight = xyloObj.Height;

mov = struct('cdata',zeros(vidHeight,vidWidth,3,'uint8'),...
    'colormap',[]);
k = 1;
while hasFrame(xyloObj)
    mov(k).cdata = readFrame(xyloObj);
    frameName =
strcat('C:\Users\Melb\Documents\MATLAB\frames_avi\frame',num2str(k),'.jpg')
    imwrite(mov(k).cdata,frameName);
    k = k+1;
end

hf = figure;
set(hf,'position',[150 150 vidWidth vidHeight]);

movie(hf,mov,1,xyloObj.FrameRate);



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: aviread from video package does not return correct frame

shall689
I just converted the h264 file to avi on the VirtualBox running Ubuntu with
the following:
ffmpeg -framerate 3 -i vid1.h264 -c copy output.avi

aviread still returns the same frame for all frames.

aviinfo returns the following:
>> aviinfo('output.avi')
ans =

  scalar structure containing the fields:

    Filename = output.avi
    FileSize =  38222588
    FileModDate = 25-Dec-2018 18:08:29
    NumFrames =  354
    FramesPerSecond =  6
    Width =  1920
    Height =  1080
    ImageType = truecolor
    VideoCompression = h264
    Quality =  100
    NumColormapEntries = 0
    AudioFormat =
    AudioRate = 0
    NumAudioChannels = 0
    Title =
    Author =
    Comment =

The FramesPerSecond is 6 which is incorrect.  When I converted the h264 to
mp4, aviinfo returned the correct frames per second, which is 3.

I used the following lines to get a frame, e.g. frame 1 and replace 1 with 2
to get frame 2:
>> f=aviread('output.avi',1);
>> imshow(f)






--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: aviread from video package does not return correct frame

shall689
I was able to get python to extract the frames. However, I would still like
to use octave's video package to extract the frames.

After installing python-opencv
(https://docs.opencv.org/3.4.1/d2/de6/tutorial_py_setup_in_ubuntu.html), the
following code was able to extract the frames successfully using the
following code (using example from
https://stackoverflow.com/questions/33311153/python-extracting-and-saving-video-frames):

import cv2
vidcap = cv2.VideoCapture('Output.mp4')
success,image = vidcap.read()
count = 0
while success:
  cv2.imwrite("frame%d.jpg" % count, image)     # save frame as JPEG file      
  success,image = vidcap.read()
  print('Read a new frame: ', success)
  count += 1




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: aviread from video package does not return correct frame

shall689
I was wanting to install octave on a Raspberry PI 3 B+ and then process video
files using the video and image packages.  However, I am currently able to
extract frames using python+opencv, so maybe I will go in that direction.  

If anyone is interested,  I installed opencv on the Rasperry PI using the
following:
sudo apt-get install python-opencv.   Before I did what was stated in part 1
of
https://www.pyimagesearch.com/2016/04/18/install-guide-raspberry-pi-3-raspbian-jessie-opencv-3/.  

opencv version 2.4.9.1 was installed, which isn't the newest version.
Installing a newer version takes a lot more work, so I will see if the
2.4.9.1 is good enough for now.

Was anyone able to install octave on the Raspberry PI?



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: aviread from video package does not return correct frame

Andreas Weber-6
Am 26.12.18 um 02:36 schrieb shall689:
> Was anyone able to install octave on the Raspberry PI?

Yes, on Raspbian without any problem.
-- Andy


Reply | Threaded
Open this post in threaded view
|

Re: aviread from video package does not return correct frame

Andreas Weber-6
In reply to this post by shall689
Am 25.12.18 um 22:41 schrieb shall689:
> The issue I am having is that all of the frames output from aviread are the
> same frame (I believe frame 53 out of 177 frames).
> ...
> The avi video was converted from a h264  to avi using ffmpeg on a different
> computer that had the same octave and video package version but was running
> Snappy linux.

It's always difficult or impossible to debug such a problem without
having the input file.

If you are able to create a little test video which shows this problem
this would really help.

-- Andy


Reply | Threaded
Open this post in threaded view
|

Re: aviread from video package does not return correct frame

shall689
In reply to this post by Andreas Weber-6
Hello Andy,

Thanks for the reply.

How did you install octave on the Raspberry Pi? Also, what version did you
install?

Stephen



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html