Opened 7 years ago

Closed 17 months ago

#6370 closed defect (fixed)

Change in rotate metadata treatment between ffmpeg 3.2 and ffmpeg 3.3

Reported by: tamc Owned by:
Priority: important Component: ffmpeg
Version: git-master Keywords: rotate regression
Cc: deim@seznam.cz Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Hello

I'm not sure if this is a deliberate change, but given a h264 video with rotate=90 in its meta data, when you then rotated the video using the command below, the output video used to have no rotate metadata. As of 3.3, it retains the metadata which makes the output display incorrectly.

Summary of the bug:
How to reproduce:

ffmpeg version 3.2.4:

ffmpeg -noautorotate -i original.mp4 -metadata:s:v rotate=0 -vf scale=640:480,transpose=clock  -f mp4 -y rotated.mp4
... output all ok ...

ffprobe -i rotated.mp4
... snip ...
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'rotated.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.56.101
  Duration: 00:00:08.24, start: 0.000000, bitrate: 1298 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x640, 1181 kb/s, 14.92 fps, 14.92 tbr, 11456 tbn, 29.83 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 120 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

ffmpeg version 3.3:

ffmpeg -noautorotate -i original.mp4 -metadata:s:v rotate=0 -vf scale=640:480,transpose=clock  -f mp4 -y rotated.mp4
... all looks ok ...

ffprobe  -i rotated.mp4
... snip ...
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'rotated.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.71.100
  Duration: 00:00:08.24, start: 0.000000, bitrate: 1299 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x640, 1182 kb/s, 14.92 fps, 14.92 tbr, 11456 tbn, 29.83 tbc (default)
    Metadata:
      rotate          : 90                                  <---- DIFFERENCE HERE
      handler_name    : VideoHandler
    Side data:
      displaymatrix: rotation of -90.00 degrees
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 120 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

Note the difference in the metadata in the second output.

I've verified that HEAD appears to give the same result at 3.3

Is this a bug? Or have we been using ffmpeg incorrectly?

Our goal is to resize videos and transpose them so they are the same way up (we use ffprobe to check their incoming rotation, and then apply the appropriate transpose flags)

Attachments (2)

original.mp4 (782.5 KB ) - added by tamc 7 years ago.
0001-Fix-rotation-metadata-override-when-transcoding.patch (1.2 KB ) - added by TheTroll 5 years ago.
Fix rotation override when transcoding

Download all attachments as: .zip

Change History (15)

by tamc, 7 years ago

Attachment: original.mp4 added

comment:1 by tamc, 7 years ago

I realise I should have put the output of ffprobe on the original.mp4 file so you can see that it starts with the rotate metadata, which is removed in ffmpeg 3.2 but kept in ffmpeg 3.3:

ffprobe -i original.mp4
..snip...
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'original.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2016-03-18T15:03:53.000000Z
  Duration: 00:00:08.19, start: 0.000000, bitrate: 3099 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x480, 2971 kb/s, 14.91 fps, 14.92 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      rotate          : 90
      creation_time   : 2016-03-18T15:03:53.000000Z
      handler_name    : VideoHandle
    Side data:
      displaymatrix: rotation of -90.00 degrees
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 123 kb/s (default)
    Metadata:
      creation_time   : 2016-03-18T15:03:53.000000Z
      handler_name    : SoundHandle

comment:2 by Carl Eugen Hoyos, 7 years ago

Please test current FFmpeg git head and provide the command line that allows to reproduce the issue together with the complete, uncut console output to make this a valid ticket.

comment:3 by tamc, 7 years ago

Sorry my original ticket wasn't clear.

Tested against current git head.

Steps to reproduce:

  1. Download the attached original.mp4 (or any other h264 file with a "rotate : 90" in its metadata
  2. ffmpeg -noautorotate -i original.mp4 -metadata:s:v rotate=0 -vf scale=640:480,transpose=clock -f mp4 -y rotated.mp4
  3. ffprobe -i rotated.mp4
  4. Note the (for me, unexpected) presence of Metadata: rotate : 90 in the output.

That metadata was not there in previous versions of ffmpeg.

Full output:

ffmpeg -noautorotate -i original.mp4 -metadata:s:v rotate=0 -vf scale=640:480,transpose=clock  -f mp4 -y rotated.mp4

ffmpeg version git-2017-05-04-d2657d2 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-d2657d2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
  libavutil      55. 61.100 / 55. 61.100
  libavcodec     57. 93.100 / 57. 93.100
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 88.100 /  6. 88.100
  libavresample   3.  6.  0 /  3.  6.  0
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'original.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp41mp42isom
    creation_time   : 2017-05-04T15:44:25.000000Z
  Duration: 00:00:02.05, start: 0.000000, bitrate: 3126 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x480, 2962 kb/s, 14.91 fps, 14.92 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      rotate          : 90
      creation_time   : 2017-05-04T15:44:25.000000Z
      handler_name    : Core Media Video
    Side data:
      displaymatrix: rotation of -90.00 degrees
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 111 kb/s (default)
    Metadata:
      creation_time   : 2017-05-04T15:44:25.000000Z
      handler_name    : Core Media Audio
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7fe46000ea00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7fe46000ea00] profile High, level 2.2
[libx264 @ 0x7fe46000ea00] 264 - core 148 r2748 97eaef2 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - 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=6 lookahead_threads=1 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=14 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 'rotated.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp41mp42isom
    encoder         : Lavf57.72.101
    Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 480x640, q=-1--1, 14.92 fps, 11456 tbn, 14.92 tbc (default)
    Metadata:
      encoder         : Lavc57.93.100 libx264
      creation_time   : 2017-05-04T15:44:25.000000Z
      handler_name    : Core Media Video
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
      displaymatrix: rotation of -90.00 degrees
    Stream #0:1(und): Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2017-05-04T15:44:25.000000Z
      handler_name    : Core Media Audio
      encoder         : Lavc57.93.100 aac
