diff --git a/doc/muxers.texi b/doc/muxers.texi index 989cb96f6d..0dc8a33628 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -544,9 +544,10 @@ optionally an ID3v1 tag at the end. ID3v2.3 and ID3v2.4 are supported, the @code{id3v2_version} option controls which one is used. The legacy ID3v1 tag is not written by default, but may be enabled with the @code{write_id3v1} option. -For seekable output the muxer also writes a Xing frame at the beginning, which -contains the number of frames in the file. It is useful for computing duration -of VBR files. +The muxer may also write a Xing frame at the beginning, which contains the +number of frames in the file. It is useful for computing duration of VBR files. +The Xing frame is written if the output stream is seekable and if the +@code{write_xing} option is set to 1 (the default). The muxer supports writing ID3v2 attached pictures (APIC frames). The pictures are supplied to the muxer in form of a video stream with a single packet. There diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index a5f672b257..b4258e2aae 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -85,6 +85,7 @@ typedef struct MP3Context { ID3v2EncContext id3; int id3v2_version; int write_id3v1; + int write_xing; /* xing header */ int64_t xing_offset; @@ -125,7 +126,7 @@ static int mp3_write_xing(AVFormatContext *s) int needed; const char *vendor = (codec->flags & CODEC_FLAG_BITEXACT) ? "Lavf" : LIBAVFORMAT_IDENT; - if (!s->pb->seekable) + if (!s->pb->seekable || !mp3->write_xing) return 0; for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++) { @@ -396,6 +397,8 @@ static const AVOption options[] = { offsetof(MP3Context, id3v2_version), AV_OPT_TYPE_INT, {.i64 = 4}, 3, 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.", + offsetof(MP3Context, write_xing), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM}, { NULL }, };