Answers.Body: <p>Use</p>
  
  <pre><code>ffmpeg -i input.mp4 -i logo.png \
  -filter_complex "[0]yadif,format=yuv420p[main];[1][main]scale2ref=iw/5:ow*450/450[wm][vid];[vid][wm]overlay=W-w-W*3/100:H-h-H*1/100:enable='gt(t,30)'" \
  -force_key_frames "expr:gte(t,n_forced/2)" -c:v libx264 -crf 23 -c:a copy output.mp4
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-02T08:59:34.493Z
Answers.LastActivityDate: 2019-12-02T08:59:34.493Z
Answers.UserDisplayName: Gyan
Body: <p>I have an ffmpeg command using -vf to deinterlace videos and produce pixel format with 4:2:0 chroma subsampling:</p>
  
  <pre><code>ffmpeg -i input.mp4 -vf yadif,format=yuv420p \ 
  -force_key_frames expr:gte(t\,n_forced/2) \
  -c:v libx264 -crf 23 output.mp4
  </code></pre>
  
  <p>Also I have another ffmpeg command to put on my watermark:</p>
  
  <pre><code>ffmpeg -i input.mp4 -i logo.png \
  -filter_complex "[1][0]scale2ref=iw/5:ow*450/450[wm][vid];[vid][wm]overlay=W-w-W*3/100:H-h-H*1/100:enable='gt(t,30)'" \
  -c:v libx264 -crf 23 output.mp4
  </code></pre>
  
  <p>I tried to put them together and got this error:</p>
  
  <pre><code>-vf/-af/-filter and -filter_complex cannot be used together for the same stream
  </code></pre>
  
  <p>I read that -filter_complex can be used for simple filters, and we can chain the filters together, separated by commas, so I created a new command without -vf:</p>
  
  <pre><code>ffmpeg -i input.mp4 -i logo.png \
  filter_complex "[1][0]scale2ref=iw/5:ow*450/450[wm][vid];[vid][wm]overlay=W-w-W*3/100:H-h-H*1/100:enable='gt(t,30)',yadif,format=yuv420p" -force_key_frames expr:gte(t\,n_forced/2) -c:v libx264 -crf 23 output.mp4
  </code></pre>
  
  <p>Is this the right way to combine these two filters?</p>
  
  <p>The console doesn't show the above error but a new error:</p>
  
  <pre><code>Missing ')' or too many args in 'gte(t\,n_forced/2)'
  Invalid force_key_frames expression 'gte(t\,n_forced/2)'
  Error initializing output stream 0:0 --
  [aac @ 0000022fbe6eacc0] Qavg: 118.000
  [aac @ 0000022fbe6eacc0] 2 frames left in the queue on closing
  Conversion failed!
  </code></pre>
  
  <p>Please help!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-12-13T06:08:07.340Z
Comments.Text: The working answer has been posted below!
Comments.UserDisplayName: David Tran
Tags: <ffmpeg><filter>
Title: Combine -vf yadif,format=yuv420p and -filter_complex for watermark
UserDisplayName: David Tran
ThreadText: # Combine -vf yadif,format=yuv420p and -filter_complex for watermark
  
  (Asked by: username_0 on 2019-12-02)
  
  I have an ffmpeg command using -vf to deinterlace videos and produce pixel format with 4:2:0 chroma subsampling:
  
  ```
  ffmpeg -i input.mp4 -vf yadif,format=yuv420p \ 
  -force_key_frames expr:gte(t\,n_forced/2) \
  -c:v libx264 -crf 23 output.mp4
  
  ```
  
  Also I have another ffmpeg command to put on my watermark:
  
  ```
  ffmpeg -i input.mp4 -i logo.png \
  -filter_complex "[1][0]scale2ref=iw/5:ow*450/450[wm][vid];[vid][wm]overlay=W-w-W*3/100:H-h-H*1/100:enable='gt(t,30)'" \
  -c:v libx264 -crf 23 output.mp4
  
  ```
  
  I tried to put them together and got this error:
  
  ```
  -vf/-af/-filter and -filter_complex cannot be used together for the same stream
  
  ```
  
  I read that -filter\_complex can be used for simple filters, and we can chain the filters together, separated by commas, so I created a new command without -vf:
  
  ```
  ffmpeg -i input.mp4 -i logo.png \
  filter_complex "[1][0]scale2ref=iw/5:ow*450/450[wm][vid];[vid][wm]overlay=W-w-W*3/100:H-h-H*1/100:enable='gt(t,30)',yadif,format=yuv420p" -force_key_frames expr:gte(t\,n_forced/2) -c:v libx264 -crf 23 output.mp4
  
  ```
  
  Is this the right way to combine these two filters?
  
  The console doesn't show the above error but a new error:
  
  ```
  Missing ')' or too many args in 'gte(t\,n_forced/2)'
  Invalid force_key_frames expression 'gte(t\,n_forced/2)'
  Error initializing output stream 0:0 --
  [aac @ 0000022fbe6eacc0] Qavg: 118.000
  [aac @ 0000022fbe6eacc0] 2 frames left in the queue on closing
  Conversion failed!
  
  ```
  
  Please help!
  
  **Tags:** ffmpeg, filter
  
  > **Comments:**
  > **username_0**: The working answer has been posted below!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-12-02. Score: 2 | Accepted answer
  
  Use
  
  ```
  ffmpeg -i input.mp4 -i logo.png \
  -filter_complex "[0]yadif,format=yuv420p[main];[1][main]scale2ref=iw/5:ow*450/450[wm][vid];[vid][wm]overlay=W-w-W*3/100:H-h-H*1/100:enable='gt(t,30)'" \
  -force_key_frames "expr:gte(t,n_forced/2)" -c:v libx264 -crf 23 -c:a copy output.mp4
  
  ```
  
  
  ---
  
  