Opened 8 years ago

Last modified 8 months ago

#3623 reopened defect

Mixed results writing M4A metadata

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

Description

Given this file
http://bitbucket.org/svnpenn/a/downloads/superuser.mp4
I am having mixed results writing metadata. For example these commands

ffmpeg -i superuser.mp4 -c copy good.aac
ffmpeg -i good.aac -c copy -bsf aac_adtstoasc -metadata title=Confetti \
  -movflags faststart good.m4a

Will generate an M4A file that plays correctly with metadata that is recognized. However this command

ffmpeg -i superuser.mp4 -c copy -vn -movflags faststart \
  -metadata title=Confetti bad.m4a

Generates a file that plays correctly, but my player does not recognize the
metadata. Note I also tried adding -bsf aac_adtstoasc to the bad command to no
avail. How can I tweak the second command to get it working?

Command-line output
http://gist.github.com/svnpenn/82e7f7685084759c7483

Source question
http://superuser.com/q/750627

Attachments (2)

confetti.mp4 (2.0 MB ) - added by svnpenn 8 years ago.
planes.mp4 (349.5 KB ) - added by svnpenn 8 years ago.

Change History (19)

comment:1 by Carl Eugen Hoyos, 8 years ago

Keywords: mov metadata added

Please post the command line that does not produce the expected output file together with the complete, uncut console output here to make this a valid ticket.

comment:2 by svnpenn, 8 years ago

Last edited 8 years ago by svnpenn (previous) (diff)

in reply to:  2 comment:3 by Carl Eugen Hoyos, 8 years ago

Replying to svnpenn:

@cehoyos , did you even read the ticket? Both the problem command and complete
output are already included.

Where? I am sorry, I was unable to see the console output in your ticket description.
Please always post the complete, uncut console output here, external resources may disappear.

comment:4 by svnpenn, 8 years ago

Last edited 8 years ago by svnpenn (previous) (diff)

comment:5 by Carl Eugen Hoyos, 8 years ago

Resolution: needs_more_info
Status: newclosed

Please feel free to reopen this ticket if you can provide the missing information.

by svnpenn, 8 years ago

Attachment: confetti.mp4 added

by svnpenn, 8 years ago

Attachment: planes.mp4 added

comment:6 by svnpenn, 8 years ago

@cehoyos my arrogance has cost me, I apologize. It seems "-f mp4" does not work
in all cases. I found that with the attached "confetti.mp4", only "-f mp4"
produced desired result while with "planes.mp4", only "-f ipod" or "-f f4v"
produce desired result.

comment:7 by svnpenn, 8 years ago

ffmpeg started on 2014-05-09 at 02:28:01
Report written to "ffmpeg-20140509-022801.log"
Command line:
"C:\\ffmpeg.exe" -i confetti.mp4 -c copy -vn -movflags faststart -metadata "title=Confetti" -report confetti.m4a
ffmpeg version git-2014-01-22-94a5241 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jan 21 2014 19:33:07 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --disable-doc --enable-nonfree --enable-libx264 --enable-libfdk-aac --arch=x86_64 --target-os=mingw32 --logfile=/dev/stdout --extra-ldflags=-static --cross-prefix=x86_64-w64-mingw32-
  libavutil      52. 63.100 / 52. 63.100
  libavcodec     55. 48.102 / 55. 48.102
  libavformat    55. 25.101 / 55. 25.101
  libavdevice    55.  5.102 / 55.  5.102
  libavfilter     4.  1.100 /  4.  1.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Splitting the commandline.
Reading option '-i' ... matched as input file with argument 'confetti.mp4'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-vn' ... matched as option 'vn' (disable video) with argument '1'.
Reading option '-movflags' ... matched as AVOption 'movflags' with argument 'faststart'.
Reading option '-metadata' ... matched as option 'metadata' (add metadata) with argument 'title=Confetti'.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option 'confetti.m4a' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file confetti.mp4.
Successfully parsed a group of options.
Opening an input file: confetti.mp4.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000001846c60] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000001846c60] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000001846c60] Before avformat_find_stream_info() pos: 2055829 bytes read:39809 seeks:1
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000001846c60] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000001846c60] After avformat_find_stream_info() pos: 819 bytes read:72577 seeks:2 frames:2
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'confetti.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.25.101
  Duration: 00:00:10.01, start: 0.000000, bitrate: 1643 kb/s
    Stream #0:0(und), 1, 1/24000: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1444 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und), 1, 1/44100: Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Successfully opened the file.
