Opened 5 years ago

Closed 5 years ago

#570 closed defect (fixed)

Video flipped with inverted colors in flash after transcode

Reported by: brama Owned by: michael
Priority: normal Component: undetermined
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

When transcoding the sample video below, the resulting output file will play OK in ubuntu's video player, but in a flash player it will be flipped and having its colors inverted.

We're currently running an ffmpeg from oct 2010 which does not have this problem. I've tested ffmpeg 0.8.3, 0.8.5 and the master branch from yesterday (libx264 dito) which do exhibit the problem.

After some investigation, it turns out that the corruption only occurs on certain output video sizes, while it works with other sizes.

Command line with output resolution that produces the corrupt output:

./ffmpeg -y  -i '/tmp/in.mp4' -s 320x180 -vcodec libx264 -acodec libfaac /tmp/out.mp4

320x184 output size produces a valid video in flash:

./ffmpeg -y  -i '/tmp/in.mp4' -s 320x184 -vcodec libx264 -acodec libfaac /tmp/out.mp4

But 320x176 is also corrupted:

./ffmpeg -y  -i '/tmp/in.mp4' -s 320x176 -vcodec libx264 -acodec libfaac /tmp/out.mp4

The sample input video is uploaded to upload.ffmpeg.org as /upload/uploaded/flipped_in_flash_after_transcode.mp4 and can also be retrieved here: http://bram.name/flipped_in_flash_after_transcode.mp4

A sample output video with 320x180 dimensions that is corrupt in flash: http://bram.name/output_flipped_in_flash.mp4

You can test the corruption in flash on this jwplayer test page (corrupt output file already filled in): http://developer.longtailvideo.com/trac/testing/?player=v5&skin=&file=http%3A%2F%2Fbram.name%2Foutput_flipped_in_flash.mp4&height=260&width=500

Output for ffmpeg -v 9 -loglevel 99 -i /tmp/in.mp4:

ffmpeg version N-33733-gfe87b2e, Copyright (c) 2000-2011 the FFmpeg developers
  built on Oct 17 2011 21:24:52 with gcc 4.3.2
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfaac --enable-libgsm --enable-libmp3lame --enable-libx264 --enable-libvorbis --enable-libtheora --enable-avfilter --prefix=/home/botr/botr/localroot/opt/encoder --extra-cflags='-I /home/botr/botr/localroot/opt/encoder/include' --extra-ldflags='-L /home/botr/botr/localroot/opt/encoder/lib' --arch=x86_32 --enable-runtime-cpudetect --disabl
e-ffplay --disable-ffserver --disable-ffprobe --disable-doc --enable-libvpx
  libavutil    51. 21. 0 / 51. 21. 0
  libavcodec   53. 20. 1 / 53. 20. 1
  libavformat  53. 16. 0 / 53. 16. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 43. 6 /  2. 43. 6
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x96ebaa0] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x96ebaa0] ISO: File Type Major Brand: mp42
[aac @ 0x96f2bc0] Unsupported bit depth: 0
[h264 @ 0x96f1f90] no picture
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x96ebaa0] All info found
rfps: 0.083333 0.000541
rfps: 0.166667 0.002165
rfps: 0.250000 0.004871
rfps: 0.333333 0.008659
rfps: 0.416667 0.013530
rfps: 0.500000 0.019483
rfps: 29.500000 0.017218
    Last message repeated 1 times

rfps: 29.583333 0.011654
    Last message repeated 1 times
rfps: 29.666667 0.007172
    Last message repeated 1 times
rfps: 29.750000 0.003773
    Last message repeated 1 times
rfps: 29.833333 0.001456
    Last message repeated 1 times
rfps: 29.916667 0.000222
    Last message repeated 1 times
rfps: 30.000000 0.000070
rfps: 30.083333 0.001001
rfps: 30.166667 0.003013
rfps: 30.250000 0.006109
rfps: 30.333333 0.010286
rfps: 30.416667 0.015547
rfps: 59.500000 0.015092
    Last message repeated 1 times
rfps: 59.583333 0.009917
    Last message repeated 1 times
rfps: 59.666667 0.005825
    Last message repeated 1 times
rfps: 59.750000 0.002815
    Last message repeated 1 times
rfps: 59.833333 0.000888
    Last message repeated 1 times
rfps: 59.916667 0.000043

    Last message repeated 1 times
rfps: 29.970030 0.000000
    Last message repeated 1 times
rfps: 59.940060 0.000000
    Last message repeated 1 times
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/in.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isom
    creation_time   : 2008-02-15 20:41:25
  Duration: 00:03:11.72, start: 0.000000, bitrate: 181 kb/s
    Chapter #0.0: start 0.000000, end 191.724854
    Metadata:
      title           :
    Stream #0:0(eng), 30, 1/48000: Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 720x480 [SAR 32:27 DAR 16:9], 1001/60000, 1502 kb/s, SAR 9709:8192 DAR 29127:16384, 29.97 fps, 29.97 tbr, 48k tbn, 59.94 tbc
    Metadata:
      creation_time   : 2008-02-15 20:41:25  
    Stream #0:1(und), 1, 1/48000: Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 104 kb/s
    Metadata:
      creation_time   : 2008-02-15 20:41:25  
    Stream #0:2(eng), 0, 1/48000: Subtitle: mov_text (text / 0x74786574)
    Metadata:
      creation_time   : 2008-02-15 20:41:25  

