[Product-Developers] Re: Capture still image from video/automatically assign P4A file image

Jean-Michel FRANCOIS jeanmichel.francois at makina-corpus.com
Wed Sep 23 08:38:10 UTC 2009


Tom Gross a écrit :
> Hi Brayton,
>
>   p4a-video uses the File-content-type, which again uses OFS.File as
> content-class. If you want to access the raw-data use:
>
> atfileobject.getFile().data
>
> or
>
> str(atfileobject.getFile())
>
> If you need a file-like object, you have to do:
>
> stream = StringIO(str(atfileobject.getFile()))
>
> HTH
> -Tom
>
>
> Brayton Osgood wrote:
>   
>> I'm trying to extend P4A Video to automatically generate the file images
>> that can be added to each video via the edit panel of any IVideoEnhanced
>> content. Ideally, the result will be an adapter (I think) that responds
>> to the IVideoEnhanced interface.
>>
>> Right now I'm running into trouble capturing an image from a video file
>> once it's stored in Plone. I've tried calling ffmpeg as a subprocess,
>> but I get an I/O error (see below):
>>
>>     
>>>>> image = subprocess.Popen('ffmpeg -i moviefile -ss 1 -an -vframes 1
>>>>>           
>> -f image2 thumb%2d.jpg', shell=True, stdin=subprocess.PIPE,
>> stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
>>     
>>>>> print image.stdout.read()
>>>>>           
>> FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et
>> al.
>>   configuration: --enable-gpl --enable-pp --enable-swscaler
>> --enable-pthreads --enable-libvorbis --enable-libtheora --enable-libogg
>> --     enable-libgsm --enable-dc1394 --disable-debug --enable-shared
>> --prefix=/usr
>>   libavutil version: 1d.49.3.0
>>   libavcodec version: 1d.51.38.0
>>   libavformat version: 1d.51.10.0
>>   built on Mar 16 2009 21:19:49, gcc: 4.2.4 (Ubuntu 4.2.4-1ubuntu3)
>> moviefile: I/O error occured
>> Usually that means that input file is truncated and/or corrupted.
>>
>> I've tried doing this where 'moviefile' is an <ATFile at
>> /Plone/Members/brayt/jumping2.mov> object, a <p4a.video _ATCTFileVideo>
>> object (applying the IVideo interface to the ATFile), and even the
>> binary data (passed by moviefile.getData()). Each case gives me the same
>> error.
>>
>> I suspect this is because ffmpeg expects to receive certain file types,
>> and Plone files are somehow wrapped so they aren't recognized. I guess
>> my question may boil down to how do I access (and do something useful
>> with) the data in a file that's not normally read by Plone? I suspect
>> that the indexing of PDFs behaves similarly to what I'm hoping to do,
>> but I haven't quite figured out how that works.
>>
>> Any help would be greatly appreciated!
>>
>> Thanks much,
>>
>> Brayton
>>     
>
>
> _______________________________________________
> Product-Developers mailing list
> Product-Developers at lists.plone.org
> http://lists.plone.org/mailman/listinfo/product-developers
>   
To call it with subprocess :
- use mkstemp python module to create a temp file
- write the raw data inside it
- do the subprocess on that new tempfile
- don't forget to delete the temp file
- write the image inside your image field.

-- 
Cordialement,
Jean-Michel FRANCOIS
Makina-Corpus


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20090923/eb71f80c/attachment.html>


More information about the Product-Developers mailing list