Answers.Body: <p>Your current method using the <a href="https://ffmpeg.org/ffmpeg-formats.html#concat-1" rel="noreferrer">concat demuxer</a> while <a href="https://ffmpeg.org/ffmpeg.html#Stream-copy" rel="noreferrer">stream copying</a> is probably the fastest (I'm just counting the <code>ffmpeg</code> time and not any time you take to enter the additional commands). Unfortunately, you have to perform several steps, but the advantage is that your non-filtered segments are not being re-encoded which preserves quality and results in fast processing.</p>
  
  <p>It is possible to do it all in one command with the <a href="https://ffmpeg.org/ffmpeg-filters.html#trim" rel="noreferrer"><code>trim</code></a>, <a href="https://ffmpeg.org/ffmpeg-filters.html#atrim" rel="noreferrer"><code>atrim</code></a>, and <a href="https://ffmpeg.org/ffmpeg-filters.html#concat" rel="noreferrer"><code>concat</code></a> filters, but this will re-encode everything and possibly be slower. You will have to test. However, it may create a more "stable" output if you find your current method to be problematic (which would likely be fairly obvious upon playback). The filter is generally used instead of the demuxer when all streams are being filtered.</p>
  
  <h3>Example using <code>concat</code> filter:</h3>
  
  <pre><code>ffmpeg -i input.mp4 -filter_complex \
  "[0:v]trim=end=10[v0]; \
   [0:a]atrim=end=10[a0]; \
   [0:v]trim=10:40,drawbox=color=invert[v1]; \
   [0:a]atrim=10:40[a1]; \
   [0:v]trim=start=40[v2]; \
   [0:a]atrim=start=40[a2]; \
   [v0][a0][v1][a1][v2][a2]concat=n=3:v=1:a=1[v][a]" \
  -map "[v]" -map "[a]" -movflags +faststart output.mp4
  </code></pre>
  
  <h3>Notes</h3>
  
  <ul>
  <li><p>If you get a weird output refer to the <a href="https://ffmpeg.org/ffmpeg-filters.html#setpts" rel="noreferrer"><code>setpts, asetpts</code></a> filters (search for <code>PTS-STARTPTS</code>).</p></li>
  <li><p>If it is still too slow use a faster x264 preset. See <a href="https://trac.ffmpeg.org/wiki/Encode/H.264" rel="noreferrer">FFmpeg Wiki: H.264 Video Encoding Guide</a>.</p></li>
  <li><p>I assume you're using OS X with the "tessus" build of <code>ffmpeg</code> from your previous FFmpeg question. The default AAC encoder for the tessus build is <code>libvo_aacenc</code>. The native FFmpeg AAC encoder is generally regarded as being slightly better. If you want to use it add <code>-c:a aac -strict experimental</code>. If you want the best supported AAC encoder, <code>libfdk_aac</code>, then use <a href="https://trac.ffmpeg.org/wiki/CompilationGuide/MacOSX" rel="noreferrer">homebrew to compile <code>ffmpeg</code></a>. See <a href="https://trac.ffmpeg.org/wiki/Encode/AAC" rel="noreferrer">FFmpeg Wiki: AAC Encoding Guide</a>.</p></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-04T07:26:13.810Z
Answers.Text: Really, great answer, thank you very much for your great explanation, you did help me a lot.
Answers.UserDisplayName: whitesiroi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-04T06:58:03.250Z
Answers.LastActivityDate: 2015-05-04T06:58:03.250Z
Answers.UserDisplayName: llogan
Body: <p>I used this command <code>ffmpeg -i thevideo.mp4 -c:a copy -vf 'drawbox= : x=0 : y=0 : color=invert:enable=between(t\,11\,39)' output.mp4</code> but it runs very slow.</p>
  
  <p>So, I took another approach, I copy first and last part and run "drawbox" only on selected length, and then adding them all together.</p>
  
  <pre><code>ffmpeg -i thevideo.mp4 -ss 00:00:00 -to 00:00:10 -c copy cut.mp4
  
  ffmpeg -i thevideo.mp4 -ss 00:00:11 -to 00:00:39 -c:a copy -vf 'drawbox= : x=0 : y=0 : color=invert' cut2.mp4
  
  ffmpeg -i thevideo.mp4 -ss 00:00:40 -c copy cut3.mp4
  
  ffmpeg -f concat -i mylist.txt -c copy output.mp4
  </code></pre>
  
  <p>content of <code>mylist.txt:</code></p>
  
  <pre><code>file 'cut1.mp4'
  file 'cut2.mp4'
  file 'cut3.mp4'
  </code></pre>
  
  <p>Can I run it in one command and have the same speed or even faster but without cutting and concatenating the parts of the video?</p>
  
Tags: <ffmpeg>
Title: Can I run this in one command line (ffmpeg)
UserDisplayName: whitesiroi
ThreadText: # Can I run this in one command line (ffmpeg)
  
  (Asked by: username_0 on 2015-05-04)
  
  I used this command `ffmpeg -i thevideo.mp4 -c:a copy -vf 'drawbox= : x=0 : y=0 : color=invert:enable=between(t\,11\,39)' output.mp4` but it runs very slow.
  
  So, I took another approach, I copy first and last part and run "drawbox" only on selected length, and then adding them all together.
  
  ```
  ffmpeg -i thevideo.mp4 -ss 00:00:00 -to 00:00:10 -c copy cut.mp4
  
  ffmpeg -i thevideo.mp4 -ss 00:00:11 -to 00:00:39 -c:a copy -vf 'drawbox= : x=0 : y=0 : color=invert' cut2.mp4
  
  ffmpeg -i thevideo.mp4 -ss 00:00:40 -c copy cut3.mp4
  
  ffmpeg -f concat -i mylist.txt -c copy output.mp4
  
  ```
  
  content of `mylist.txt:`
  
  ```
  file 'cut1.mp4'
  file 'cut2.mp4'
  file 'cut3.mp4'
  
  ```
  
  Can I run it in one command and have the same speed or even faster but without cutting and concatenating the parts of the video?
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-05-04. Score: 5 | Accepted answer
  
  Your current method using the [concat demuxer](https://ffmpeg.org/ffmpeg-formats.html#concat-1) while [stream copying](https://ffmpeg.org/ffmpeg.html#Stream-copy) is probably the fastest (I'm just counting the `ffmpeg` time and not any time you take to enter the additional commands). Unfortunately, you have to perform several steps, but the advantage is that your non-filtered segments are not being re-encoded which preserves quality and results in fast processing.
  
  It is possible to do it all in one command with the [`trim`](https://ffmpeg.org/ffmpeg-filters.html#trim), [`atrim`](https://ffmpeg.org/ffmpeg-filters.html#atrim), and [`concat`](https://ffmpeg.org/ffmpeg-filters.html#concat) filters, but this will re-encode everything and possibly be slower. You will have to test. However, it may create a more "stable" output if you find your current method to be problematic (which would likely be fairly obvious upon playback). The filter is generally used instead of the demuxer when all streams are being filtered.
  
  ### Example using `concat` filter:
  
  ```
  ffmpeg -i input.mp4 -filter_complex \
  "[0:v]trim=end=10[v0]; \
   [0:a]atrim=end=10[a0]; \
   [0:v]trim=10:40,drawbox=color=invert[v1]; \
   [0:a]atrim=10:40[a1]; \
   [0:v]trim=start=40[v2]; \
   [0:a]atrim=start=40[a2]; \
   [v0][a0][v1][a1][v2][a2]concat=n=3:v=1:a=1[v][a]" \
  -map "[v]" -map "[a]" -movflags +faststart output.mp4
  
  ```
  
  ### Notes
  
  * If you get a weird output refer to the [`setpts, asetpts`](https://ffmpeg.org/ffmpeg-filters.html#setpts) filters (search for `PTS-STARTPTS`).
  * If it is still too slow use a faster x264 preset. See [FFmpeg Wiki: H.264 Video Encoding Guide](https://trac.ffmpeg.org/wiki/Encode/H.264).
  * I assume you're using OS X with the "tessus" build of `ffmpeg` from your previous FFmpeg question. The default AAC encoder for the tessus build is `libvo_aacenc`. The native FFmpeg AAC encoder is generally regarded as being slightly better. If you want to use it add `-c:a aac -strict experimental`. If you want the best supported AAC encoder, `libfdk_aac`, then use [homebrew to compile `ffmpeg`](https://trac.ffmpeg.org/wiki/CompilationGuide/MacOSX). See [FFmpeg Wiki: AAC Encoding Guide](https://trac.ffmpeg.org/wiki/Encode/AAC).
  
  > **Comments:**
  > **username_0**: Really, great answer, thank you very much for your great explanation, you did help me a lot.  
  
  ---
  
  