diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-01-17 15:31:18 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-01-17 15:34:24 +0100 |
commit | 58770db2ae67d9b4b6adcf2b15951f9608442051 (patch) | |
tree | a155b0f27369b59cfa7651a4a1ecd6627d3d8a58 /libavformat/mp3enc.c | |
parent | 5049b6a1fe52f549bad6721f162b4ec2d9d0a357 (diff) | |
parent | 33018907bd07b34e0e70d5ae12097265eb3734d7 (diff) | |
download | ffmpeg-58770db2ae67d9b4b6adcf2b15951f9608442051.tar.gz |
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>
Diffstat (limited to 'libavformat/mp3enc.c')
-rw-r--r-- | libavformat/mp3enc.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index b4258e2aae..9523cf9a9c 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -394,7 +394,7 @@ AVOutputFormat ff_mp2_muxer = { static const AVOption options[] = { { "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.", - offsetof(MP3Context, id3v2_version), AV_OPT_TYPE_INT, {.i64 = 4}, 3, 4, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(MP3Context, id3v2_version), AV_OPT_TYPE_INT, {.i64 = 4}, 0, 4, AV_OPT_FLAG_ENCODING_PARAM}, { "write_id3v1", "Enable ID3v1 writing. ID3v1 tags are written in UTF-8 which may not be supported by most software.", offsetof(MP3Context, write_id3v1), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM}, { "write_xing", "Write the Xing header containing file duration.", @@ -467,6 +467,14 @@ static int mp3_write_header(struct AVFormatContext *s) MP3Context *mp3 = s->priv_data; int ret, i; + if (mp3->id3v2_version && + mp3->id3v2_version != 3 && + mp3->id3v2_version != 4) { + av_log(s, AV_LOG_ERROR, "Invalid ID3v2 version requested: %d. Only " + "3, 4 or 0 (disabled) are allowed.\n", mp3->id3v2_version); + return AVERROR(EINVAL); + } + /* check the streams -- we want exactly one audio and arbitrary number of * video (attached pictures) */ mp3->audio_stream_idx = -1; @@ -490,13 +498,22 @@ static int mp3_write_header(struct AVFormatContext *s) } mp3->pics_to_write = s->nb_streams - 1; - ff_id3v2_start(&mp3->id3, s->pb, mp3->id3v2_version, ID3v2_DEFAULT_MAGIC); - ret = ff_id3v2_write_metadata(s, &mp3->id3); - if (ret < 0) - return ret; + if (mp3->pics_to_write && !mp3->id3v2_version) { + av_log(s, AV_LOG_ERROR, "Attached pictures were requested, but the " + "ID3v2 header is disabled.\n"); + return AVERROR(EINVAL); + } + + if (mp3->id3v2_version) { + ff_id3v2_start(&mp3->id3, s->pb, mp3->id3v2_version, ID3v2_DEFAULT_MAGIC); + ret = ff_id3v2_write_metadata(s, &mp3->id3); + if (ret < 0) + return ret; + } if (!mp3->pics_to_write) { - ff_id3v2_finish(&mp3->id3, s->pb); + if (mp3->id3v2_version) + ff_id3v2_finish(&mp3->id3, s->pb); mp3_write_xing(s); } |