AVbin 7 c++

130 views
Skip to first unread message

Peter Enerccio

unread,
Dec 11, 2011, 8:33:23 AM12/11/11
to pyglet...@googlegroups.com
I know this is a bit off topic for pyglet, but maybe someone who knows the avbin can reply to me. I am trying to found a way to get whn the video file has finished playing in avbin, but alas, I found no such information anywhere. I tried to check for timestamp whether it is at the end, but it would ignore it and just end with segmentation fault.

Nathan

unread,
Dec 12, 2011, 12:11:12 PM12/12/11
to pyglet...@googlegroups.com

Peter,

AVbin doesn't "play" a video file, per se. Some application or
framework (like Pyglet, for example) uses AVbin to decode a video
frame by frame and then presents the visual/audio information to some
device to play it.

You can tell that AVbin has nothing left to decode from a video file
when a call to avbin_decode_video() returns 0 (successfull finish) or
-1 (hit an error).

If you are interested in using Pyglet to play video, you can view the
documentation here (
http://pyglet.org/doc/programming_guide/sound_and_video.html ) and the
API reference here ( http://pyglet.org/doc/api/index.html ). There's
even an example player application in examples/video.py in the pyglet
tarball (do examples get put somewhere during binary installs of
Pyglet, anyone?).

Or, you can read Pyglet's source code to see a reference
implementation of how to use AVbin -- though Pyglet is written in
Python, not C++ like I assume you are looking to do from the subject
of this email.

If you are looking to use AVbin directly from your C++ project, I
suggest reading include/avbin.h -- the API is documented fairly
thoroughly in that file in comments. I need to see about generating
an online version of those docs (it looks like it may be already set
up to generate using doxygen, but I've never used doxygen...yet).

~ Nathan

Peter Enerccio

unread,
Dec 12, 2011, 12:38:32 PM12/12/11
to pyglet...@googlegroups.com
Ah, I mean about the decoding the frame.
Here is my code so far: http://paste.pocoo.org/show/519833/
It works, albeit somewhat slower than the original.
I have also troubles with avi files, they report 0/0 on the frame rate, which is really jarring...

2011/12/12 Nathan <nathan...@gmail.com>

~ Nathan

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To post to this group, send email to pyglet...@googlegroups.com.
To unsubscribe from this group, send email to pyglet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en.


Nathan

unread,
Dec 12, 2011, 12:51:44 PM12/12/11
to pyglet...@googlegroups.com
On Mon, Dec 12, 2011 at 10:38 AM, Peter Enerccio <ener...@gmail.com> wrote:
> Ah, I mean about the decoding the frame.
> Here is my code so far: http://paste.pocoo.org/show/519833/
> It works, albeit somewhat slower than the original.
> I have also troubles with avi files, they report 0/0 on the frame rate,
> which is really jarring...

Well, if you're just trying to detect when it has finished playing,
then after line 118 in your file check to see if res == 0.

~ Nathan

Peter Enerccio

unread,
Dec 12, 2011, 12:57:51 PM12/12/11
to pyglet...@googlegroups.com
Seems not to even reach that part of the program: http://i.imgur.com/hlDah.png

2011/12/12 Nathan <nathan...@gmail.com>

~ Nathan

Nathan

unread,
Dec 12, 2011, 2:46:48 PM12/12/11
to pyglet...@googlegroups.com
On Mon, Dec 12, 2011 at 10:57 AM, Peter Enerccio <ener...@gmail.com> wrote:
> Seems not to even reach that part of the program:
> http://i.imgur.com/hlDah.png

Do you know whether that segfault happened before res was equal to
zero, or afterwards on the next instance of the loop? If the latter,
then it may be a problem with avbin_seek_file().

~ Nathan

Peter Enerccio

unread,
Dec 12, 2011, 2:56:05 PM12/12/11
to pyglet...@googlegroups.com
I changed a few lines here and there: http://paste.pocoo.org/show/519896/
and now it really seg faults in avbin_seek_file().

2011/12/12 Nathan <nathan...@gmail.com>

~ Nathan

Peter Enerccio

unread,
Dec 12, 2011, 5:06:15 PM12/12/11
to pyglet...@googlegroups.com
Hello again.
I managed to fix it by closing the stream and file and reopening it (skipping all file info and stream founding routines along the way).


2011/12/12 Peter Enerccio <ener...@gmail.com>

Nathan

unread,
Dec 12, 2011, 6:28:25 PM12/12/11
to pyglet...@googlegroups.com
On Mon, Dec 12, 2011 at 3:06 PM, Peter Enerccio <ener...@gmail.com> wrote:
> Hello again.
> I managed to fix it by closing the stream and file and reopening it
> (skipping all file info and stream founding routines along the way).

Great, I am glad you found a workaround!

I wonder if there is a bug in avbin_seek_file(), then.

~ Nathan

Peter Enerccio

unread,
Dec 12, 2011, 7:02:58 PM12/12/11
to pyglet...@googlegroups.com
Maybe. Although, other from that and weird frame rate information avbin works great!

2011/12/13 Nathan <nathan...@gmail.com>

~ Nathan

Nathan

unread,
Dec 13, 2011, 1:23:04 AM12/13/11
to pyglet...@googlegroups.com
On Mon, Dec 12, 2011 at 5:02 PM, Peter Enerccio <ener...@gmail.com> wrote:
> Maybe. Although, other from that and weird frame rate information avbin
> works great!

Glad to hear it! What OS and version of AVbin are you using?

~ Nathan

Peter Enerccio

unread,
Dec 13, 2011, 3:23:32 AM12/13/11
to pyglet...@googlegroups.com
7, 13661
and linux 64

2011/12/13 Nathan <nathan...@gmail.com>

~ Nathan

anatoly techtonik

unread,
Dec 13, 2011, 5:52:20 AM12/13/11
to pyglet...@googlegroups.com
On Monday, December 12, 2011 8:11:12 PM UTC+3, Nathan wrote:

AVbin doesn't "play" a video file, per se.  Some application or
framework (like Pyglet, for example) uses AVbin to decode a video
frame by frame and then presents the visual/audio information to some
device to play it.

You can tell that AVbin has nothing left to decode from a video file
when a call to avbin_decode_video() returns 0 (successfull finish) or
-1 (hit an error).

I couldn't find any documentation on AVbin. pyglet docs are also very limited in this regard. Are there any plans to provide some tutorial and Python bindings for AVbin out of the box? So that people can `easy_install avbin` and `import avbin` to play with its API/features?

Nathan

unread,
Dec 13, 2011, 2:58:22 PM12/13/11
to pyglet...@googlegroups.com
On Tue, Dec 13, 2011 at 1:23 AM, Peter Enerccio <ener...@gmail.com> wrote:
> 7, 13661
> and linux 64

FYI, AVbin 8 has been released. It would be great if you could give
that a spin and see if it works any better/worse than AVbin 7.

http://avbin.github.com/AVbin/Download.html

~ Nathan

Richard Jones

unread,
Dec 13, 2011, 3:14:03 PM12/13/11
to pyglet...@googlegroups.com

avbin isn't a Python module - it's a C library that exports a stable
ABI wrapped around the ffmpeg (or libav?) library.


Richard

Nathan

unread,
Dec 13, 2011, 3:15:07 PM12/13/11
to pyglet...@googlegroups.com
On Tue, Dec 13, 2011 at 3:52 AM, anatoly techtonik <tech...@gmail.com> wrote:
> On Monday, December 12, 2011 8:11:12 PM UTC+3, Nathan wrote:
>>
>> AVbin doesn't "play" a video file, per se.  Some application or
>> framework (like Pyglet, for example) uses AVbin to decode a video
>> frame by frame and then presents the visual/audio information to some
>> device to play it.
>>
>> You can tell that AVbin has nothing left to decode from a video file
>> when a call to avbin_decode_video() returns 0 (successful finish) or

>> -1 (hit an error).
>
> I couldn't find any documentation on AVbin. pyglet docs are also very
> limited in this regard. Are there any plans to provide some tutorial and
> Python bindings for AVbin out of the box? So that people can `easy_install
> avbin` and `import avbin` to play with its API/features?

AVbin documentation is currently in the form of comments in
include/avbin.h in the AVbin source. You WILL need to read that if
you want to use AVbin's interface directly. It's on the Version 9
roadmap to get online documentation generated (in fact, it looks like
it's all set up to be generated by Doxygen, as soon as I figure out
how to use Doxygen).

Pyglet includes a full set of python bindings already in
pyglet.media.avbin (AVbin was originally created just for that
purpose, after all). I don't have any plans to create or maintain a
separate set of Python bindings, though I don't mind if someone else
wants to. If you wanted to, you could take Pyglet's version and adapt
it to your own use. (see pyglet/media/avbin.py) I don't know why
that file isn't included in Pyglet's API reference.

I don't currently have any plans to make a tutorial. There IS an
example C program in AVbin under example/avbin_dump.c that may be
useful towards that end, though.

Those were good questions. Thanks!

~ Nathan

Indra Gunawan

unread,
Dec 13, 2011, 3:16:47 PM12/13/11
to pyglet...@googlegroups.com

TMIIW It's originaly created to extend pyglet multimedia playback capability

Peter Enerccio

unread,
Dec 13, 2011, 3:44:00 PM12/13/11
to pyglet...@googlegroups.com
I can try but I think I saw linux is not supported yet? Or maybe that has changed already.

2011/12/13 Nathan <nathan...@gmail.com>

~ Nathan

Peter Enerccio

unread,
Dec 13, 2011, 3:57:20 PM12/13/11
to pyglet...@googlegroups.com
I was actually wondering, whether there could be alpha support option be included in the avbin?
Right now, I have to take every pixel and basically add 4th 255 alpha value to support GL_RGBA texture option...

2011/12/13 Indra Gunawan <indra...@gmail.com>

anatoly techtonik

unread,
Dec 13, 2011, 3:59:11 PM12/13/11
to pyglet...@googlegroups.com
On Tue, Dec 13, 2011 at 11:15 PM, Nathan <nathan...@gmail.com> wrote:
On Tue, Dec 13, 2011 at 3:52 AM, anatoly techtonik <tech...@gmail.com> wrote:
> On Monday, December 12, 2011 8:11:12 PM UTC+3, Nathan wrote:
>>
>> AVbin doesn't "play" a video file, per se.  Some application or
>> framework (like Pyglet, for example) uses AVbin to decode a video
>> frame by frame and then presents the visual/audio information to some
>> device to play it.
>>
>> You can tell that AVbin has nothing left to decode from a video file
>> when a call to avbin_decode_video() returns 0 (successful finish) or
>> -1 (hit an error).
>
> I couldn't find any documentation on AVbin. pyglet docs are also very
> limited in this regard. Are there any plans to provide some tutorial and
> Python bindings for AVbin out of the box? So that people can `easy_install
> avbin` and `import avbin` to play with its API/features?

AVbin documentation is currently in the form of comments in
include/avbin.h in the AVbin source.  You WILL need to read that if
you want to use AVbin's interface directly.  It's on the Version 9
roadmap to get online documentation generated (in fact, it looks like
it's all set up to be generated by Doxygen, as soon as I figure out
how to use Doxygen).

Well, to tell the truth, I am not really interested in Doxygen API reference for C part of the library. Though I am curious about the process of stripping FFmpeg to a minimal set of bare functionality needed, but what really interests me is playing with AVbin from Python console.
 
Pyglet includes a full set of python bindings already in
pyglet.media.avbin (AVbin was originally created just for that
purpose, after all).  I don't have any plans to create or maintain a
separate set of Python bindings, though I don't mind if someone else
wants to.

The main motivation here is not to create YetAnothePythonBinding-for-FFmpeg, but to make it possible for pyglet to just `import AVbin` - that would be useful for other applications as well. AVbin is already an external dependency, so it will be convenient to have it wrapped in Python package.

Another useful outcome of clearly separated API is that FFmpeg is not the only A/V library out there, and it becomes evident for other that it is possible to create non-GPLed AVbin replacement that only operates with WebM, for example.
 
If you wanted to, you could take Pyglet's version and adapt
it to your own use.  (see pyglet/media/avbin.py)  I don't know why
that file isn't included in Pyglet's API reference.

API reference is still a reference - not a replacement for documentation explaining concepts and use cases. Good documentation is inspiring. Good API reference is full, but concise. It is quite hard to pursue all these goals.

I don't currently have any plans to make a tutorial.   There IS an
example C program in AVbin under example/avbin_dump.c that may be
useful towards that end, though.

Example should be available from the web. First you read an example, and then (if it is interesting enough) download code.
 
Those were good questions.  Thanks!

No problem. I will probably have more if these are "fixed". =)

Nathan

unread,
Dec 13, 2011, 10:39:33 PM12/13/11
to pyglet...@googlegroups.com
On Tue, Dec 13, 2011 at 1:44 PM, Peter Enerccio <ener...@gmail.com> wrote:
> I can try but I think I saw linux is not supported yet? Or maybe that has
> changed already.

Version 8 is released for all platforms.

~ Nathan

Reply all
Reply to author
Forward
0 new messages