title: ffmpeg stdin Pipe seeking
body: <p>I'am trying to write some code that is reading from stdin and then trims a video with seeking.
  Thats what I got so far:</p>
  <pre><code>def trim():
              in_use=io.BytesIO()
              process = sp.Popen(shlex.split('ffmpeg -i pipe: -ss 00:00:01.0 -t 00:00:01.4 -c:v libx264 -strict -2 output.mp4'), stdin=sp.PIPE, bufsize=10**8)
              # Pipewriter function
              pipewriter(in_use,process)
              process.wait()
  </code></pre>
  <p>The pipewriter function does look like this:</p>
  <pre><code>def pipewriter():
          video.seek(0)
          for chunk in iter(partial(video.read,1024),b''):
              process.stdin.write(chunk)
          process.stdin.flush()
          process.stdin.close()
  </code></pre>
  <p>The file inside the in_use io.BytesIO object is a valid video and thats not the problem.
  The output file also does get generatet and trimmed correctly so the function does work.
  My problem is that because of seeking and trimming the pipewriter function does write the whole video into the pipe. But the ffmpeg process stops after -t 00:00:01.4 seconds so the rest of the video written in stdin leads to an pipe Error</p>
  <p>Does somebody got a clean solution for that without try except.
  I also do have to trim the video as accurate as possible. The current solution does work good for me.</p>
  <p><strong>Error</strong>:</p>
  <pre><code>   process.stdin.flush()
  BrokenPipeError: [Errno 32] Broken pipe
  </code></pre>