We read sub_packet_h / 2 packets per line of data (during deinterleaving),
which equals zero if sub_packet_h <= 1, thus causing us to not read any
data, leading to an infinite loop.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
This allows writing QuickTime-compatible fragmented mp4 (with
a non-empty moov atom) to a non-seekable output.
This buffers the mdat for the initial fragment just as it does
for all normal fragments, too. Previously, the resulting
atom structure was mdat,moov, moof,mdat ..., while it now
is moov,mdat, moof,mdat.
Signed-off-by: Martin Storsjö <martin@martin.st>
In nonseekable files, we already stop parsing the toplevel atoms
after finding moov and one mdat. In large seekable files (or files
that are seekable, but slowly, e.g. http), reading all the fragments
at the start can take a considerable amount of time. This allows
opting out from this behaviour.
Signed-off-by: Martin Storsjö <martin@martin.st>
If parsing moov+mdat in a non-seekable file, we currently
abort parsing directly after parsing the header of the mdat
atom. If we want to continue parsing later (if looking to
parse later fragments), we need to skip past the content of the
mdat atom, otherwise we end up parsing the content of the mdat
atom as root level atoms.
Signed-off-by: Martin Storsjö <martin@martin.st>
For video, mark the first sample in a trun which doesn't have the
sample-is-non-sync-sample flag set as a keyframe.
In particular, the "sample does not depend on other samples" flag
isn't enough to make it a keyframe, since later frames still can
reference frames prior to that one (the flag only says that that
particular frame doesn't depend on other frames).
This fixes bug 215.
Signed-off-by: Martin Storsjö <martin@martin.st>
The parser was fixed so this workaround should no longer
be necessary.
This allows using stream-copy to fix files with keyframes
incorrectly marked.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
This avoids reading any old data in the AVIOContext buffer after
the seek, and indicates to the mpegts demuxer that we've seeked,
avoiding continuity check errors.
Signed-off-by: Martin Storsjö <martin@martin.st>
Enhance seeking by demuxing until the requested timestamp is
reached within the segment selected by the seek code using the
playlist info.
Some mpegts streams don't have dts set for all packets though,
this seeking method doesn't work well for that case.
Signed-off-by: Martin Storsjö <martin@martin.st>
The previous condition of 0 page size was wrong,
that would disable the mechanism for all frames at
a start of a page, thus some keyframes still would not
get their own granule.
The real problem is that header packets must not be flushed,
but they have (and must have) 0 granule and thus would
be detected as keyframes.
Add a separate parameter to mark header packets.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
This prevents failed assertions further down in the packet processing
where we require non-negative values for packet_size_left.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
H263 in RTP can be packetized in two formats (RFC 2190, RFC
2429/4629). The former normally uses the static payload type 34,
while the latter normally uses dynamic payload types with the
SDP format names H263-1998 or H263-2000.
Look for packets that don't look like proper RFC 2190 packets and
switch to depacketizing them according to the new format if they
match some heuristic criteria.
Signed-off-by: Martin Storsjö <martin@martin.st>
In order to match Linux behaviour better our
Windows-specific open() replacement should disable
Windows default file locking.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
This needs the extradata to be extracted.
The approach used is the one MPlayer uses, though it is
unclear whether the 4 bytes extradata that are skipped
should be skipped always or only for AAC.
The AAC parser must be disabled, too, otherwise playback
still does not work.
Fixes trac issue #547.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
According to 14496-12, the duration should be all 1s if
the duration is unknown. This is the case if writing a moov
atom without any samples described in it (e.g. as in ismv files).
Signed-off-by: Martin Storsjö <martin@martin.st>
This allows handling matroska files with errors.
Fixes test4.mkv and test7.mkv from the official Matroska test suite.
These are also trac issues #544 and #545.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Muxing pcm audio in MOV using avcodec_encode_audio() was failing
because avcodec_encode_audio() returns an incorrect packet size of 4
bytes. This can be reproduced by modifying the sample
ffmpeg/doc/examples/muxing.c to encode PCM, see ML patch
muxing-test.diff
I git bisected and commit 89ddff92a3 is the one that broke this. In
mov_write_header() if st->codec->frame_size <= 1 it sets it to 1. Then
avcodec_encode_audio() sets frame->nb_samples = avctx->frame_size, and
frame->nb_samples of 1 is used to compute a packet size of 4 bytes.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
According to unofficial documentation, the video rate is locked to the audio
sample rate. This results in proper synchronization of audio and video
timestamps from the demuxer. This only works if the first audio packet occurs
before the first video packet or the audio sample rate is the default rate of
11111 Hz, both of which are true for all samples in our archive.
This avoids initializing a stream with dummy values or when the file does not
contain audio.
Also set duration for audio packets, using the sample rate as the time base.
Update FATE reference to account for now non-existent palette packet.
This also fixes the FATE test if frame data is not initialized in
get_buffer(), so update comment in avconv accordingly.
The rtp demuxer which listens for RTP packets and detects the
RTP payload type will currently get confused if the first packet
received is an RTCP packet. Thus ignore such packets.
Signed-off-by: Martin Storsjö <martin@martin.st>