how to crop 1 width by one pixel?

Any other question that don't fit into the other support categorizes.
Post Reply
sung
Posts: 4
Joined: Thu Aug 25, 2016 7:55 am

how to crop 1 width by one pixel?

Post by sung » Thu Aug 25, 2016 8:08 am

I am trying to crop 1 pixel of width.
But the following error come up.

Code: Select all

[Parsed_crop_0 @ 00000000005643e0] Invalid too big or non positive size for width '0' or height '360'
[Parsed_crop_0 @ 00000000005643e0] Failed to configure input pad on Parsed_crop_0
Error configuring complex filters.
Invalid argument
Here is my code.

Code: Select all

ffmpeg -y -i 1.mp4 -i 2.mp4 -filter_complex ^
"[0:0]crop=iw/iw:ih:iw/iw * 0:0, pad=iw/2*20:ih:0:0 [t0]; ^
[1:0]crop=iw/iw:ih:iw/iw * 1:0, pad=iw/2*19:ih:0:0 [t1]; ^
[0:0]crop=iw/iw:ih:iw/iw * 2:0, pad=iw/2*18:ih:0:0 [t2]; ^
[1:0]crop=iw/iw:ih:iw/iw * 3:0, pad=iw/2*17:ih:0:0 [t3]; ^
[0:0]crop=iw/iw:ih:iw/iw * 4:0, pad=iw/2*16:ih:0:0 [t4]; ^
[1:0]crop=iw/iw:ih:iw/iw * 5:0, pad=iw/2*15:ih:0:0 [t5]; ^
[0:0]crop=iw/iw:ih:iw/iw * 6:0, pad=iw/2*14:ih:0:0 [t6]; ^
[1:0]crop=iw/iw:ih:iw/iw * 7:0, pad=iw/2*13:ih:0:0 [t7]; ^
[0:0]crop=iw/iw:ih:iw/iw * 8:0, pad=iw/2*12:ih:0:0 [t8]; ^
[1:0]crop=iw/iw:ih:iw/iw * 9:0, pad=iw/2*11:ih:0:0 [t9]; ^
[0:0]crop=iw/iw:ih:iw/iw * 10:0, pad=iw/2*10:ih:0:0 [t10]; ^
[1:0]crop=iw/iw:ih:iw/iw * 11:0, pad=iw/2*9:ih:0:0 [t11]; ^
[0:0]crop=iw/iw:ih:iw/iw * 12:0, pad=iw/2*8:ih:0:0 [t12]; ^
[1:0]crop=iw/iw:ih:iw/iw * 13:0, pad=iw/2*7:ih:0:0 [t13]; ^
[0:0]crop=iw/iw:ih:iw/iw * 14:0, pad=iw/2*6:ih:0:0 [t14]; ^
[1:0]crop=iw/iw:ih:iw/iw * 15:0, pad=iw/2*5:ih:0:0 [t15]; ^
[0:0]crop=iw/iw:ih:iw/iw * 16:0, pad=iw/2*4:ih:0:0 [t16]; ^
[1:0]crop=iw/iw:ih:iw/iw * 17:0, pad=iw/2*3:ih:0:0 [t17]; ^
[0:0]crop=iw/iw:ih:iw/iw * 18:0, pad=iw/2*2:ih:0:0 [t18]; ^
[1:0]crop=iw/iw:ih:iw/iw * 19:0 [t19]; ^
[t0][t1]overlay=W/10[x1]; ^
[x1][t2]overlay=W/10 * 2[x2]; ^
[x2][t3]overlay=W/10 * 3[x3]; ^
[x3][t4]overlay=W/10 * 4[x4]; ^
[x4][t5]overlay=W/10 * 5[x5]; ^
[x5][t6]overlay=W/10 * 6[x6]; ^
[x6][t7]overlay=W/10 * 7[x7]; ^
[x7][t8]overlay=W/10 * 8[x8]; ^
[x8][t9]overlay=W/10 * 9[x9]; ^
[x9][t10]overlay=W/10 * 10[x10]; ^
[x10][t11]overlay=W/10 * 11[x11]; ^
[x11][t12]overlay=W/10 * 12[x12]; ^
[x12][t13]overlay=W/10 * 13[x13]; ^
[x13][t14]overlay=W/10 * 14[x14]; ^
[x14][t15]overlay=W/10 * 15[x15]; ^
[x15][t16]overlay=W/10 * 16[x16]; ^
[x16][t17]overlay=W/10 * 17[x17]; ^
[x17][t18]overlay=W/10 * 18[x18]; ^
[x18][t19]overlay=W/10 * 19 " -codec:a copy Out.mp4
This video is what I am working on.
fdf.png
fdf.png (45.3 KiB) Viewed 3582 times
As you see, I crop two videos and put them together.
I cut them by 2 pixels.
What I want to do is cut them by 1 pixel and put them together.
Is there any idea?

rogerdpack
Posts: 1876
Joined: Fri Aug 05, 2011 9:56 pm

Re: how to crop 1 width by one pixel?

Post by rogerdpack » Fri Aug 26, 2016 2:09 pm

