Capture still image from video/automatically assign P4A file image

9 messages Options
Embed this post
Permalink
Brayton Osgood () Capture still image from video/automatically assign P4A file image
Reply Threaded More More options
Print post
Permalink
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
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Tom Gross () Re: Capture still image from video/automatically assign P4A file image
Reply Threaded More More options
Print post
Permalink
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
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Jean-Michel FRANCOIS () Re: Re: Capture still image from video/automatically assign P4A file image
Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
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
[hidden email]
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


_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Brayton Osgood () Re: Re: Capture still image from video/automatically assign P4A file image
Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Between this and IRC I've got the image capture working. Still have to write the captured image back into Plone, but I think I have that under control. Thanks for all the help,

Brayton

Here is the code I used (for future Googlers):

  context = aq_inner(file)
  movie_data = context.get_data()

  movie_id, movie_name = tempfile.mkstemp('.mov',text=False)
  image_id, image_name = tempfile.mkstemp('jpg', text=False)
  output_id, output_name = tempfile.mkstemp()
  wfile = open(movie_name, 'wb')
  wfile.write(movie_data)
  wfile.close()

  args = "ffmpeg -i %s -ss 1 -an -vframes 1 -f image2 %s" % (movie_name, image_name)
  p = sub.Popen(args, shell=True, stdin=sub.PIPE, stdout=output_name, stderr=sub.STDOUT)


On Sep 23, 2009, at 1:38 AM, Jean-Michel FRANCOIS wrote:

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
[hidden email]
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

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Espen Moe-Nilssen () Re: Re: Capture still image from video/automatically assign P4A file image
Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
If I understand this right and you got this to work:

1) Add a "p4video-file" to plone 
2) The first frame of the image shows as the video/image.

I am pretty sure the people behind p4artists would like that code....


Espen 



Den 23. sep. 2009 kl. 18.19 skrev Brayton Osgood:

Between this and IRC I've got the image capture working. Still have to write the captured image back into Plone, but I think I have that under control. Thanks for all the help,

Brayton

Here is the code I used (for future Googlers):

  context = aq_inner(file)
  movie_data = context.get_data()

  movie_id, movie_name = tempfile.mkstemp('.mov',text=False)
  image_id, image_name = tempfile.mkstemp('jpg', text=False)
  output_id, output_name = tempfile.mkstemp()
  wfile = open(movie_name, 'wb')
  wfile.write(movie_data)
  wfile.close()

  args = "ffmpeg -i %s -ss 1 -an -vframes 1 -f image2 %s" % (movie_name, image_name)
  p = sub.Popen(args, shell=True, stdin=sub.PIPE, stdout=output_name, stderr=sub.STDOUT)


On Sep 23, 2009, at 1:38 AM, Jean-Michel FRANCOIS wrote:

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
[hidden email]
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
_______________________________________________
Product-Developers mailing list


_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Brayton Osgood () Re: Re: Capture still image from video/automatically assign P4A file image
Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Espen,

You do understand me correctly and I have this mostly working as you describe. It works for .mov files, though I haven't been successful with a flash video yet - I still get the solid black background with play arrow. I'm going to keep working on that.

I'm happy to share with p4a, though I haven't received anything but a 503 error at plone4artists.org for the last few weeks. Who should I get in touch with to share it?

Thanks,
Brayton

On Sep 24, 2009, at 12:52 AM, Espen Moe-Nilssen wrote:

If I understand this right and you got this to work:

1) Add a "p4video-file" to plone 
2) The first frame of the image shows as the video/image.

I am pretty sure the people behind p4artists would like that code....


Espen 



Den 23. sep. 2009 kl. 18.19 skrev Brayton Osgood:

Between this and IRC I've got the image capture working. Still have to write the captured image back into Plone, but I think I have that under control. Thanks for all the help,

Brayton

Here is the code I used (for future Googlers):

  context = aq_inner(file)
  movie_data = context.get_data()

  movie_id, movie_name = tempfile.mkstemp('.mov',text=False)
  image_id, image_name = tempfile.mkstemp('jpg', text=False)
  output_id, output_name = tempfile.mkstemp()
  wfile = open(movie_name, 'wb')
  wfile.write(movie_data)
  wfile.close()

  args = "ffmpeg -i %s -ss 1 -an -vframes 1 -f image2 %s" % (movie_name, image_name)
  p = sub.Popen(args, shell=True, stdin=sub.PIPE, stdout=output_name, stderr=sub.STDOUT)


On Sep 23, 2009, at 1:38 AM, Jean-Michel FRANCOIS wrote:

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
[hidden email]
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
_______________________________________________
Product-Developers mailing list



_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Tom Gross () Re: Capture still image from video/automatically assign P4A file image
Reply Threaded More More options
Print post
Permalink
p4a moved to the collective: http://dev.plone.org/old/collective/browser/p4a

