Opened 17 months ago

Last modified 7 months ago

#10103 new defect

mov enc: QT doesn't like TIFF GRAY8 in MOV created by ffmpeg

Reported by: ami_stuff Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by ami_stuff)

TIFF GRAY8 in MOV created by ffmpeg decodes incorrectly with QT Player, because QT Player expects 0x28 instead of 0x18 in stsd atom.

Attached patch fixes the problem, but I'm not sure if it's the best solution.

If it's not then please fix the issue whatever way you like.

avctx->bits_per_coded_sample is set to 0x28 for GRAY8 in tiff encoder, but the value is not forwarded to mov muxer, where it's always set to 0:

    case AV_PIX_FMT_GRAY8:
        avctx->bits_per_coded_sample = 0x28;

./ffmpeg -i 160.bmp -vcodec tiff -pix_fmt gray gray.mov
ffmpeg version N-109332-g45ab5307a6 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
  configuration: --enable-libopenjpeg
  libavutil      57. 43.100 / 57. 43.100
  libavcodec     59. 54.100 / 59. 54.100
  libavformat    59. 34.102 / 59. 34.102
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 51.100 /  8. 51.100
  libswscale      6.  8.112 /  6.  8.112
  libswresample   4.  9.100 /  4.  9.100
Input #0, bmp_pipe, from '160.bmp':
  Duration: N/A, bitrate: N/A
  Stream #0:0: Video: bmp, bgr24, 160x120, 25 fps, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (bmp (native) -> tiff (native))
Press [q] to stop, [?] for help
Output #0, mov, to 'gray.mov':
  Metadata:
    encoder         : Lavf59.34.102
  Stream #0:0: Video: tiff (tiff / 0x66666974), gray(pc, progressive), 160x120, q=2-31, 200 kb/s, 25 fps, 12800 tbn
    Metadata:
      encoder         : Lavc59.54.100 tiff
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbframe=    1 fps=0.0 q=-0.0 Lsize=      20kB time=00:00:00.00 bitrate=N/A speed=   0x    
video:19kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.705027%

Attachments (2)

160.bmp (56.3 KB ) - added by ami_stuff 17 months ago.
movenc.patch (670 bytes ) - added by ami_stuff 17 months ago.

Download all attachments as: .zip

Change History (5)

by ami_stuff, 17 months ago

Attachment: 160.bmp added

by ami_stuff, 17 months ago

Attachment: movenc.patch added

comment:1 by ami_stuff, 17 months ago

Description: modified (diff)

comment:2 by ami_stuff, 17 months ago

ffmpeg creates broken TIFF in MOV files for anything, but "-pix_fmt rgb24", where the correct value (0x18) is written into stsd atom.

so TIFF in MOV files created with:

-pix_fmt monow
-pix_fmt monob
-pix_fmt gray
-pix_fmt rgba

currently doesn't decode correctly in QT.

Exactly the same situation happens for -vcodec TARGA in MOV.

-vcodec PNG in MOV seems to encode correct files which decodes ok in QT.

comment:3 by ami_stuff, 7 months ago

see also #5928

Note: See TracTickets for help on using tickets.