<p>Use this:</p>

<pre><code>ffmpeg -i input.mp4  -filter_complex \
"[0:v]crop='if(gte(iw,ih),ih,iw):if(gte(ih,iw),iw,ih)',scale=720x720,split=3[1v][2v][3v]; \
 [1v]trim=0:4.95,setpts=PTS-STARTPTS[v1]; \
 [2v]trim=4.95:6.75,setpts=(PTS-STARTPTS)/0.1[v2]; \
 [3v]trim=6.75:8,setpts=PTS-STARTPTS[v3]; \
 [v1][v2][v3]concat=n=3:v=1:a=0[out]" \
-map [out] -an -c:v libx264 -profile:v high -level 4.1 \
-preset superfast -crf 20 -r 30 output.mp4
</code></pre>

CC BY-SA 3.0
2016-05-06T08:47:07.703Z
2016-05-06T08:54:26.740Z
2016-05-06T08:54:26.740Z
Gyan
<p>I have an <code>ffmpeg</code> command using <code>-vf</code> to square crop a video:</p>

<pre><code>ffmpeg -i input.mp4 -vf \
"crop='if(gte(iw,ih),ih,iw):if(gte(ih,iw),iw,ih)', scale=720x720" \
-an -c:v libx264 -profile:v high -level 4.1 \
-preset superfast -crf 20 output.mp4
</code></pre>

<p>I also have a separate <code>ffmpeg</code> command using <code>-filter_complex</code> to apply a slow motion "profile" (normal speed, then slow, then normal speed) to a video:</p>

<pre><code>ffmpeg -i input.mp4 -filter_complex \
"[0:v]trim=0:4.95,setpts=PTS-STARTPTS[v1]; \
 [0:v]trim=4.95:6.75,setpts=PTS-STARTPTS[v2]; \
 [0:v]trim=6.75:8,setpts=PTS-STARTPTS[v3]; \
 [v2]setpts=PTS/0.1[vslow2]; \
 [v1][vslow2][v3]concat=n=3:v=1:a=0[out]" \
-map [out] -an -c:v libx264 -profile:v high -level 4.1 \
-preset superfast -crf 20 -r 30 output.mp4
</code></pre>

<p>If I try and put them together:</p>

<pre><code>ffmpeg -i input.mp4 -vf "crop='if(gte(iw,ih),ih,iw):if(gte(ih,iw),iw,ih)', scale=720x720" \
-filter_complex \
"[0:v]trim=0:4.95,setpts=PTS-STARTPTS[v1]; \
 [0:v]trim=4.95:6.75,setpts=PTS-STARTPTS[v2]; \
 [0:v]trim=6.75:8,setpts=PTS-STARTPTS[v3]; \
 [v2]setpts=PTS/0.1[vslow2]; \
 [v1][vslow2][v3]concat=n=3:v=1:a=0[out]" \
-map [out] -an -c:v libx264 -profile:v high -level 4.1 \
-preset superfast -crf 20 -r 30 output.mp4
</code></pre>

<p>I then get:</p>

<pre><code>-vf/-af/-filter and -filter_complex cannot be used together for the same stream.
</code></pre>

<p>Is there a way of applying the <code>crop</code> filter to the entire stream, or will I have to apply it to each of the <code>[v1]</code>, <code>[v2]</code>, etc. streams?</p>

<ffmpeg><filter>
ffmpeg: can I crop using vf while also using filter_complex at the same time?
awidgery
# ffmpeg: can I crop using vf while also using filter_complex at the same time?

(Asked by: username_0 on 2016-05-06)

I have an ffmpeg command using -vf to square crop a video:
ffmpeg -i input.mp4 -vf \
"crop='if(gte(iw,ih),ih,iw):if(gte(ih,iw),iw,ih)', scale=720x720" \
-an -c:v libx264 -profile:v high -level 4.1 \
-preset superfast -crf 20 output.mp4

I also have a separate ffmpeg command using -filter_complex to apply a slow motion "profile" (normal speed, then slow, then normal speed) to a video:
ffmpeg -i input.mp4 -filter_complex \
"[0:v]trim=0:4.95,setpts=PTS-STARTPTS[v1]; \
 [0:v]trim=4.95:6.75,setpts=PTS-STARTPTS[v2]; \
 [0:v]trim=6.75:8,setpts=PTS-STARTPTS[v3]; \
 [v2]setpts=PTS/0.1[vslow2]; \
 [v1][vslow2][v3]concat=n=3:v=1:a=0[out]" \
-map [out] -an -c:v libx264 -profile:v high -level 4.1 \
-preset superfast -crf 20 -r 30 output.mp4

If I try and put them together:
ffmpeg -i input.mp4 -vf "crop='if(gte(iw,ih),ih,iw):if(gte(ih,iw),iw,ih)', scale=720x720" \
-filter_complex \
"[0:v]trim=0:4.95,setpts=PTS-STARTPTS[v1]; \
 [0:v]trim=4.95:6.75,setpts=PTS-STARTPTS[v2]; \
 [0:v]trim=6.75:8,setpts=PTS-STARTPTS[v3]; \
 [v2]setpts=PTS/0.1[vslow2]; \
 [v1][vslow2][v3]concat=n=3:v=1:a=0[out]" \
-map [out] -an -c:v libx264 -profile:v high -level 4.1 \
-preset superfast -crf 20 -r 30 output.mp4

I then get:
-vf/-af/-filter and -filter_complex cannot be used together for the same stream.

Is there a way of applying the crop filter to the entire stream, or will I have to apply it to each of the [v1], [v2], etc. streams?

**Tags:** ffmpeg, filter


---

## 1 answers

### Answer by username_1 on 2016-05-06. Score: 4 | Accepted answer

Use this:
ffmpeg -i input.mp4  -filter_complex \
"[0:v]crop='if(gte(iw,ih),ih,iw):if(gte(ih,iw),iw,ih)',scale=720x720,split=3[1v][2v][3v]; \
 [1v]trim=0:4.95,setpts=PTS-STARTPTS[v1]; \
 [2v]trim=4.95:6.75,setpts=(PTS-STARTPTS)/0.1[v2]; \
 [3v]trim=6.75:8,setpts=PTS-STARTPTS[v3]; \
 [v1][v2][v3]concat=n=3:v=1:a=0[out]" \
-map [out] -an -c:v libx264 -profile:v high -level 4.1 \
-preset superfast -crf 20 -r 30 output.mp4


---

