Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.
In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.
There are multiple important problems with this approach:
- the fields in AVCodecContext are in general one of
* stream parameters
* codec options
* codec state
However, it's not clear which ones are which. It is consequently
unclear which fields are a demuxer allowed to set or a muxer allowed to
read. This leads to erratic behaviour depending on whether decoding or
encoding is being performed or not (and whether it uses the AVStream
embedded codec context).
- various synchronization issues arising from the fact that the same
context is used by several different APIs (muxers/demuxers,
parsers, bitstream filters and encoders/decoders) simultaneously, with
there being no clear rules for who can modify what and the different
processes being typically delayed with respect to each other.
- avformat_find_stream_info() making it necessary to support opening
and closing a single codec context multiple times, thus
complicating the semantics of freeing various allocated objects in the
codec context.
Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
As with the change to flacenc this allows the user to control the amount
of padding they want added to the file.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This makes the encoding of picture descriptions consistent with the
encoding of other text id3 tags and works better with iTunes, which
does not display pictures with some UTF-16 picture descriptions
(including a UTF-16 empty string, i.e. BOM + terminator). It also
saves a few bytes.
Example:
ffmpeg -f lavfi -i sine=b=4 -f lavfi -i smptebars -map 0:a -map 1:v \
-codec:a libmp3lame -codec:v mjpeg -id3v2_version 3 \
-metadata:s:v comment="Cover (front)" -t 3 -y out.mp3
This example does not set a picture description (-metadata:s:v title=)
so an empty string is written in the id3v2.3 APIC frame. Without this
patch, UTF-16 is used and the cover art does not display in iTunes.
With the patch the cover art is displayed. (Note that iTunes does not
display or have a way to set picture descriptions, only the picture
itself, but nevertheless has trouble skipping some UTF-16 descriptions.)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Adding an arbitrary amount of padding bytes at the end of the
ID3 metadata fixes cover art display for some software (iTunes,
Traktor, Serato, Torq).
For reference (ID3 metadata):
[ Apic frames ] -> cover doesn't show up
[ Apic frames, Padding ] -> ok
[ Apic frames, ID3 frames ] -> ok
[ ID3 frames, Apic frames ] -> cover doesn't show up
[ ID3 frames, Apic frames, Padding ] -> ok
Frame sizes in ID3v2.3 are not synchsafe, they are simply 32be numbers.
In practice this bug is not noticeable unless the frame size takes more
than 7 bits (which is almost never for text frames).
Adds support for year (TYER) and day/month (TDAT) tags when writing
id3v2 version 3 metadata by splitting the "date" tag. The date tag
should have a format of "YYYY-MM-DD" or "YYYY".
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>