iw * 0


is that right?

iw - 1 maybe?

mulvya
Posts: 9
Joined: Thu Nov 26, 2015 2:49 pm

Re: how to crop 1 width by one pixel?

Post by mulvya » Fri Aug 26, 2016 5:44 pm

Try adding

Code: Select all

format=yuv444p
before each crop.

sung
Posts: 4
Joined: Thu Aug 25, 2016 7:55 am

Re: how to crop 1 width by one pixel?

Post by sung » Mon Aug 29, 2016 9:09 am

mulvya wrote:Try adding

Code: Select all

format=yuv444p
before each crop.
I tried adding "format=yuv44p". But the error comes up.

Code: Select all

ffmpeg -y -i 1.mp4 -i 2.mp4 -filter_complex ^
" format=yuv444p [0:0]crop=iw/(iw/2):ih:iw/(iw/2) * 0:0, pad=iw*20:ih:0:0 [t0]; ^
I tried like this but i think it is wrong.

Can you give me an example where to put "format=yuv444p"?

mulvya
Posts: 9
Joined: Thu Nov 26, 2015 2:49 pm

Re: how to crop 1 width by one pixel?

Post by mulvya » Mon Aug 29, 2016 9:35 am

Like this:

Code: Select all

ffmpeg -y -i 1.mp4 -i 2.mp4 -filter_complex ^
"[0:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 0:0, pad=iw/2*20:ih:0:0 [t0]; ^
[1:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 1:0, pad=iw/2*19:ih:0:0 [t1]; ^
[0:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 2:0, pad=iw/2*18:ih:0:0 [t2]; ^
[1:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 3:0, pad=iw/2*17:ih:0:0 [t3]; ^
...

sung
Posts: 4
Joined: Thu Aug 25, 2016 7:55 am

Re: how to crop 1 width by one pixel?

Post by sung » Mon Aug 29, 2016 11:53 am

mulvya wrote:Like this:

Code: Select all

ffmpeg -y -i 1.mp4 -i 2.mp4 -filter_complex ^
"[0:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 0:0, pad=iw/2*20:ih:0:0 [t0]; ^
[1:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 1:0, pad=iw/2*19:ih:0:0 [t1]; ^
[0:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 2:0, pad=iw/2*18:ih:0:0 [t2]; ^
[1:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 3:0, pad=iw/2*17:ih:0:0 [t3]; ^
...

Thanks so much !

Now I can crop it by one pixel. but I got another problem.

These commands crop only one video.
1px without one video.png
I inserted white picture and normal video to compare if two videos cropped well or not.

but as you see the picture, can see only one video cropped part. And cannot see a white part.

What will be the problem?? and what is the meaning of yuv444p?? Does "yuv444p"command affect to the cropping two videos?

mulvya
Posts: 9
Joined: Thu Nov 26, 2015 2:49 pm

Re: how to crop 1 width by one pixel?

Post by mulvya » Mon Aug 29, 2016 1:05 pm

Suggest you use the hstack filter:

Code: Select all

ffmpeg -y -i 1.mp4 -i 2.mp4 -filter_complex ^
"[0:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 0:0[t0]; ^
[1:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 1:0[t1]; ^
[0:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 2:0[t2]; ^
[1:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 3:0[t3]; ^
...
[0:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 18:0[t18]; ^
[1:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 19:0[t19]; ^
[t0][t1][t2]....[t19]hstack=20" -codec:a copy Out.mp4
The hstack value refers to the total number of inputs. Padding no longer required.

-----

A shorter way to achieve the end result is to use the geq filter.

Code: Select all

ffmpeg -y -i 1.mp4 -i 2.mp4 -filter_complex ^
"[1]format=yuva420p,geq=lum(X,Y):a='255*mod(X,2)'[v];^
 [0][v]overlay" -codec:a copy Out.mp4

sung
Posts: 4
Joined: Thu Aug 25, 2016 7:55 am

Re: how to crop 1 width by one pixel?

Post by sung » Thu Sep 01, 2016 7:28 am

mulvya wrote:Suggest you use the hstack filter:

Code: Select all

ffmpeg -y -i 1.mp4 -i 2.mp4 -filter_complex ^
"[0:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 0:0[t0]; ^
[1:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 1:0[t1]; ^
[0:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 2:0[t2]; ^
[1:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 3:0[t3]; ^
...
[0:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 18:0[t18]; ^
[1:0]format=yuv444p,crop=iw/iw:ih:iw/iw * 19:0[t19]; ^
[t0][t1][t2]....[t19]hstack=20" -codec:a copy Out.mp4
The hstack value refers to the total number of inputs. Padding no longer required.

-----

A shorter way to achieve the end result is to use the geq filter.

Code: Select all

ffmpeg -y -i 1.mp4 -i 2.mp4 -filter_complex ^
"[1]format=yuva420p,geq=lum(X,Y):a='255*mod(X,2)'[v];^
 [0][v]overlay" -codec:a copy Out.mp4

Thank you so much. Everything works well!! :D

Post Reply
'