Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#1191 closed defect (fixed)

qt tiff enc: make output compatible with quitcktime

Reported by: ami_stuff Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: mov tif
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

http://ffmpeg.org/trac/ffmpeg/raw-attachment/ticket/1167/j.asf

the output from

ffmpeg -i j.asf -an -vcodec tiff -pix_fmt (any) out.mov

is always identified by quicktime as 24bpp and is decoded incorrectly.

I have found out where is a problem, please look at the attached screenshot.

The left file is an unmodified output from:

ffmpeg -i j.asf -vcodec tiff -pix_fmt gray out.mov

conversion, the right file is modified by me (to values which are present in QT TIFF 256gray generated by QuickTime) and after this change the file is identified and decoded correctly by QuickTime.

(for monob 18 FF FF should be repleaced by 01 00 01)

Attachments (6)

qttiff.jpg (101.8 KB ) - added by ami_stuff 12 years ago.
patchtiffmov.diff (1.6 KB ) - added by Carl Eugen Hoyos 12 years ago.
pal8.bmp (769.1 KB ) - added by ami_stuff 12 years ago.
pal8.mov (759.5 KB ) - added by ami_stuff 12 years ago.
patchpngtga.diff (1.8 KB ) - added by Carl Eugen Hoyos 12 years ago.
gray.mov (19.9 KB ) - added by ami_stuff 12 years ago.

Download all attachments as: .zip

Change History (17)

by ami_stuff, 12 years ago

Attachment: qttiff.jpg added

comment:1 by ami_stuff, 12 years ago

the same problem (and fix) for -vcodec png and targa

comment:2 by Carl Eugen Hoyos, 12 years ago

Keywords: mov tif added
Version: unspecifiedgit-master

Does it work with "28 FF FF"?

The relevant line in libavformat/movenc.c is 1064, "avio_wb16(pb, 0x18); /* Reserved */"

comment:3 by ami_stuff, 12 years ago

yes it seems enough to modify only this one value to number of bpp to make the file correctly recognized by qt

monob/w: 01
gray: 28
rgb: 18
rgba: 20
pal8: 08 (wrong palette/colors, probably unrelated issue)

by Carl Eugen Hoyos, 12 years ago

Attachment: patchtiffmov.diff added

comment:4 by Carl Eugen Hoyos, 12 years ago

Status: newopen

Could you test if attached patch fixes RGBA and monob?
Does it also work for RGB48 and RGBA64?

comment:5 by ami_stuff, 12 years ago

monob/w, rgb24 and rgba deocdes correctly with attached patch

pal8 have wrong colors (see pal8.bmp), maybe problem with endianness?

rgb48/64 is not supported by qt even in tiff

by ami_stuff, 12 years ago

Attachment: pal8.bmp added

by ami_stuff, 12 years ago

Attachment: pal8.mov added

by Carl Eugen Hoyos, 12 years ago

Attachment: patchpngtga.diff added

comment:6 by Carl Eugen Hoyos, 12 years ago

Resolution: fixed
Status: openclosed

tiff should be fixed as far as possible, could you test attached patch with png and targa?

comment:7 by ami_stuff, 12 years ago

targa:

qt decodes correctly all modes of targa except rgb555le, but when I add

    case PIX_FMT_RGB555LE:
+        avctx->bits_per_coded_sample = 16;
        pkt->data[2]  = TGA_RGB;    /* uncompresses true-color image */
        pkt->data[16] = 16;         /* bpp */
        break;

then I get correct output.

The problem is that avctx->bits_per_coded_sample is set to 15 for rgb555le mode:

    avctx->bits_per_coded_sample = av_get_bits_per_pixel(&av_pix_fmt_descriptors[avctx->pix_fmt]);
+    av_log(avctx, AV_LOG_INFO, "bits_per_coded_sample: %d\n", avctx->bits_per_coded_sample);
    switch(avctx->pix_fmt) {

png:

qt decodec correctly monob/rgb24/rgba/gray/pal8 (wrong colors)

gray16/rgb48/rgba64 doesn't work (black screen)

comment:8 by Carl Eugen Hoyos, 12 years ago

Could you test ffmpeg -i input -vcodec png out.avi with WMP and different pix_fmts with and without this patch (if this works at all with -pix_fmt rgb24)?
http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/143645

comment:9 by ami_stuff, 12 years ago

I have installed CorePNG codec, so WMP is able to play output avi from this:

ffmpeg -i test.bmp -pix_fmt <format> -vtag PNG1 out.avi

and WMP plays correctly (with and without your patch) monob/gray/pal8/rgb24 and rgba.

VirtualDub is not so happy:

monob/gray/pal8 decodes incorrectly

rgb24/rgba: first frame decodes ok, next frames are upside-down

but this in unrealted to your patch, so in short your patch shouldn't break anything for at least CorePNG codec in AVI.

comment:10 by Elon Musk, 12 years ago

Are you sure that for gray8 in mov bpp is set to 0x28 (40)?

by ami_stuff, 12 years ago

Attachment: gray.mov added

comment:11 by ami_stuff, 12 years ago

I attached qt tiff 256 grays.

Note: See TracTickets for help on using tickets.