frame=   31 fps=0.0 q=-1.0 Lsize=     306kB time=00:00:02.05 bitrate=1216.8kbits/s speed=3.18x
video:279kB audio:24kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.774942%
[libx264 @ 0x7fe46000ea00] frame I:1     Avg QP:23.06  size: 16177
[libx264 @ 0x7fe46000ea00] frame P:10    Avg QP:24.86  size: 12260
[libx264 @ 0x7fe46000ea00] frame B:20    Avg QP:26.12  size:  7304
[libx264 @ 0x7fe46000ea00] consecutive B-frames:  6.5% 12.9% 29.0% 51.6%
[libx264 @ 0x7fe46000ea00] mb I  I16..4:  9.2% 63.4% 27.4%
[libx264 @ 0x7fe46000ea00] mb P  I16..4:  5.8% 30.1%  8.8%  P16..4: 32.4% 15.7%  4.9%  0.0%  0.0%    skip: 2.3%
[libx264 @ 0x7fe46000ea00] mb B  I16..4:  1.1%  4.6%  1.5%  B16..8: 40.0% 17.1%  4.6%  direct:13.2%  skip:17.9%  L0:58.6% L1:26.7% BI:14.8%
[libx264 @ 0x7fe46000ea00] 8x8 transform intra:66.1% inter:69.7%
[libx264 @ 0x7fe46000ea00] coded y,uvDC,uvAC intra: 75.3% 74.5% 22.0% inter: 41.5% 44.1% 0.4%
[libx264 @ 0x7fe46000ea00] i16 v,h,dc,p: 11% 49%  9% 30%
[libx264 @ 0x7fe46000ea00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  9% 45% 11%  4%  5%  4% 10%  4%  8%
[libx264 @ 0x7fe46000ea00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 48%  9%  4%  5%  4% 11%  3%  5%
[libx264 @ 0x7fe46000ea00] i8c dc,h,v,p: 38% 39% 16%  8%
[libx264 @ 0x7fe46000ea00] Weighted P-Frames: Y:20.0% UV:10.0%
[libx264 @ 0x7fe46000ea00] ref P L0: 63.7% 12.7% 19.2%  4.3%  0.2%
[libx264 @ 0x7fe46000ea00] ref B L0: 89.0%  8.8%  2.2%
[libx264 @ 0x7fe46000ea00] ref B L1: 98.8%  1.2%
[libx264 @ 0x7fe46000ea00] kb/s:1096.54
[aac @ 0x7fe460010200] Qavg: 14239.845

ffprobe  -i rotated.mp4

ffprobe version git-2017-05-04-d2657d2 Copyright (c) 2007-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-d2657d2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
  libavutil      55. 61.100 / 55. 61.100
  libavcodec     57. 93.100 / 57. 93.100
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 88.100 /  6. 88.100
  libavresample   3.  6.  0 /  3.  6.  0
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'rotated.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.72.101
  Duration: 00:00:02.08, start: 0.000000, bitrate: 1203 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x640, 1099 kb/s, 14.92 fps, 14.92 tbr, 11456 tbn, 29.83 tbc (default)
    Metadata:
      rotate          : 90 <--- UNEXPECTED, BUG?
      handler_name    : VideoHandler
    Side data:
      displaymatrix: rotation of -90.00 degrees
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 95 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

comment:4 by Carl Eugen Hoyos, 7 years ago

Component: undeterminedffmpeg
Priority: normalimportant
Reproduced by developer: set
Status: newopen

comment:5 by Carl Eugen Hoyos, 7 years ago

Keywords: regression added

comment:6 by d3im, 7 years ago

Cc: deim@seznam.cz added

comment:7 by d3im, 7 years ago

Cc: deim@seznam.cz removed

comment:8 by d3im, 7 years ago

Cc: deim@seznam.cz added

comment:9 by Carl Eugen Hoyos, 5 years ago

Keywords: rotate added

by TheTroll, 5 years ago

Fix rotation override when transcoding

comment:10 by bort, 5 years ago

Whats the current status on this issue?

comment:11 by bort, 4 years ago

Any updates or at least a workaround?

Last edited 4 years ago by bort (previous) (diff)

in reply to:  11 comment:12 by d3im, 4 years ago

Replying to bort:

Any updates or at least a workaround?

https://trac.ffmpeg.org/ticket/8329#comment:6

comment:13 by Thilo Borgmann, 17 months ago

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.