Browse code

Merge commit '33018907bd07b34e0e70d5ae12097265eb3734d7'

* commit '33018907bd07b34e0e70d5ae12097265eb3734d7':
mp3enc: allow omitting the id3v2 header with -id3v2_version 0

Conflicts:
doc/muxers.texi
libavformat/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2014/01/17 23:31:18
Showing 3 changed files
... ...
@@ -541,8 +541,10 @@ ffmpeg -re @var{<normal input/transcoding options>} -movflags isml+frag_keyframe
541 541
 
542 542
 The MP3 muxer writes a raw MP3 stream with an ID3v2 header at the beginning and
543 543
 optionally an ID3v1 tag at the end. ID3v2.3 and ID3v2.4 are supported, the
544
-@code{id3v2_version} option controls which one is used. The legacy ID3v1 tag is
545
-not written by default, but may be enabled with the @code{write_id3v1} option.
544
+@code{id3v2_version} option controls which one is used. Setting
545
+@code{id3v2_version} to 0 will disable the ID3v2 header completely. The legacy
546
+ID3v1 tag is not written by default, but may be enabled with the
547
+@code{write_id3v1} option.
546 548
 
547 549
 The muxer may also write a Xing frame at the beginning, which contains the
548 550
 number of frames in the file. It is useful for computing duration of VBR files.
... ...
@@ -574,6 +576,11 @@ ffmpeg -i input.mp3 -i cover.png -c copy -map 0 -map 1
574 574
 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3
575 575
 @end example
576 576
 
577
+Write a "clean" MP3 without any extra features:
578
+@example
579
+ffmpeg -i input.wav -write_xing 0 -id3v2_version 0 out.mp3
580
+@end example
581
+
577 582
 @section mpegts
578 583
 
579 584
 MPEG transport stream muxer.
... ...
@@ -394,7 +394,7 @@ AVOutputFormat ff_mp2_muxer = {
394 394
 
395 395
 static const AVOption options[] = {
396 396
     { "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.",
397
-      offsetof(MP3Context, id3v2_version), AV_OPT_TYPE_INT, {.i64 = 4}, 3, 4, AV_OPT_FLAG_ENCODING_PARAM},
397
+      offsetof(MP3Context, id3v2_version), AV_OPT_TYPE_INT, {.i64 = 4}, 0, 4, AV_OPT_FLAG_ENCODING_PARAM},
398 398
     { "write_id3v1", "Enable ID3v1 writing. ID3v1 tags are written in UTF-8 which may not be supported by most software.",
399 399
       offsetof(MP3Context, write_id3v1), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
400 400
     { "write_xing",  "Write the Xing header containing file duration.",
... ...
@@ -467,6 +467,14 @@ static int mp3_write_header(struct AVFormatContext *s)
467 467
     MP3Context  *mp3 = s->priv_data;
468 468
     int ret, i;
469 469
 
470
+    if (mp3->id3v2_version      &&
471
+        mp3->id3v2_version != 3 &&
472
+        mp3->id3v2_version != 4) {
473
+        av_log(s, AV_LOG_ERROR, "Invalid ID3v2 version requested: %d. Only "
474
+               "3, 4 or 0 (disabled) are allowed.\n", mp3->id3v2_version);
475
+        return AVERROR(EINVAL);
476
+    }
477
+
470 478
     /* check the streams -- we want exactly one audio and arbitrary number of
471 479
      * video (attached pictures) */
472 480
     mp3->audio_stream_idx = -1;
... ...
@@ -490,13 +498,22 @@ static int mp3_write_header(struct AVFormatContext *s)
490 490
     }
491 491
     mp3->pics_to_write = s->nb_streams - 1;
492 492
 
493
-    ff_id3v2_start(&mp3->id3, s->pb, mp3->id3v2_version, ID3v2_DEFAULT_MAGIC);
494
-    ret = ff_id3v2_write_metadata(s, &mp3->id3);
495
-    if (ret < 0)
496
-        return ret;
493
+    if (mp3->pics_to_write && !mp3->id3v2_version) {
494
+        av_log(s, AV_LOG_ERROR, "Attached pictures were requested, but the "
495
+               "ID3v2 header is disabled.\n");
496
+        return AVERROR(EINVAL);
497
+    }
498
+
499
+    if (mp3->id3v2_version) {
500
+        ff_id3v2_start(&mp3->id3, s->pb, mp3->id3v2_version, ID3v2_DEFAULT_MAGIC);
501
+        ret = ff_id3v2_write_metadata(s, &mp3->id3);
502
+        if (ret < 0)
503
+            return ret;
504
+    }
497 505
 
498 506
     if (!mp3->pics_to_write) {
499
-        ff_id3v2_finish(&mp3->id3, s->pb);
507
+        if (mp3->id3v2_version)
508
+            ff_id3v2_finish(&mp3->id3, s->pb);
500 509
         mp3_write_xing(s);
501 510
     }
502 511
 
... ...
@@ -30,8 +30,8 @@
30 30
 #include "libavutil/version.h"
31 31
 
32 32
 #define LIBAVFORMAT_VERSION_MAJOR 55
33
-#define LIBAVFORMAT_VERSION_MINOR 23
34
-#define LIBAVFORMAT_VERSION_MICRO 103
33
+#define LIBAVFORMAT_VERSION_MINOR 24
34
+#define LIBAVFORMAT_VERSION_MICRO 100
35 35
 
36 36
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
37 37
                                                LIBAVFORMAT_VERSION_MINOR, \