Change History (18)

comment:1 in reply to: ↑ description Changed 5 years ago by cehoyos

  • Component changed from FFmpeg to undetermined

Replying to brama:

You can test the corruption in flash on this jwplayer test page (corrupt output file already filled in): http://developer.longtailvideo.com/trac/testing/?player=v5&skin=&file=http%3A%2F%2Fbram.name%2Foutput_flipped_in_flash.mp4&height=260&width=500

Does not look corrupted to me...

For mp4 files, I would suggest QuickTime? as reference application, certainly not FlashPlayer?.
Do the output files play correctly with current QuickTime? player?

comment:2 Changed 5 years ago by brama

The intro text of that vid is not mirrored for you in the flash player? I've verified this on osx and linux. It does indeed play fine in QuickTime?.

The issue is that it must work in flash, and a previous version of ffmpeg that we run on production does produce videos without the corruption on the exact same input file with the exact same cmd line. So somewhere along the line this must have been introduced.

comment:3 Changed 5 years ago by cehoyos

If you believe there is a regression, please find the revision introducing it with git bisect.

comment:4 Changed 5 years ago by cehoyos

Afaict, this is a regression in Adobe's Flash Player (it is not reproducible with old versions).
Or can you point to a FFmpeg revision that introduced the problem?

comment:5 Changed 5 years ago by brama

I believe this is a regression somewhere in ffmpeg/x264. Using the older ffmpeg I can still produce a non-corrupted video that will work with the latest adobe flash plugin from the same input file and the same cmd.

I will have to spend some time figuring out how to locate the regression as I'm not very experienced in that field.

comment:6 Changed 5 years ago by brama

I will investigate the approximate time where this change has occurred.

comment:7 Changed 5 years ago by cehoyos

git bisect will show you very fast the version introducing your problem.

comment:8 Changed 5 years ago by brama

Found the culprit, it's commit c8868f28e357e7e6ffe3254d0056b3e8033fe8e5

With just this commit I can repeatedly and without fail confirm that the video will show up corrupted in flash.

comment:9 Changed 5 years ago by RichardD

FYI : I am also getting the same behaviour when converting older videos to H.264. The video is flipped.

comment:10 Changed 5 years ago by brama

I investigated some more. The commit mentioned above fixes 1 video, but breaks another. I have now found the real culprit, and that is commit e7c7b0d000e81d24327602e04d8fed400dbb7193:

Author: Michael Niedermayer <michaelni@gmx.at>
Date:   Fri Apr 1 17:30:45 2011 +0200

    Another aspect ratio fix try. This leaves the setdar addition at the end (preferred by people).
    
    Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Later on, a new commit actually fixes the issue: d1eb50bb29caad9745631759265f475177df99b9

But this commit is 100% reversed in commit d6c858658f2cd5cabbfecc008503c30951256fdd, because "it breaks fate" (?).

It looks like the avfilter option passing has been rewritten entirely, so I can't figure out how to attempt to patch this in master. However, I did notice that explicitly passing '-aspect 1.77' in the cmdline will produce a video that is not flipped or negative.

Last edited 5 years ago by brama (previous) (diff)

comment:11 Changed 5 years ago by cehoyos

Did you already report the regression to Adobe?

comment:12 Changed 5 years ago by brama

Are you suggesting the changes in ffmpeg have nothing to do with it even though they do influence the behavior? I do not have old flash versions to test with.

comment:13 Changed 5 years ago by cehoyos

I do have an old flash version installed, and with it, the problem is not reproducible.

comment:14 Changed 5 years ago by brama

I have tested with Flash 10.0, 10.1 and 10.3. They all exhibit the same problem. Pretty much everyone with Flash installed has one of these versions. So in practice this would mean that, for affected videos, we'd serve broken videos to all of those until they've upgraded to a version in which Adobe has applied a fix. That will take a pretty long time and is therefore not a practical solution.

It seems very obvious that the behavior can be influenced within ffmpeg itself, and all commits that change the behavior that I mentioned above are related to the aspect ratio. It would therefore be very beneficial if we can trick this down and figure out a fix that will work with the install base of Flash.

comment:15 Changed 5 years ago by cehoyos

FYI, it works fine with 10.2.159.1.

comment:16 Changed 5 years ago by brama

I have tried exactly that version as well now on a WinXP box and it is corrupted here. Are we looking at the same generated mp4, http://bram.name/output_flipped_in_flash.mp4 ? Or are you using a self-transcoded mp4? If so, does the link above show corruption? Please clarify. In that case there's a difference in our ffmpeg builds somehow.

comment:17 Changed 5 years ago by terran

Curious if there has been any progress on this ticket. I've experienced the same issue and have found the problem across Windows, Mac and Linux across a large number of Flash versions.

comment:18 Changed 5 years ago by michael

  • Reproduced by developer set
  • Resolution set to fixed
  • Status changed from new to closed

This is a bug in flash player
Ive added a workaround to ffmpeg, which should be in git master in a few moments

Note: See TracTickets for help on using tickets.