strange behaviour of read() function for Videos

Hi, I have just started to work with VideoReader and the read function to access single frames of the video sequence. Now I have remarked that the result of read() depends on the previous access.
I have just done a little example to demonstrate this:
__________
tic
mov = VideoReader('/home/florian/Videos/output.avi');
%mov = VideoReader('/home/florian/Videos/out7.avi');
toc
read(mov,1);
read(mov,2);
read(mov,3);
read(mov,4);
read(mov,5);
read(mov,6);
read(mov,7);
read(mov,8);
read(mov,9);
read(mov,10);
read(mov,11);
read(mov,12);
read(mov,13);
read(mov,14);
x = read(mov,15);
y = read(mov,16);
z = read(mov,17);
read(mov,1);
z2 = read(mov,17);
read(mov,1);
x2 = read(mov,15);
read(mov,1);
y2 = read(mov,16);
max(max(max(x-x2)))
max(max(max(y-y2)))
max(max(max(z-z2)))
____________________________
I expect the output of x,x2 of y,y2 and z,z2 to be the same, since it is an easy access of frame 15, 16 and 17. If they are the same, the difference is the 0-matrix and the max of it (three dimensional) should be zero. But I got the strange results
_
Elapsed time is 8.905139 seconds.
ans =
190
ans =
187
ans =
204
__________
which proves their not the same. Could any one help me out?
I am using Linux (Ubuntu 12.10) with the R2013a matlab version.
Thank you for your effort.

2 commentaires

Are the videos fixed frame rate or variable frame rate?
In fact I am not quit sure. My original file is a *.m2ts file which is used and produced by sony devices. It is no problem to play it with vlc for example. But in Matlab I get with:
>> VideoReader.getFileFormats()
Video File Formats:
.avi - AVI File
.mj2 - Motion JPEG2000
.ogg - OGG File
.ogv - OGG Video
thus I need to do some preprocessing. I think to be fine to work with the avi file format, because this should be common. I did some preprocessing in order to produce my file which I am using and which produced the strong behaviour in matlab.In fact I used:
avconv -i ori.m2ts -ss 00:04:40 -t 00:00:10 -scodec copy -acodec copy -vcodec copy -f matroska step1.mkv
to extract the important part out of the original and then
ffmpeg -i step1.mkv -sameq -b 512k -f avi output_new.avi
to produce the file which then produces the error when loading to matlab.
To read the head of it, I used the following:
ffmpeg -i output_new.avi
ffmpeg version 0.8.10-4:0.8.10-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
built on Feb 6 2014 20:56:59 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Input #0, avi, from 'output_new.avi':
Metadata:
encoder : Lavf53.21.1
Duration: 00:00:10.06, start: 0.000000, bitrate: 74307 kb/s
Stream #0.0: Video: mpeg4 (Simple Profile), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 50 tbr, 50 tbn, 50 tbc
Stream #0.1: Audio: ac3, 48000 Hz, 5.1, s16, 512 kb/s
At least one output file must be specified
As defined in http://stackoverflow.com/questions/3199489/meaning-of-ffmpeg-output-tbc-tbn-tbr I guess to have a video of fixed frame rate of 50 frames/sec.

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 5 Avr 2014

0 votes

I have Windows 7 and it works with rhinos.avi and traffic.avi, the demos that MATLAB Image Processing Toolbox ships with. Do you get 0 0 0 for those two videos? What about other videos that are not from the same source as your output.avi?

2 commentaires

Florian
Florian le 7 Avr 2014
Yes, I get 0 0 0 for both of these clips. This leads me to the conclusion that my file might be corrupt, but then I expect to get some kind of error during the VideoReader('') loading.
You can send them the video and ask them to look at it, if you have a support contract.

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by