Parsing a group of options: output file confetti.m4a.
Applying option c (codec name) with argument copy.
Applying option vn (disable video) with argument 1.
Applying option metadata (add metadata) with argument title=Confetti.
Successfully parsed a group of options.
Opening an output file: confetti.m4a.
Successfully opened the file.
Output #0, ipod, to 'confetti.m4a':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Confetti
    encoder         : Lavf55.25.101
    Stream #0:0(und), 0, 1/44100: Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, 192 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
Press [q] to stop, [?] for help
No more output streams to write to, finishing.
[ipod @ 000000000418f6c0] Starting second pass: moving the moov atom to the beginning of the file
[AVIOContext @ 0000000001859ae0] Statistics: 240981 bytes read, 0 seeks
size=     238kB time=00:00:10.00 bitrate= 194.6kbits/s    

video:0kB audio:235kB subtitle:0 global headers:0kB muxing overhead 1.040919%
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 00000000018cfc60] Statistics: 32 seeks, 462 writeouts
[AVIOContext @ 000000000198fbc0] Statistics: 1856308 bytes read, 33 seeks

comment:8 by svnpenn, 8 years ago

ffmpeg started on 2014-05-09 at 02:29:04
Report written to "ffmpeg-20140509-022904.log"
Command line:
"C:\\ffmpeg.exe" -i planes.mp4 -c copy -vn -movflags faststart -metadata "title=Planes" -report planes.m4a
ffmpeg version git-2014-01-22-94a5241 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jan 21 2014 19:33:07 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --disable-doc --enable-nonfree --enable-libx264 --enable-libfdk-aac --arch=x86_64 --target-os=mingw32 --logfile=/dev/stdout --extra-ldflags=-static --cross-prefix=x86_64-w64-mingw32-
  libavutil      52. 63.100 / 52. 63.100
  libavcodec     55. 48.102 / 55. 48.102
  libavformat    55. 25.101 / 55. 25.101
  libavdevice    55.  5.102 / 55.  5.102
  libavfilter     4.  1.100 /  4.  1.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Splitting the commandline.
Reading option '-i' ... matched as input file with argument 'planes.mp4'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-vn' ... matched as option 'vn' (disable video) with argument '1'.
Reading option '-movflags' ... matched as AVOption 'movflags' with argument 'faststart'.
Reading option '-metadata' ... matched as option 'metadata' (add metadata) with argument 'title=Planes'.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option 'planes.m4a' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file planes.mp4.
Successfully parsed a group of options.
Opening an input file: planes.mp4.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000000336c20] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000000336c20] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000000336c20] Before avformat_find_stream_info() pos: 357849 bytes read:36726 seeks:1
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000000336c20] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000000336c20] After avformat_find_stream_info() pos: 25214 bytes read:69494 seeks:2 frames:2
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'planes.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.25.101
  Duration: 00:00:10.01, start: 0.000000, bitrate: 286 kb/s
    Stream #0:0(und), 1, 1/12288: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 90 kb/s, 6 fps, 6 tbr, 12288 tbn, 12 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und), 1, 1/44100: Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Successfully opened the file.
Parsing a group of options: output file planes.m4a.
Applying option c (codec name) with argument copy.
Applying option vn (disable video) with argument 1.
Applying option metadata (add metadata) with argument title=Planes.
Successfully parsed a group of options.
Opening an output file: planes.m4a.
Successfully opened the file.
Output #0, ipod, to 'planes.m4a':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Planes
    encoder         : Lavf55.25.101
    Stream #0:0(und), 0, 1/44100: Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, 192 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
Press [q] to stop, [?] for help
No more output streams to write to, finishing.
[ipod @ 000000000033f0e0] Starting second pass: moving the moov atom to the beginning of the file
[AVIOContext @ 000000000033e4a0] Statistics: 240441 bytes read, 0 seeks
size=     237kB time=00:00:10.00 bitrate= 194.2kbits/s    