-Tom

Brayton Osgood wrote:

> Espen,
>
> You do understand me correctly and I have this mostly working as you
> describe. It works for .mov files, though I haven't been successful with
> a flash video yet - I still get the solid black background with play
> arrow. I'm going to keep working on that.
>
> I'm happy to share with p4a, though I haven't received anything but a
> 503 error at plone4artists.org for the last few weeks. Who should I get
> in touch with to share it?
>
> Thanks,
> Brayton
>
> On Sep 24, 2009, at 12:52 AM, Espen Moe-Nilssen wrote:
>
>> If I understand this right and you got this to work:
>>
>> 1) Add a "p4video-file" to plone
>> 2) The first frame of the image shows as the video/image.
>>
>> I am pretty sure the people behind p4artists would like that code....
>>
>>
>> Espen
>>
>>
>>
>> Den 23. sep. 2009 kl. 18.19 skrev Brayton Osgood:
>>
>>> Between this and IRC I've got the image capture working. Still have
>>> to write the captured image back into Plone, but I think I have that
>>> under control. Thanks for all the help,
>>>
>>> Brayton
>>>
>>> Here is the code I used (for future Googlers):
>>>
>>>   context = aq_inner(file)
>>>   movie_data = context.get_data()
>>>
>>>   movie_id, movie_name = tempfile.mkstemp('.mov',text=False)
>>>   image_id, image_name = tempfile.mkstemp('jpg', text=False)
>>>   output_id, output_name = tempfile.mkstemp()
>>>   wfile = open(movie_name, 'wb')
>>>   wfile.write(movie_data)
>>>   wfile.close()
>>>
>>>   args = "ffmpeg -i %s -ss 1 -an -vframes 1 -f image2 %s" %
>>> (movie_name, image_name)
>>>   p = sub.Popen(args, shell=True, stdin=sub.PIPE, stdout=output_name,
>>> stderr=sub.STDOUT)
>>>
>>>
>>> On Sep 23, 2009, at 1:38 AM, Jean-Michel FRANCOIS wrote:
>>>
>>>> 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
>>>>> [hidden email]
>>>>> 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
>>> _______________________________________________
>>> Product-Developers mailing list
>>> [hidden email]
>>> <mailto:[hidden email]>
>>> http://lists.plone.org/mailman/listinfo/product-developers
>>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Product-Developers mailing list
> [hidden email]
> http://lists.plone.org/mailman/listinfo/product-developers


_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
JonStahl () Re: Re: Capture still image from video/automatically assign P4A file image
Reply Threaded More More options
Print post
Permalink
And, for the record, Nate Aune ([hidden email]), is the founder of
the p4a project. :-)

:jon

On Fri, Sep 25, 2009 at 12:13 AM, Tom Gross <[hidden email]> wrote:

> p4a moved to the collective: http://dev.plone.org/old/collective/browser/p4a
>
> -Tom
>
> Brayton Osgood wrote:
>> Espen,
>>
>> You do understand me correctly and I have this mostly working as you
>> describe. It works for .mov files, though I haven't been successful with
>> a flash video yet - I still get the solid black background with play
>> arrow. I'm going to keep working on that.
>>
>> I'm happy to share with p4a, though I haven't received anything but a
>> 503 error at plone4artists.org for the last few weeks. Who should I get
>> in touch with to share it?
>>
>> Thanks,
>> Brayton
>>
>> On Sep 24, 2009, at 12:52 AM, Espen Moe-Nilssen wrote:
>>
>>> If I understand this right and you got this to work:
>>>
>>> 1) Add a "p4video-file" to plone
>>> 2) The first frame of the image shows as the video/image.
>>>
>>> I am pretty sure the people behind p4artists would like that code....
>>>
>>>
>>> Espen
>>>
>>>
>>>
>>> Den 23. sep. 2009 kl. 18.19 skrev Brayton Osgood:
>>>
>>>> Between this and IRC I've got the image capture working. Still have
>>>> to write the captured image back into Plone, but I think I have that
>>>> under control. Thanks for all the help,
>>>>
>>>> Brayton
>>>>
>>>> Here is the code I used (for future Googlers):
>>>>
>>>>   context = aq_inner(file)
>>>>   movie_data = context.get_data()
>>>>
>>>>   movie_id, movie_name = tempfile.mkstemp('.mov',text=False)
>>>>   image_id, image_name = tempfile.mkstemp('jpg', text=False)
>>>>   output_id, output_name = tempfile.mkstemp()
>>>>   wfile = open(movie_name, 'wb')
>>>>   wfile.write(movie_data)
>>>>   wfile.close()
>>>>
>>>>   args = "ffmpeg -i %s -ss 1 -an -vframes 1 -f image2 %s" %
>>>> (movie_name, image_name)
>>>>   p = sub.Popen(args, shell=True, stdin=sub.PIPE, stdout=output_name,
>>>> stderr=sub.STDOUT)
>>>>
>>>>
>>>> On Sep 23, 2009, at 1:38 AM, Jean-Michel FRANCOIS wrote:
>>>>
>>>>> 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
>>>>>> [hidden email]
>>>>>> 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
>>>> _______________________________________________
>>>> Product-Developers mailing list
>>>> [hidden email]
>>>> <mailto:[hidden email]>
>>>> http://lists.plone.org/mailman/listinfo/product-developers
>>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Product-Developers mailing list
>> [hidden email]
>> http://lists.plone.org/mailman/listinfo/product-developers
>
>
> _______________________________________________
> Product-Developers mailing list
> [hidden email]
> http://lists.plone.org/mailman/listinfo/product-developers
>

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Nate Aune () Re: Re: Capture still image from video/automatically assign P4A file image
Reply Threaded More More options
Print post
Permalink
If you go to plone4artists.org now it will redirect you to dev.plone4artists.org
.

