By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,525 Members | 1,689 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,525 IT Pros & Developers. It's quick & easy.

Extract frame from wmv

P: n/a
Hi,

I need to extract a frame from a wmv file and save it as a jpg. In fact
I need to extract a frame from each one of a collection of several
thousand wmv files, but that's beside the point.

I've actually written a script that does exactly this using the pyglet
module. But while it works fine on my local machine running Python 2.5,
my host is only on 2.4.3. They've installed pyglet for me, but it won't
run without ctype, and they don't suport it.

Can anyone suggest an alternative way to achieve this using a module
that will run on a standard 2.4.3 installation?

Thanks,

Martin

Nov 5 '08 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Martin wrote:
I need to extract a frame from a wmv file and save it as a jpg. In fact
I need to extract a frame from each one of a collection of several
thousand wmv files, but that's beside the point.

I've actually written a script that does exactly this using the pyglet
module. But while it works fine on my local machine running Python 2.5,
my host is only on 2.4.3. They've installed pyglet for me, but it won't
run without ctype, and they don't suport it.

Can anyone suggest an alternative way to achieve this using a module
that will run on a standard 2.4.3 installation?
Pretty sure pymedia can do this kind of thing, possibly
with a bit of work.

http://pymedia.org/tut/src/dump_video.py.html

I used it recentlyish to do the reverse: combine a series
of still shots into a time-lapse movie.

Alternatively, you might be able to commandline control
mencoder or ffmpeg itself to do this. Not sure, but there
must be *something* among those millions of command-line
options!

TJG

Nov 5 '08 #2

P: n/a
Tim Golden wrote:
Martin wrote:
>I need to extract a frame from a wmv file and save it as a jpg. In
fact I need to extract a frame from each one of a collection of
several thousand wmv files, but that's beside the point.

I've actually written a script that does exactly this using the pyglet
module. But while it works fine on my local machine running Python
2.5, my host is only on 2.4.3. They've installed pyglet for me, but it
won't run without ctype, and they don't suport it.

Can anyone suggest an alternative way to achieve this using a module
that will run on a standard 2.4.3 installation?

Pretty sure pymedia can do this kind of thing, possibly
with a bit of work.

http://pymedia.org/tut/src/dump_video.py.html

I used it recentlyish to do the reverse: combine a series
of still shots into a time-lapse movie.

Alternatively, you might be able to commandline control
mencoder or ffmpeg itself to do this. Not sure, but there
must be *something* among those millions of command-line
options!

TJG
Hi Tim,

I've looked at Pymedia but I have to admit I couldn't work it out.

Commandline might be good, but I'm really hoping someone can point me in
the right direction, as this is not my area of expertise.

Thanks,

Martin
Nov 5 '08 #3

P: n/a
Martin wrote:
I've looked at Pymedia but I have to admit I couldn't work it out.

Commandline might be good, but I'm really hoping someone can point me in
the right direction, as this is not my area of expertise.

Nor mine :) Just so people can help you out, can you
be more precise in your requirement? Do you want just
the first frame (eg to act as an img placeholder for
an embedded video). Or do you want to extract one or
more arbitrary frames, eg for screen cap purposes?

This page:

http://stream0.org/2008/02/howto-ext...from-a-vi.html

looks helpful from the ffmpeg pov, but I assume you're
as capable of using Google as I am. I had a very quick
go with the copy of pymedia I have installed here, but
it couldn't read a (fairly recent) .wmv file so that
might be a problem in any case.

UPDATE: Just tried:

ffmpeg -i bacardi.wmv -r 1 -f image2 images%05d.png

from that page and it produced useful stuff. Worth a try?

TJG
Nov 5 '08 #4

P: n/a
Tim Golden wrote:
Martin wrote:
>I've looked at Pymedia but I have to admit I couldn't work it out.

Commandline might be good, but I'm really hoping someone can point me
in the right direction, as this is not my area of expertise.


Nor mine :) Just so people can help you out, can you
be more precise in your requirement? Do you want just
the first frame (eg to act as an img placeholder for
an embedded video). Or do you want to extract one or
more arbitrary frames, eg for screen cap purposes?

This page:

http://stream0.org/2008/02/howto-ext...from-a-vi.html

looks helpful from the ffmpeg pov, but I assume you're
as capable of using Google as I am. I had a very quick
go with the copy of pymedia I have installed here, but
it couldn't read a (fairly recent) .wmv file so that
might be a problem in any case.

UPDATE: Just tried:

ffmpeg -i bacardi.wmv -r 1 -f image2 images%05d.png

from that page and it produced useful stuff. Worth a try?

TJG
Thanks again Tim,

I'm just extracting the first frame to use as a thumbnail.

I will try ffmpeg. Thanks for pointer. I didn't really know where to
start looking.

Martin
Nov 5 '08 #5

P: n/a
In message <ma**************************************@python.o rg>, Tim Golden
wrote:
Alternatively, you might be able to commandline control
mencoder or ffmpeg itself to do this. Not sure, but there
must be *something* among those millions of command-line
options!
FFmpeg--yes!
Nov 6 '08 #6

P: n/a
Lawrence D'Oliveiro wrote:
In message <ma**************************************@python.o rg>, Tim Golden
wrote:
>Alternatively, you might be able to commandline control
mencoder or ffmpeg itself to do this. Not sure, but there
must be *something* among those millions of command-line
options!

FFmpeg--yes!
Unfortunately it looks like I have the same problem as I do with pyglet
- it's not support by my host.

It looks like I might have to process the files locally and then upload
them. Painful.

Unless anyone else has any suggestions?

Martin
Nov 6 '08 #7

P: n/a
Martin wrote:
Lawrence D'Oliveiro wrote:
>In message <ma**************************************@python.o rg>, Tim
Golden
wrote:
>>Alternatively, you might be able to commandline control
mencoder or ffmpeg itself to do this. Not sure, but there
must be *something* among those millions of command-line
options!

FFmpeg--yes!

Unfortunately it looks like I have the same problem as I do with pyglet
- it's not support by my host.

It looks like I might have to process the files locally and then upload
them. Painful.

Unless anyone else has any suggestions?

Well, since as far as I can see your host won't let you
install anything which isn't there already, you're down to
implementing a Python-only module to read a frame from a
..wmv. Which is, I would suggest, a not inconsiderable task.

Perhaps pre-filtering is the best solution after all.

TJG
Nov 6 '08 #8

P: n/a
Tim Golden wrote:
Martin wrote:
>Lawrence D'Oliveiro wrote:
>>In message <ma**************************************@python.o rg>, Tim
Golden
wrote:

Alternatively, you might be able to commandline control
mencoder or ffmpeg itself to do this. Not sure, but there
must be *something* among those millions of command-line
options!

FFmpeg--yes!

Unfortunately it looks like I have the same problem as I do with
pyglet - it's not support by my host.

It looks like I might have to process the files locally and then
upload them. Painful.

Unless anyone else has any suggestions?


Well, since as far as I can see your host won't let you
install anything which isn't there already, you're down to
implementing a Python-only module to read a frame from a
.wmv. Which is, I would suggest, a not inconsiderable task.

Perhaps pre-filtering is the best solution after all.

TJG
Thanks Lawrence and Tim,

The irony is that I already have a Python only solution - it just
requires 2.5!

I've actually worked out a way to extract and compress just the
thumbnails from my local server and upload them without having to
re-upload the video files (which took days) so I'm happy.

Thanks for the suggestions,

Martin
Nov 6 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.