video:0kB audio:235kB subtitle:0 global headers:0kB muxing overhead 1.042425%
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 00000000003bfc00] Statistics: 32 seeks, 462 writeouts
[AVIOContext @ 00000000003dfbc0] Statistics: 364281 bytes read, 4 seeks

comment:9 by svnpenn, 8 years ago

Resolution: needs_more_info
Status: closedreopened

comment:10 by svnpenn, 8 years ago

This command also works

ffmpeg -i confetti.mp4 -c copy -f adts - |
ffmpeg -i - -c copy -bsf aac_adtstoasc -movflags faststart \
  -metadata title=Confetti good.m4a

Note, this issue was discussed over 3 years ago

http://lists.infradead.org/pipermail/get_iplayer/2011-March/001171.html

comment:11 by Carl Eugen Hoyos, 8 months ago

Version: unspecifiedgit-master

The question afaict is:
How did you create the input file? The extradata that this file contains is copied into the output file.

If there ever was an issue that can be fixed in the FFmpeg source code, I believe it is still reproducible.

comment:12 by svnpenn, 8 months ago

Ok yes, this is still an issue. If I take this file:

http://jplayer.org/audio/m4a/Miaow-02-Hidden.m4a

My player will play the audio, and read the metadata. But if I do this:

ffmpeg -i Miaow-02-Hidden.m4a -c copy -movflags faststart out.m4a

My player will play the audio, but it says no metadata.

comment:13 by Carl Eugen Hoyos, 8 months ago

What happens if you pipe the contents of the new file into a second ffmpeg process?

comment:14 by svnpenn, 8 months ago

Correcting myself. I can get correct metadata with this file [1], if I add "-f mp4":

ffmpeg -i Miaow-02-Hidden.m4a -c copy -movflags faststart -f mp4 out.m4a

However this file:

youtube-dl -f 140 http://youtube.com/watch?v=j-70HbaR4g4

I can only get correct metadata, if I destroy and rebuild the file like this:

ffmpeg -i 'Confetti (Remastered)-j-70HbaR4g4.m4a' -c copy good.aac
ffmpeg -i good.aac -c copy -bsf aac_adtstoasc -metadata title=Confetti -movflags faststart good.m4a
  1. http://jplayer.org/audio/m4a/Miaow-02-Hidden.m4a

comment:15 by Carl Eugen Hoyos, 8 months ago

How is this related?
You originally described that if you pipe the content of file into ffmpeg you get different output (that also behaves differently) than the output from one (theoretically identical) ffmpeg invocation.

comment:16 by svnpenn, 8 months ago

You originally described that if you pipe the content of file into ffmpeg you get different output (that also behaves differently) than the output from one (theoretically identical) ffmpeg invocation.

No, originally I used these commands:

ffmpeg -i superuser.mp4 -c copy good.aac
ffmpeg -i good.aac -c copy -bsf aac_adtstoasc -metadata title=Confetti  -movflags faststart good.m4a

as shown at the top of this page. Later, I did use this as well:

ffmpeg -i confetti.mp4 -c copy -f adts - |
ffmpeg -i - -c copy -bsf aac_adtstoasc -movflags faststart -metadata title=Confetti good.m4a

but the difference is irrelevant, as both do the same thing, only one uses a pipe, and one uses a temp file.

comment:17 by svnpenn, 8 months ago

I think I was able to solve this. If I run these commands:

ffmpeg -i in.m4a -c copy -movflags faststart -metadata title=Confetti bad.m4a
ffmpeg -i in.m4a -c copy -movflags faststart -metadata title=Confetti `
   -map_metadata -1 good.m4a
mp4dump bad.m4a > bad.txt
mp4dump good.m4a > good.txt
git diff bad.txt good.txt

I get this result:

-        handler_name = ISO Media file produced by Google Inc.
+        handler_name = SoundHandler

I tested some more, and it seems any handler_name more than 29 characters will fail, which is probably 30 including a null byte, or maybe a length byte. Here is an example that will just barely pass:

ffmpeg -i in.m4a -c copy -movflags faststart -metadata title=Confetti `
-metadata:s handler_name=SoundHandlerSoundHandlerSound good.m4a
Last edited 8 months ago by svnpenn (previous) (diff)
Note: See TracTickets for help on using tickets.