Opened 8 years ago
Closed 8 years ago
#5071 closed defect (fixed)
FFmpeg doesn't use the correct palette when playing Apple Graphics (SMC) in Matroska
Reported by: | matsp888 | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avformat |
Version: | git-master | Keywords: | mkv |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | yes | |
Analyzed by developer: | no |
Description
I know this isn't really an urgent issue, more towards exotic actually. I just wanted to mention that FFmpeg doesn't use the correct palette when playing Apple Graphics (SMC) encoded video in Matroska. The question is if it uses a specific palette whatsoever, since most of the output is just black. I should add that it has no problems playing Apple Graphics in QuickTime, but that is another story...
Attachments (5)
Change History (62)
comment:1 by , 8 years ago
by , 8 years ago
Attachment: | aletrek.mkv added |
---|
comment:3 by , 8 years ago
How did you create the file?
Which application plays the file correctly?
Please provide a command line that allows to reproduce your issue together with the complete, uncut console output to make this a valid ticket.
comment:4 by , 8 years ago
The sample file is created with mkvmerge. I have also tried to convert with FFmpeg, to no avail. It's not really the file that is invalid, since the private data in it is alright (it contains all of the 'stsd' atom. No application plays the file correctly, since I am in Linux, and every player I have here relies on libavcodec/libavformat (unfortunately). There is really no need to provide a command line, just play the sample file in MPlayer or FFplay, and you will see that most of the output is black.
comment:5 by , 8 years ago
A command line makes no difference, so to say. It's about the video display, not any textual output.
comment:6 by , 8 years ago
I should add that the source QuickTime file (and the resulting MAtroska file) doesn't contain any palette in the 'stsd' atom (or private data in the case of Matroska), hence FFmpeg has to use the default Macintosh palette, which is does correctly when processing the original QuickTime file, but not in the case of the Matroska file.
comment:7 by , 8 years ago
Resolution: | → needs_more_info |
---|---|
Status: | new → closed |
Please reopen this ticket if you can provide the missing information.
comment:10 by , 8 years ago
Resolution: | needs_more_info |
---|---|
Status: | closed → reopened |
comment:11 by , 8 years ago
What do you need? The command line "mplayer aletrek.mkv"? Quite useless, isn't it? I told you everything about the issue already.
comment:12 by , 8 years ago
Resolution: | → needs_more_info |
---|---|
Status: | reopened → closed |
Please reopen this ticket if you can provide the FFmpeg command line that allows to reproduce the issue.
comment:13 by , 8 years ago
Resolution: | needs_more_info |
---|---|
Status: | closed → reopened |
Are you blind? FFplay aletrek.mkv or MPlayer aletrek.mkv, doesn't mattere since MPlayer uses libavformat/libavcodec as well.
comment:14 by , 8 years ago
Read what I've written instead of automatically spitting out useless instructions.
comment:16 by , 8 years ago
You seem to like bitching, judging by what I've read in other tickets. It won't work with me.
comment:17 by , 8 years ago
Resolution: | → needs_more_info |
---|---|
Status: | reopened → closed |
Please reopen this ticket only if you can provide the FFmpeg command line that allows to reproduce the issue together with the complete, uncut console output.
comment:18 by , 8 years ago
Resolution: | needs_more_info |
---|---|
Status: | closed → reopened |
comment:20 by , 8 years ago
Resolution: | → needs_more_info |
---|---|
Status: | reopened → closed |
Please reopen this ticket only if you can provide the FFmpeg command line that allows to reproduce the issue together with the complete, uncut console output.
comment:21 by , 8 years ago
Replying to matsp888:
You're not very good at english, are you? ;)
I am not a native speaker, no, but you are the first user who fails to understand this sentence.
comment:22 by , 8 years ago
Being rude towards the guy who keeps the bugtracker in shape and takes the bulk of the abuse from obnoxious lusers is probably not the best strategy to show that you are not one of those and get sympathetic attention for your issue, but by all means please do whatever you find best.
comment:23 by , 8 years ago
Resolution: | needs_more_info |
---|---|
Status: | closed → reopened |
I would like to have someone else taking care of this issue. You don't seem competent enough, to be honest.
comment:24 by , 8 years ago
You are the one who is obnoxious, who refuses to do something constructive and read what I write.
comment:25 by , 8 years ago
I try to explain as good as I can about the issue, and you just ignore it. To hell with the console output, it has no relevance, it's about the VIDEO DISPLAY. But you don't seem to understand plain english, so please get someone else on this one.
comment:26 by , 8 years ago
Considering this was my first comment on this ticket, this remark is quite funny. Good luck with your issue.
comment:27 by , 8 years ago
Ah, sorry Cigaes, I didn't see that it was another user. I thought it was still Carl who was bitching.
follow-up: 29 comment:28 by , 8 years ago
In any case, he is not very constructive by repeating the same irrelevant message over and over again.
comment:29 by , 8 years ago
Replying to matsp888:
In any case, he is not very constructive by repeating the same irrelevant message over and over again.
You aren't exactly constructive either. You could've just spent 30 seconds posting the info he requested, and everyone would have been happy. Instead, you started insulting the developers of whom you expect support.
comment:30 by , 8 years ago
Resolution: | → needs_more_info |
---|---|
Status: | reopened → closed |
comment:31 by , 8 years ago
You seem to be a bunch of assholes all of you. More or less what I expected. Take care, and get a life.
follow-up: 33 comment:32 by , 8 years ago
If the source file was http://samples.mplayerhq.hu/V-codecs/SMC/aletrek-smc.mov both remuxing with latest mkvmerge and ffmpeg to matroska seem to lose some kind of information.
Likely source file (file plays fine on mpv):
ffprobe -i aletrek-smc.mov ffprobe version N-77079-g27c90b7 Copyright (c) 2007-2015 the FFmpeg developers built with gcc 5.2.0 (Rev4, Built by MSYS2 project) configuration: --enable-avisynth --enable-libmp3lame --enable-libvorbis --enable-libx264 --disable-decoder=dca --enable-libdcadec --disable-postproc --enable-gmp --disable-doc --enable-libvpx --enable-libopus --disable-hwaccels --disable-sdl --disable-encoder=vorbis --disable-demuxer=asf --enable-gpl --enable-version3 --disable-debug libavutil 55. 10.100 / 55. 10.100 libavcodec 57. 16.101 / 57. 16.101 libavformat 57. 19.100 / 57. 19.100 libavdevice 57. 0.100 / 57. 0.100 libavfilter 6. 20.100 / 6. 20.100 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.101 / 2. 0.101 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'aletrek-smc.mov': Metadata: creation_time : 2002-10-16 23:31:08 Duration: 00:00:03.33, start: 0.000000, bitrate: 309 kb/s Stream #0:0(eng): Video: smc (smc / 0x20636D73), pal8, 160x120, 307 kb/s, 10.20 fps, 10 tbr, 600 tbn, 600 tbc (default) Metadata: creation_time : 2002-10-16 23:31:08 handler_name : Apple Alias Data Handler encoder : Graphics
Sample provided (immediately closes after opening on mpv):
ffprobe -i aletrek.mkv ffprobe version N-77079-g27c90b7 Copyright (c) 2007-2015 the FFmpeg developers built with gcc 5.2.0 (Rev4, Built by MSYS2 project) configuration: --enable-avisynth --enable-libmp3lame --enable-libvorbis --enable-libx264 --disable-decoder=dca --enable-libdcadec --disable-postproc --enable-gmp --disable-doc --enable-libvpx --enable-libopus --disable-hwaccels --disable-sdl --disable-encoder=vorbis --disable-demuxer=asf --enable-gpl --enable-version3 --disable-debug libavutil 55. 10.100 / 55. 10.100 libavcodec 57. 16.101 / 57. 16.101 libavformat 57. 19.100 / 57. 19.100 libavdevice 57. 0.100 / 57. 0.100 libavfilter 6. 20.100 / 6. 20.100 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.101 / 2. 0.101 Input #0, matroska,webm, from 'aletrek.mkv': Metadata: encoder : libebml v1.3.1 + libmatroska v1.4.2 creation_time : 2015-12-06 11:00:32 COLLECTION/TITLE: Clips CATEGORY/TITLE : Misc MOVIE/COMMENT : MPlayer/FFmpeg doesn’t use the correct palette when playing : Apple Graphics in Matroska. MOVIE/DATE_ENCODED: 2002‐10‐16T23:31:08 MOVIE/TITLE : aletrek Duration: 00:00:03.40, start: 0.000000, bitrate: 318 kb/s Stream #0:0: Video: smc (smc / 0x20636D73), pal8, 160x120, SAR 1:1 DAR 4:3, 10 fps, 10 tbr, 1k tbn, 1k tbc (default) Metadata: DATE_ENCODED : 2002‐10‐16T23:31:08
Source file remuxed to mkv using ffmpeg -i aletrek-smc.mov -c copy aletrek-ffmpeg-remux.mkv
:
ffprobe -i aletrek-ffmpeg-remux.mkv ffprobe version N-77079-g27c90b7 Copyright (c) 2007-2015 the FFmpeg developers built with gcc 5.2.0 (Rev4, Built by MSYS2 project) configuration: --enable-avisynth --enable-libmp3lame --enable-libvorbis --enable-libx264 --disable-decoder=dca --enable-libdcadec --disable-postproc --enable-gmp --disable-doc --enable-libvpx --enable-libopus --disable-hwaccels --disable-sdl --disable-encoder=vorbis --disable-demuxer=asf --enable-gpl --enable-version3 --disable-debug libavutil 55. 10.100 / 55. 10.100 libavcodec 57. 16.101 / 57. 16.101 libavformat 57. 19.100 / 57. 19.100 libavdevice 57. 0.100 / 57. 0.100 libavfilter 6. 20.100 / 6. 20.100 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.101 / 2. 0.101 [matroska,webm @ 0000004702c62c40] Unknown/unsupported AVCodecID V_QUICKTIME. [matroska,webm @ 0000004702c62c40] Could not find codec parameters for stream 0 (Video: none, none, 160x120): unknown codec Consider increasing the value for the 'analyzeduration' and 'probesize' options aletrek-ffmpeg-remux.mkv: End of file
Source file remuxed with mkvmerge 8.6.1 mkvmerge aletrek-smc.mov -o aletrek-mkvmerge8.6.1-remux.mkv
:
ffprobe -i aletrek-mkvmerge8.6.1-remux.mkv ffprobe version N-77079-g27c90b7 Copyright (c) 2007-2015 the FFmpeg developers built with gcc 5.2.0 (Rev4, Built by MSYS2 project) configuration: --enable-avisynth --enable-libmp3lame --enable-libvorbis --enable-libx264 --disable-decoder=dca --enable-libdcadec --disable-postproc --enable-gmp --disable-doc --enable-libvpx --enable-libopus --disable-hwaccels --disable-sdl --disable-encoder=vorbis --disable-demuxer=asf --enable-gpl --enable-version3 --disable-debug libavutil 55. 10.100 / 55. 10.100 libavcodec 57. 16.101 / 57. 16.101 libavformat 57. 19.100 / 57. 19.100 libavdevice 57. 0.100 / 57. 0.100 libavfilter 6. 20.100 / 6. 20.100 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.101 / 2. 0.101 Input #0, matroska,webm, from 'aletrek-mkvmerge8.6.1-remux.mkv': Metadata: encoder : libebml v1.3.3 + libmatroska v1.4.4 creation_time : 2015-12-06 19:49:31 Duration: 00:00:03.40, start: 0.000000, bitrate: 317 kb/s Stream #0:0: Video: smc (smc / 0x20636D73), pal8, 160x120, SAR 1:1 DAR 4:3, 10 fps, 10 tbr, 1k tbn, 1k tbc (default) Metadata: BPS : 301070 BPS-eng : 301070 DURATION : 00:00:03.400000000 DURATION-eng : 00:00:03.400000000 NUMBER_OF_FRAMES: 34 NUMBER_OF_FRAMES-eng: 34 NUMBER_OF_BYTES : 127955 NUMBER_OF_BYTES-eng: 127955 _STATISTICS_WRITING_APP: mkvmerge v8.6.1 ('Flying') 64bit _STATISTICS_WRITING_APP-eng: mkvmerge v8.6.1 ('Flying') 64bit _STATISTICS_WRITING_DATE_UTC: 2015-12-06 19:49:31 _STATISTICS_WRITING_DATE_UTC-eng: 2015-12-06 19:49:31 _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
comment:33 by , 8 years ago
Replying to RiCON:
If the source file was http://samples.mplayerhq.hu/V-codecs/SMC/aletrek-smc.mov both remuxing with latest mkvmerge and ffmpeg to matroska seem to lose some kind of information.
Why don't you use the source file attached to this ticket?
comment:35 by , 8 years ago
ffmpeg -i aletrek.mkv -qscale 2 aletrek-out.avi ffmpeg version N-77071-g843e1a8 Copyright (c) 2000-2015 the FFmpeg developers built with gcc 5.2.0 (Rev4, Built by MSYS2 project) configuration: --enable-static --disable-shared --enable-avisynth --enable-libmp3lame --enable-libvorbis --enable-libx264 --disable-decoder=dca --enable-libdcadec --disable-postproc --enable-gmp --disable-doc --enable-libvpx --enable-libopus --disable-hwaccels --disable-sdl --disable-encoder=vorbis --disable-demuxer=asf --enable-gpl --enable-version3 --disable-debug libavutil 55. 9.100 / 55. 9.100 libavcodec 57. 16.101 / 57. 16.101 libavformat 57. 19.100 / 57. 19.100 libavdevice 57. 0.100 / 57. 0.100 libavfilter 6. 20.100 / 6. 20.100 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.101 / 2. 0.101 Input #0, matroska,webm, from 'aletrek.mkv': Metadata: encoder : libebml v1.3.1 + libmatroska v1.4.2 creation_time : 2015-12-06 11:00:32 COLLECTION/TITLE: Clips CATEGORY/TITLE : Misc MOVIE/COMMENT : MPlayer/FFmpeg doesn’t use the correct palette when playing : Apple Graphics in Matroska. MOVIE/DATE_ENCODED: 2002‐10‐16T23:31:08 MOVIE/TITLE : aletrek Duration: 00:00:03.40, start: 0.000000, bitrate: 318 kb/s Stream #0:0: Video: smc (smc / 0x20636D73), pal8, 160x120, SAR 1:1 DAR 4:3, 10 fps, 10 tbr, 1k tbn, 1k tbc (default) Metadata: DATE_ENCODED : 2002‐10‐16T23:31:08 Please use -q:a or -q:v, -qscale is ambiguous Output #0, avi, to 'aletrek-out.avi': Metadata: MOVIE/DATE_ENCODED: 2002‐10‐16T23:31:08 MOVIE/TITLE : aletrek COLLECTION/TITLE: Clips CATEGORY/TITLE : Misc MOVIE/COMMENT : MPlayer/FFmpeg doesn’t use the correct palette when playing : Apple Graphics in Matroska. ISFT : Lavf57.19.100 Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 160x120 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 10 fps, 10 tbn, 10 tbc (default) Metadata: DATE_ENCODED : 2002‐10‐16T23:31:08 encoder : Lavc57.16.101 mpeg4 Stream mapping: Stream #0:0 -> #0:0 (smc (native) -> mpeg4 (native)) Press [q] to stop, [?] for help frame= 34 fps=0.0 q=2.0 Lsize= 8kB time=00:00:03.40 bitrate= 20.3kbits/s video:2kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 324.027557%
Output file plays fine but just shows black.
comment:36 by , 8 years ago
Keywords: | mkv added |
---|---|
Reproduced by developer: | set |
Resolution: | needs_more_info |
Status: | closed → reopened |
Version: | unspecified → git-master |
I attached a PoC based on 3ece3e4c by Martin Storsjö but will probably not continue working on it.
comment:37 by , 8 years ago
Patch seems to fix it. Resulting file now shows the original animation(?).
comment:38 by , 8 years ago
RICON, mkvmerge does NOT lose any information, as I said before. Everything in the 'stsd' atom is in the Matroska file created by mkvmerge. But FFmpeg doesn't use the default Macintosh palette as it should, when processing Apple Graphics in Matroska without a palette in the 'stsd' atom. It DOES use the default palette (defined in qtpalette.h) when processing the original QuickTime file. I have looked at the source code in matroskadec.c, and there is no mention of using any palette whatsoever. Thanks for finally taking care of it anyway, RICON.
comment:39 by , 8 years ago
I can't see any changes in matroskadec.c at GitHub, so I suppose you have made a private patch over there, RICON. It would be nice to have it applied to the official source code, of course.
comment:40 by , 8 years ago
For the record, the original QuickTime file (and other files with Apple Graphics encoded video that I have here) has 0x0008 rather than 0xffff (-1) as its "color table ID" in the video sample description. From the QuickTime File Format specification, page 93 (or page 118 for a later version from 2010):
"Color table ID: A 16-bit integer that identifies which color table to use. If this field is set to –1, the default color table should be used for the specified depth. For all depths below 16 bits per pixel, this indicates a standard Macintosh color table for the specified depth. Depths of 16, 24, and 32 have no color table. If the color table ID is set to 0, a color table is contained within the sample description itself. The color table immediately follows the color table ID field in the sample description."
So, the proper value to use here would be 0xffff, but it seems that FFmpeg accepts 0x0008 just as well, when processing Apple Graphics without a palette *in QuickTime files*. Since there can only be two possible states of the color table (palette), included or not included, I suppose FFmpeg treats anything that isn't zero as 0xffff (no palette included). In any case it uses the default Macintosh palette properly.
comment:41 by , 8 years ago
OK, I have added the proposed patch from Martin Storsjö mentioned above, albeit manually with cut and paste, since I have a slightly older version of FFmpeg here. It works as it should. Now if only it could make its way into the official source code ;) This should really have been done long ago, since Apple Graphics (SMC) is one of the very first codecs used in QuickTime.
comment:42 by , 8 years ago
Unfortunately, it only works with FFplay. MPlayer (at least the version I have here) exits immediately, after emitting several "Frame too small! (xxxx < 19200) Wrong format?" messages, where "xxxx" is a varying number.
EDIT: MPlayer obviously needs the fourcc value, which is commented out in the patch. However, it still won't use the palette in spite of setting matroska->pal in matroskadec.c.
EDIT: Since the 'pal' member of the MatroskaDemuxContext structure is newly added in the patch, I suppose some other part(s) of MPlayer have to be rewritten as well...
EDIT: Never mind the pal member, it's only used in matroskadec.c. However, the "pal = av_packet_new_side_data()" line in the patch makes me wonder if MPlayer ever sees this "side data" in Matroska. Probably not, since the palette is unchanged.
EDIT: No, it does not see the side data, first and foremost because it's in a function matroska_deliver_packet() that MPlayer never uses. Oh well...
follow-up: 49 comment:43 by , 8 years ago
The patch was made available by Carl. It can be applied easily with either git apply patchmkvmov.diff
or patch -p1 -N -i patchmkvmov.diff
from the root of the git repository or snapshot.
I just did what you should've done right from the start before starting to insult everyone.
The rest now depends if some other developer checks if the fix doesn't cause regressions. I'm not one.
comment:44 by , 8 years ago
I told you I couldn't use the patch directly because I have an older version of FFmpeg. I do know how to use patch, for the record. And as I said, FFplay works fine, but the MPlayer source code is a veritable mess, and it's hard to find a way to make this work.
Furthermore, the patch isn't really mature, since it comments out the fourcc among other things, but I changed that myself. This solution works for "home use", but it's far from ready for "production use".
by , 8 years ago
Attachment: | patchmkvmov.diff added |
---|
PoC by Carl Eugen Hoyos based on 3ece3e4c by Martin Storsjö
comment:45 by , 8 years ago
That looks a bit better, Carl. But I don't understand why all the stuff at the top is commented out. It looks important to me at least. Among other things, it sets AV_CODEC_ID_SVQ3 under certain conditions.
comment:46 by , 8 years ago
I should perhaps also emphasize once again that this patch will make no difference in MPlayer, which seems to need quite a bit of rewriting to make this work. But I'm happy as long as FFplay works.
comment:47 by , 8 years ago
And there is no need to (and for codec_id actually incorrect) to set codec_id and fourcc at the bottom of the block, since it's already handled by the commented out code.
by , 8 years ago
Attachment: | matroskadec.c.diff added |
---|
comment:48 by , 8 years ago
I attached a context diff with the changes I've made to matroskadec.c to show what I'm talking about.
In case anyone wonders, the change from 86 to 36 in "track->codec_priv.size >= 36" at line 27 in the diff, this was made by me long ago to allow (old) version 0 sound sample descriptions to be detected, since they are only 36 bytes.
follow-up: 54 comment:49 by , 8 years ago
Replying to RiCON:
I just did what you should've done right from the start before starting to insult everyone.
By the way, what you did, RiCON, added NOTHING of value. The console output is totally irrelevant, since once again, it's about the inner processing in matroskadec.c. It won't show in the console output, as you can probably understand.
comment:50 by , 8 years ago
It's not about value, it's about helping a bug tracker maintainer understand if it's a user issue (PEBCAK) or code issue. Just calling them names or being aggressive won't ever help and will actually contribute to your issue (and possibly future issues) being ignored.
comment:51 by , 8 years ago
Well, OK. It wasn't easy for him to grasp it at first of course. I have MY view here, and I present a totally new problem. I rest my case.
comment:52 by , 8 years ago
First of all, please excuse me for my initial bad behaviour. I know you guys are doing your best to keep this rolling. If it can be regarded as any form of excuse, the fact is that the dad of one of my friends just died, and I was in a generally bad mood that day. Now for something more constructive: I have managed to make the patch work in MPlayer with zero modification of its source code, by copying the palette to st->codec->extradata as well, which MPlayer needs in order to tack it onto the end of its "fake" BITMAPINFOHEADER. I'm attaching a unified diff of the latest Git version of matroskadec.c. Hopefully there is someone of you who thinks it looks worthy enough to implement into the official source, possibly with minor modifications.
by , 8 years ago
Attachment: | matroskadec.c.latest.diff added |
---|
comment:53 by , 8 years ago
I forgot an av_freep(&matroska->pal) in the block at line 77 of the patch. Oh well...
comment:54 by , 8 years ago
Replying to matsp888:
The console output is totally irrelevant, since once again, it's about the inner processing in matroskadec.c. It won't show in the console output, as you can probably understand.
The console output provides the exact compiled version amongst other thing, together with information related to the build version and the system, and is useful to reproduce the issue later (especially in case the original reporter is not around anymore). Therefore Carl's request was not (only) about bitching, but was (also) related to a technical requirement.
by , 8 years ago
Attachment: | matroskadec.c.latest2.diff added |
---|
comment:57 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Replying to matsp888:
I should say "processing" or something instead of "playing", of course, since FFmpeg is no video player. Sorry.