Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing python's file like object to ffmpeg via subprocess
    primarykey
    data
    text
    <p>I have a django FileField, which i use to store wav files on the Amazon s3 server. I have set up the celery task to read that file and convert it to mp3 and store it to another FileField. Problem i am facing is that i am unable to pass the input file to ffmpeg as the file is not the physical file on the hard disk drive. To circumvent that, i used stdin to feed the input stream of the file with the django's filefield. Here is the example:</p> <pre><code>output_file = NamedTemporaryFile(suffix='.mp3') subprocess.call(['ffmpeg', '-y', '-i', '-', output_file.name], stdin=recording_wav) </code></pre> <p>where recording_wav file is: , which is actually stored on the amazon s3 server. The error for the above subprocess call is:</p> <pre><code>AttributeError: 'cStringIO.StringO' object has no attribute 'fileno' </code></pre> <p>How can i do this? Thanks in advance for the help.</p> <p><strong>Edit:</strong></p> <p>Full traceback:</p> <pre><code>[2012-07-03 04:09:50,336: ERROR/MainProcess] Task api.tasks.convert_audio[b7ab4192-2bff-4ea4-9421-b664c8d6ae2e] raised exception: AttributeError("'cStringIO.StringO' object has no attribute 'fileno'",) Traceback (most recent call last): File "/home/tejinder/envs/tmai/local/lib/python2.7/site-packages/celery/execute/trace.py", line 181, in trace_task R = retval = fun(*args, **kwargs) File "/home/tejinder/projects/tmai/../tmai/apps/api/tasks.py", line 56, in convert_audio subprocess.Popen(['ffmpeg', '-y', '-i', '-', output_file.name], stdin=recording_wav) File "/usr/lib/python2.7/subprocess.py", line 672, in __init__ errread, errwrite) = self._get_handles(stdin, stdout, stderr) File "/usr/lib/python2.7/subprocess.py", line 1043, in _get_handles p2cread = stdin.fileno() File "/home/tejinder/envs/tmai/local/lib/python2.7/site-packages/django/core/files/utils.py", line 12, in &lt;lambda&gt; fileno = property(lambda self: self.file.fileno) File "/home/tejinder/envs/tmai/local/lib/python2.7/site-packages/django/core/files/utils.py", line 12, in &lt;lambda&gt; fileno = property(lambda self: self.file.fileno) AttributeError: 'cStringIO.StringO' object has no attribute 'fileno' </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload