Opened 11 years ago

Closed 6 years ago

Last modified 6 years ago

#2798 closed enhancement (fixed)

Write cover art to mov files

Reported by: svnpenn Owned by:
Priority: wish Component: avformat
Version: git-master Keywords: mov
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

.m4a files support album art
.mp4 files support cover art

currently you can add the art in this way

atomicparsley infile.mp4 --artwork infile.png --overWrite

However once muxed with FFmpeg some changes happen

ffmpeg -i infile.mp4 -c copy -map 0 outfile.mp4
  1. The png stream changes from
png

to

png (m[0][0][0] / 0x006D)
  1. Thumbnail disappears, example http://superuser.com/a/524120
  1. If you open in VLC instead of just playing video it also opens a second window with the png
ffmpeg version N-37428-gf18d2df Copyright (c) 2000-2013 the FFmpeg developers
  built on May 23 2013 01:35:26 with gcc 4.8.0 (rubenvb-4.8.0)
  configuration: --enable-gpl --enable-libx264 --enable-nonfree --enable-libfdk-aac --arch=x86 --target-os=mingw32 --logfile=/dev/stdout --extra-ldflags=-static --cross-prefix=i686-w64-mingw32- --host-cc=i686-w64-mingw32-gcc
  libavutil      52. 28.100 / 52. 28.100
  libavcodec     55.  7.100 / 55.  7.100
  libavformat    55.  4.101 / 55.  4.101
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 63.101 /  3. 63.101
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 035e5f00] stream 0, timescale not set
[mov,mp4,m4a,3gp,3g2,mj2 @ 035e5f00] max_analyze_duration 5000000 reached at 5005031 microseconds
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'infile.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.4.101
  Duration: 00:01:00.06, start: 0.000000, bitrate: 4923 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1040 [SAR 1:1 DAR 24:13], 4019 kb/s, 23.98 fps, 23.98 tbr, 16k tbn, 47.95 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Metadata:
      handler_name    : SoundHandler
    Stream #0:2: Video: png, rgb24, 1920x1040 [SAR 1:1 DAR 24:13], 90k tbr, 90k tbn, 90k tbc
[mp4 @ 035f65c0] track 1: codec frame size is not set
Output #0, mp4, to 'outfile.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.4.101
    Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1920x1040 [SAR 1:1 DAR 24:13], q=2-31, 4019 kb/s, 23.98 fps, 16k tbn, 16k tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: ac3 ([165][0][0][0] / 0x00A5), 48000 Hz, 5.1(side), 384 kb/s
    Metadata:
      handler_name    : SoundHandler
    Stream #0:2: Video: png (m[0][0][0] / 0x006D), rgb24, 1920x1040 [SAR 1:1 DAR 24:13], q=2-31, 90k tbn, 90k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
Press [q] to stop, [?] for help
frame= 1440 fps=0.0 q=-1.0 Lq=-1.0 size=   36097kB time=00:01:00.00 bitrate=4928.4kbits/s    

video:33241kB audio:2812kB subtitle:0 global headers:0kB muxing overhead 0.118462%

Change History (13)

comment:1 by Carl Eugen Hoyos, 11 years ago

Component: undeterminedavformat
Keywords: mov added

Is this problem reproducible with current git head?

comment:2 by svnpenn, 11 years ago

If it helps, I tested it again with

ffmpeg version N-54802-gfc6de70 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jul 18 2013 18:07:01 with gcc 4.7.3 (GCC)

same result. If need be I can build from HEAD and try again.

comment:3 by jamal, 11 years ago

mov/mp4/m4a muxer currently doesn't support cover art.
A patch that implements this was submitted to ffmpeg-devel a few weeks ago.

This is the thread: http://comments.gmane.org/gmane.comp.video.ffmpeg.devel/165509

comment:5 by Carl Eugen Hoyos, 10 years ago

Priority: normalwish
Status: newopen
Type: defectenhancement
Version: unspecifiedgit-master

comment:6 by Carl Eugen Hoyos, 10 years ago

Summary: Unexpected behavior with cover artWrite cover art to mov files

comment:7 by Vitaly Zdanevich, 7 years ago

Still no way to add a cover to the m4a?

comment:8 by Oscar Calvo, 6 years ago

What is the current status of this issue?

comment:9 by fabled, 6 years ago

I am also interested to fix this, I just posted redesigned and greatly simplified patch against current git master: https://ffmpeg.org/pipermail/ffmpeg-devel/2018-March/227516.html

comment:10 by Carl Eugen Hoyos, 6 years ago

Resolution: fixed
Status: openclosed

comment:11 by svnpenn, 6 years ago

This is not fixed - as the commit does nothing for M4A files:

[ipod @ 0000000000353bc0] Could not find tag for codec mjpeg in stream #1, codec
not currently supported in container

comment:12 by fabled, 6 years ago

Yes, it was omission in the original patch to not support m4a and m4v files. This has been fixed in commit 12205d2c896b7edbc929d4886e7bfda4b53538e5. Be sure to use '-c copy' or similar to make sure that ffmpeg does not try to transcode the cover image to H.264 which is not supported as cover image. Additional (relatively intrusive) changes would be needed to get the automatic transcoding codecs right.

comment:13 by Khang NT, 6 years ago

Still facing this problem, is it really fixed?

ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.10.44.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2_1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gpl --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-opencl --enable-openssl --enable-videotoolbox --enable-nonfree
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Splitting the commandline.
Reading option '-i' ... matched as input url with argument 'test.m4a'.
Reading option '-i' ... matched as input url with argument 'cover.jpeg'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '1'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option 'out.m4a' ... matched as output url.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url test.m4a.
Successfully parsed a group of options.
Opening an input file: test.m4a.
[NULL @ 0x7fcfc9007400] Opening 'test.m4a' for reading
[file @ 0x7fcfc741a000] Setting default whitelist 'file,crypto'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fcfc9007400] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fcfc9007400] ISO: File Type Major Brand: M4A
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fcfc9007400] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fcfc9007400] Processing st: 0, edit list 0 - media time: 0, duration: 13549593
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fcfc9007400] Before avformat_find_stream_info() pos: 4877049 bytes read:86458 seeks:1 nb_streams:1
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fcfc9007400] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fcfc9007400] After avformat_find_stream_info() pos: 404 bytes read:119226 seeks:2 frames:1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.m4a':
  Metadata:
    major_brand     : M4A
    minor_version   : 512
    compatible_brands: isomiso2
    creation_time   : 2018-10-22T05:56:39.000000Z
    encoder         : Lavf57.71.100
  Duration: 00:05:07.25, start: 0.000000, bitrate: 126 kb/s
    Stream #0:0(eng), 1, 1/44100: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
      creation_time   : 2018-10-22T05:56:39.000000Z
      handler_name    : SoundHandler
Successfully opened the file.
Parsing a group of options: input url cover.jpeg.
Successfully parsed a group of options.
Opening an input file: cover.jpeg.
[NULL @ 0x7fcfc900a600] Opening 'cover.jpeg' for reading
[file @ 0x7fcfc741af80] Setting default whitelist 'file,crypto'
[image2 @ 0x7fcfc900a600] Format image2 probed with size=2048 and score=50
[image2 @ 0x7fcfc900a600] Before avformat_find_stream_info() pos: 0 bytes read:23087 seeks:0 nb_streams:1
[mjpeg @ 0x7fcfc900b800] marker=d8 avail_size_in_buf=23085
[mjpeg @ 0x7fcfc900b800] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x7fcfc900b800] marker=db avail_size_in_buf=23083
[mjpeg @ 0x7fcfc900b800] index=0
[mjpeg @ 0x7fcfc900b800] qscale[0]: 3
[mjpeg @ 0x7fcfc900b800] index=1
[mjpeg @ 0x7fcfc900b800] qscale[1]: 6
[mjpeg @ 0x7fcfc900b800] marker parser used 132 bytes (1056 bits)
[mjpeg @ 0x7fcfc900b800] marker=c0 avail_size_in_buf=22949
[mjpeg @ 0x7fcfc900b800] Changing bps from 0 to 8
[mjpeg @ 0x7fcfc900b800] sof0: picture: 460x460
[mjpeg @ 0x7fcfc900b800] component 0 2:2 id: 0 quant:0
[mjpeg @ 0x7fcfc900b800] component 1 1:1 id: 1 quant:1
[mjpeg @ 0x7fcfc900b800] component 2 1:1 id: 2 quant:1
[mjpeg @ 0x7fcfc900b800] pix fmt id 22111100
[mjpeg @ 0x7fcfc900b800] Format yuvj420p chosen by get_format().
[mjpeg @ 0x7fcfc900b800] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x7fcfc900b800] marker=c4 avail_size_in_buf=22930
[mjpeg @ 0x7fcfc900b800] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x7fcfc900b800] escaping removed 114 bytes
[mjpeg @ 0x7fcfc900b800] marker=da avail_size_in_buf=22510
[mjpeg @ 0x7fcfc900b800] marker parser used 22396 bytes (179168 bits)
[mjpeg @ 0x7fcfc900b800] marker=d9 avail_size_in_buf=0
[mjpeg @ 0x7fcfc900b800] decode frame unused 0 bytes
[image2 @ 0x7fcfc900a600] After avformat_find_stream_info() pos: 23087 bytes read:23087 seeks:0 frames:1
Input #1, image2, from 'cover.jpeg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 4617 kb/s
    Stream #1:0, 1, 1/25: Video: mjpeg, 1 reference frame, yuvj420p(pc, bt470bg/unknown/unknown, center), 460x460, 0/1, 25 tbr, 25 tbn, 25 tbc
Successfully opened the file.
Parsing a group of options: output url out.m4a.
Applying option map (set input stream mapping) with argument 0.
Applying option map (set input stream mapping) with argument 1.
Applying option c (codec name) with argument copy.
Successfully parsed a group of options.
Opening an output file: out.m4a.
File 'out.m4a' already exists. Overwrite ? [y/N] y
[file @ 0x7fcfc741d180] Setting default whitelist 'file,crypto'
Successfully opened the file.
[ipod @ 0x7fcfc900d600] Could not find tag for codec mjpeg in stream #1, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
    Last message repeated 1 times
[AVIOContext @ 0x7fcfc76004c0] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 0x7fcfc741a140] Statistics: 119226 bytes read, 2 seeks
[AVIOContext @ 0x7fcfc741e040] Statistics: 23087 bytes read, 0 seeks
Note: See TracTickets for help on using tickets.