Hi,

I am having a problem with reading video files with the ffmpeg api. I am building on a python wrapper, that someone else wrote. I noticed a bug, but the creator could not solve the issue. So I am trying to hunt it down by myself.

The problem is that the wrapper truncates any video I tried it with.

The basic idea of the wrapper is, to use

av_read_frame()

to read frames until it returns a value < 0. That seems to work, and I get the right frames back all the time (even using seek of the wrapper), except for the last frames. It seems as av_read_frame only reads until the last key frame and does not go beyond it.

FFMPEG command line tools, on the other hand, can extract the full video sequence and do not omit anything.


I am not sure whether the information I give here is enough to start hunting down the bug. I am not experienced at all with the ffmpeg api and I am working with the code I have got from the other guy. Let me know if you need something else to start tracing the problem.

Thanks,

Peter


Stuff to test the problem:

Wrapper code with line calling av_read_frame:
===========================

https://bitbucket.org/groakat/ffvideo/src/b45143f755ac8da1e6ed4f52a11217af1e093d54/ffvideo/ffvideo.pyx?at=default#cl-231

( you can install the wraper with pip install https://bitbucket.org/groakat/ffvideo/get/b45143f755ac.zip)


Rendered test Video (1000 frames numbered from 1..1000):
====================================

https://www.dropbox.com/s/guu33jyy4t7sq53/test.avi?dl=0


Script to generate the video:
=================

First generate frames:

#!/bin/bash
for i in $(seq -f "%05g" 1 1000)
do
convert -size 51x18 -pointsize 16 -font /usr/share/fonts/truetype/freefont/FreeMono.ttf label:$i $i.png
done

Then use to create a video from the image sequence:

ffmpeg -y -f image2 -r 30 -i "%05d.png" -r 30 test.avi


Then test whether ffmpeg can read all frames:

ffmpeg -i "test.avi" -an -f image2 "output_%05d.png"


Python script using the wrapper from above to extract the frames:
========================================

from ffvideo import VideoStream
from scipy.misc import imsave
vs = VideoStream('test.avi', exact_seek=True)

cnt = 0
for frame in vs:
    f = frame.ndarray()
    imsave("frame {0:05d}.png".format(cnt), f)
    cnt += 1


My ffmpeg version
===========

$ ffmpeg
ffmpeg version 2.2.git Copyright (c) 2000-2014 the FFmpeg developers
built on Apr 9 2014 16:32:16 with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu9) configuration: --prefix=/home/peter/ffmpeg_build --extra-cflags=-I/home/peter/ffmpeg_build/include --extra-ldflags=-L/home/peter/ffmpeg_build/lib --bindir=/home/peter/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab --enable-shared
  WARNING: library configuration mismatch
avutil configuration: --enable-gpl --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-shared avcodec configuration: --enable-gpl --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-shared avformat configuration: --enable-gpl --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-shared avdevice configuration: --enable-gpl --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-shared avfilter configuration: --enable-gpl --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-shared swscale configuration: --enable-gpl --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-shared swresample configuration: --enable-gpl --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-shared postproc configuration: --enable-gpl --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-shared
  libavutil      52. 74.100 / 52. 75.100
  libavcodec     55. 58.102 / 55. 58.103
  libavformat    55. 36.102 / 55. 36.102
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  3.100 /  4.  3.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

_______________________________________________
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

Reply via email to