title: Can you split a file using ffmpeg directly from a db?
body: <p>I am splitting a file using ffmpeg and python. I am able split a file if I input a file path, but if I send in the file itself from my mongodb, it errors out. Is there a way to get ffmpeg to run using the file instead of the path to the file?</p>
  
  <p>python code:</p>
  
  <pre><code>args = [ffmpeg_binary,
                           "-v", "quiet",
                           "-y", "-i", video_file, "-vcodec", "copy", "-acodec", "copy",
                   "-ss", "00:00:00", "-t", "00:00:10", "-sn",
                   output_file_name ]
  
  pipe = sp.Popen(args)
  </code></pre>
  
  <p>if video_file is a <code>gridfs.grid_file.GridOut</code> object or a <code>(gridfs.grid_file.GridOut object).read()</code>, I get:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/dev/youniversity/test.py", line 21, in &lt;module&gt;
      split_vid_from_file(vid_file)
    File "C:\dev\youniversity\src\lib\ffmpeg_lib.py", line 107, in split_vid_from_file
      pipe = sp.Popen(args)
    File "C:\Python27\lib\subprocess.py", line 709, in __init__
      errread, errwrite)
    File "C:\Python27\lib\subprocess.py", line 957, in _execute_child
      startupinfo)
  TypeError: must be string without null bytes or None, not str
  </code></pre>
  
  <p>How do I split the video directly from the DB?</p>
  
  <p>EDIT: I found that you can do this:</p>
  
  <pre><code>... "-y", "-", ... 
  
  pipe = sp.Popen(args, stdin=sp.PIPE)
  </code></pre>
  
  <p>but I don't want the user to type input, I want to pipe in the variable.</p>