Opened 5 years ago

Last modified 5 years ago

#7752 new defect

Rotation metadata is not honored by crop filter in ffplay

Reported by: Ondřej Žižka Owned by:
Priority: normal Component: ffplay
Version: git-master Keywords: rotate
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

Using the 'crop' filter,
the ffplay preview of cropping the videos that were rotated just by setting the metadata behaves as if there was no rotation.

That means: If I want to crop a rotated video,
ffplay takes the cropping parameters as if it was not rotated;

ffplay -i VIDEO-rot.mp4 -vf 'crop=in_w*(1-0.5-0):in_h*(1-0.31-0.1):in_w*0.5:in_h*0.31'

while the actual cropping takes them properly.

ffmpeg -i VIDEO-rot.mp4 -filter:v 'crop=in_w*(1-0.5-0):in_h*(1-0.31-0.1):in_w*0.5:in_h*0.31' -c:a copy VIDEO-cropped.mp4

How to reproduce:

1) Have an MP4 video
2) Rotate it with metadata:

ffmpeg -i "$INPUT" -metadata:s:v rotate="180" -codec copy "VIDEO-rot.mp4"

3) Preview cropping with ffplay and do the cropping with ffmpeg and notice that the crop filter params need to be rotated.

% ffmpeg -i input ... output
ffmpeg version 4.1-static https://johnvansickle.com/ffmpeg/

Change History (6)

comment:1 by Carl Eugen Hoyos, 5 years ago

Version: 4.1git-master

Is the issue not reproducible with ffmpeg?
Please test current FFmpeg git head and provide command line together with the complete, uncut console output and a sample to make this a valid ticket.

comment:2 by Ondřej Žižka, 5 years ago

Output of FFPLAY:

+ ffplay -i VIDEOa-5.12+01.46.mp4 -vf 'crop=in_w*(1-0.5-0):in_h*(1-0.31-0.1):in_w*0.5:in_h*0.31'
ffplay version 3.4.4-0ubuntu0.18.04.1 Copyright (c) 2003-2018 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'VIDEOa-5.12+01.46.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
  Duration: 00:01:46.01, start: 0.009000, bitrate: 20280 kb/s
    Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080, 20092 kb/s, SAR 1:1 DAR 16:9, 23.86 fps, 23.83 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      handler_name    : VideoHandle
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 190 kb/s (default)
    Metadata:
      handler_name    : SoundHandle
Seek to 40% ( 0:00:42) of total duration ( 0:01:46)       B f=0/0   
+ set +x

comment:3 by Ondřej Žižka, 5 years ago

Output of FFMPEG:

+ ffmpeg -i VIDEOa-5.12+01.46.mp4 -filter:v 'crop=in_w*(1-0.5-0):in_h*(1-0.31-0.1):in_w*0.5:in_h*0.31' -c:a copy VIDEOa-5.12+01.46-#0.31,0,0.1,0.5.mp4
ffmpeg version 4.1-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'VIDEOa-5.12+01.46.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
  Duration: 00:01:46.01, start: 0.009000, bitrate: 20280 kb/s
    Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080, 20092 kb/s, SAR 1:1 DAR 16:9, 23.86 fps, 23.83 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      handler_name    : VideoHandle
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 190 kb/s (default)
    Metadata:
      handler_name    : SoundHandle
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[libx264 @ 0x5474bc0] using SAR=1/1
[libx264 @ 0x5474bc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x5474bc0] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x5474bc0] 264 - core 157 r2935 545de2f - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'VIDEOa-5.12+01.46-#0.31,0,0.1,0.5.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
    Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 960x636 [SAR 1:1 DAR 80:53], q=-1--1, 23.83 fps, 18304 tbn, 23.83 tbc (default)
    Metadata:
      handler_name    : VideoHandle
      encoder         : Lavc58.35.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 190 kb/s (default)
    Metadata:
      handler_name    : SoundHandle
frame= 2529 fps= 56 q=-1.0 Lsize=   17433kB time=00:01:45.98 bitrate=1347.4kbits/s dup=1 drop=0 speed=2.34x    
video:14888kB audio:2471kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.429686%
[libx264 @ 0x5474bc0] frame I:12    Avg QP:20.83  size: 30718
[libx264 @ 0x5474bc0] frame P:637   Avg QP:23.51  size: 11908
[libx264 @ 0x5474bc0] frame B:1880  Avg QP:25.43  size:  3878
[libx264 @ 0x5474bc0] consecutive B-frames:  0.8%  0.2%  0.4% 98.7%
[libx264 @ 0x5474bc0] mb I  I16..4: 12.0% 74.8% 13.2%
[libx264 @ 0x5474bc0] mb P  I16..4:  2.4% 10.1%  0.7%  P16..4: 57.3% 15.0%  7.5%  0.0%  0.0%    skip: 7.0%
[libx264 @ 0x5474bc0] mb B  I16..4:  0.4%  1.2%  0.0%  B16..8: 43.4%  3.1%  0.3%  direct: 3.9%  skip:47.7%  L0:46.0% L1:51.6% BI: 2.4%
[libx264 @ 0x5474bc0] 8x8 transform intra:75.9% inter:84.1%
[libx264 @ 0x5474bc0] coded y,uvDC,uvAC intra: 57.7% 79.5% 14.4% inter: 15.8% 37.0% 0.5%
[libx264 @ 0x5474bc0] i16 v,h,dc,p: 12%  8%  2% 77%
[libx264 @ 0x5474bc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 11% 13%  7% 10% 11%  8% 12%  6%
[libx264 @ 0x5474bc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 15% 11%  6% 10%  9%  7%  7%  4%
[libx264 @ 0x5474bc0] i8c dc,h,v,p: 53% 16% 22% 10%
[libx264 @ 0x5474bc0] Weighted P-Frames: Y:0.8% UV:0.6%
[libx264 @ 0x5474bc0] ref P L0: 51.3% 11.4% 26.4% 10.8%  0.0%
[libx264 @ 0x5474bc0] ref B L0: 89.4%  7.9%  2.7%
[libx264 @ 0x5474bc0] ref B L1: 96.8%  3.2%
[libx264 @ 0x5474bc0] kb/s:1149.32

comment:4 by Ondřej Žižka, 5 years ago

I was never able to compile ffmpeg properly with all features. Are there any statically linked builds of Git master for Linux? Thanks

comment:5 by Carl Eugen Hoyos, 5 years ago

Where did you download the version you tested?

comment:6 by Ondřej Žižka, 5 years ago

The ffplay is from Ubuntu's official repository.
The ffmpeg is from https://www.johnvansickle.com/ffmpeg/
However, ffmpeg behaves as per documentation, only ffplay behaves differently.

Note: See TracTickets for help on using tickets.