Brayton- it would be great if you could contribute your code to a  
branch in the collective and then we will review it at the video  
sprint in a few weeks in Budapest.

Nate

--
Nate Aune - [hidden email]
http://www.jazkarta.com
Sent from my iPhone

On Oct 2, 2009, at 3:43 PM, Jon Stahl <[hidden email]> wrote:

> And, for the record, Nate Aune ([hidden email]), is the founder of
> the p4a project. :-)
>
> :jon
>
> On Fri, Sep 25, 2009 at 12:13 AM, Tom Gross <[hidden email]>  
> wrote:
>> p4a moved to the collective: http://dev.plone.org/old/collective/browser/p4a
>>
>> -Tom
>>
>> Brayton Osgood wrote:
>>> Espen,
>>>
>>> You do understand me correctly and I have this mostly working as you
>>> describe. It works for .mov files, though I haven't been  
>>> successful with
>>> a flash video yet - I still get the solid black background with play
>>> arrow. I'm going to keep working on that.
>>>
>>> I'm happy to share with p4a, though I haven't received anything  
>>> but a
>>> 503 error at plone4artists.org for the last few weeks. Who should  
>>> I get
>>> in touch with to share it?
>>>
>>> Thanks,
>>> Brayton
>>>
>>> On Sep 24, 2009, at 12:52 AM, Espen Moe-Nilssen wrote:
>>>
>>>> If I understand this right and you got this to work:
>>>>
>>>> 1) Add a "p4video-file" to plone
>>>> 2) The first frame of the image shows as the video/image.
>>>>
>>>> I am pretty sure the people behind p4artists would like that  
>>>> code....
>>>>
>>>>
>>>> Espen
>>>>
>>>>
>>>>
>>>> Den 23. sep. 2009 kl. 18.19 skrev Brayton Osgood:
>>>>
>>>>> Between this and IRC I've got the image capture working. Still  
>>>>> have
>>>>> to write the captured image back into Plone, but I think I have  
>>>>> that
>>>>> under control. Thanks for all the help,
>>>>>
>>>>> Brayton
>>>>>
>>>>> Here is the code I used (for future Googlers):
>>>>>
>>>>>   context = aq_inner(file)
>>>>>   movie_data = context.get_data()
>>>>>
>>>>>   movie_id, movie_name = tempfile.mkstemp('.mov',text=False)
>>>>>   image_id, image_name = tempfile.mkstemp('jpg', text=False)
>>>>>   output_id, output_name = tempfile.mkstemp()
>>>>>   wfile = open(movie_name, 'wb')
>>>>>   wfile.write(movie_data)
>>>>>   wfile.close()
>>>>>
>>>>>   args = "ffmpeg -i %s -ss 1 -an -vframes 1 -f image2 %s" %
>>>>> (movie_name, image_name)
>>>>>   p = sub.Popen(args, shell=True, stdin=sub.PIPE,  
>>>>> stdout=output_name,
>>>>> stderr=sub.STDOUT)
>>>>>
>>>>>
>>>>> On Sep 23, 2009, at 1:38 AM, Jean-Michel FRANCOIS wrote:
>>>>>
>>>>>> 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
>>>>>>> [hidden email]
>>>>>>> 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
>>>>> _______________________________________________
>>>>> Product-Developers mailing list
>>>>> [hidden email]
>>>>> <mailto:[hidden email]>
>>>>> http://lists.plone.org/mailman/listinfo/product-developers
>>>>
>>>
>>>
>>> ---
>>> ---
>>> ------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Product-Developers mailing list
>>> [hidden email]
>>> http://lists.plone.org/mailman/listinfo/product-developers
>>
>>
>> _______________________________________________
>> Product-Developers mailing list
>> [hidden email]
>> http://lists.plone.org/mailman/listinfo/product-developers
>>

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers