VideoHelp Forum
+ Reply to Thread
Results 1 to 10 of 10
Thread
  1. Member
    Join Date
    Feb 2021
    Location
    127.0.0.1
    Search Comp PM
    There is BD in 1080p. It is very old and remastered mopic, it real size is 1438×1078 (2px in top and left/rigth both 241px). I cropped to image size and want to upscale to make valid image ratio 4:3. But if I set left rectangle position to 241 I have got 1px black line on the right, if 242 there is the same line on the left. This is problem with scale. What to do with this to make valid image?

    Code:
    -vf "crop=1438:1078:241:2,scale=1440x1080:flags=bicubic,setsar=1:1"
    Quote Quote  
  2. Maybe the real size is 1436x1078
    Quote Quote  
  3. Your source is probably YUV 4:2:0 and can't be cropped on odd pixel boundaries. So ffmpeg is quietly changing your 241 x offset to 240 or 242:

    Code:
    -vf "crop=1438:1078:240:2,scale=1440x1080:flags=bicubic,setsar=1:1"
    Quote Quote  
  4. Member
    Join Date
    Feb 2021
    Location
    127.0.0.1
    Search Comp PM
    Code:
    Video #1
    ID                             : 4113 (0x1011)
    Menu ID                        : 1 (0x1)
    Format                         : AVC
    Format/Info                    : Advanced Video Codec
    Format profile                 : High@L4.1
    Format settings                : CABAC / 3 Ref Frames
    Format settings, CABAC         : Yes
    Format settings, Reference fra : 3 frames
    Format settings, GOP           : M=3, N=24
    Codec ID                       : 27
    Duration                       : 1 h 3 min
    Width                          : 1 920 pixels
    Height                         : 1 080 pixels
    Display aspect ratio           : 16:9
    Frame rate                     : 23.976 (24000/1001) FPS
    Color space                    : YUV
    Chroma subsampling             : 4:2:0
    Bit depth                      : 8 bits
    Scan type                      : Progressive
    format_identifier              : HDMV
    Source                         : 00003.m2ts / 00003.m2ts
    When I saved frame, cropped in Photoshop all what is black, in result I have got 1438×1078.
    When I tried offset 240, black line on the left appeared.

    Maybe above MediaInfo will be helpful? I don't understand this stream
    Quote Quote  
  5. It's what jagabo said, the chroma subsampling prevent you from cropping by single pixels

    The "dimensions" of the planes are different for 4:2:0 chroma subsampling
    Y=1920x1080
    Cb=960x540
    Cr=960x540

    A workaround is if you convert to 4:4:4, you can and crop by single pixels (and back to 4:2:0 if desired) . This "resamples" the CbCr planes so they are 1920x1080 too.

    Code:
    -vf "format=yuv444p,crop=1438:1078:241:2,scale=1440x1080:flags=bicubic,setsar=1:1,format=yuv420p"
    Quote Quote  
  6. Note that converting to yuv 4:4:4, cropping on odd boundaries, and converting back to yuv 4:2:0, will blur the chroma. Scaling by small percentages will also create moire artifacts and blurring of chroma and luma. I hope you have a good reason to be doing this.
    Quote Quote  
  7. -vf "crop=1438:1078:0:0,setsar=1:1"
    works here fine on a avc movie with 4:2:0 chroma subsampling
    Quote Quote  
  8. Originally Posted by ProWo View Post
    -vf "crop=1438:1078:0:0,setsar=1:1"
    works here fine on a avc movie with 4:2:0 chroma subsampling
    Why wouldn't it?
    Quote Quote  
  9. Oh, I just noticed that ffmpeg's crop filter has an "exact" option that will let it crop YV12 at odd boundaries:

    Code:
    -vf "crop=1438:1078:241:2:exact=1,scale=1440x1080:flags=bicubic,setsar=1:1"
    Quote Quote  
  10. Member
    Join Date
    Feb 2021
    Location
    127.0.0.1
    Search Comp PM
    Thanks guys! All is fixed by exact crop parameter. Now image is perfect, without any black strips or other artifacts.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!