Commit Graph

10160 Commits

Author SHA1 Message Date
Martin Storsjö fe42f94ce1 dashenc: Don't segment all video streams when one stream gets a keyframe
This makes sure that segments actually start at a keyframe (and
makes sure we don't split segments twice in a row, with one segment
consisting of only a handful of packets), when one stream uses b-frames
while another one doesn't.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-24 11:09:40 +02:00
Vittorio Giovara 30b8eb0f87 sol: simplify sol_codec_id()
Bug-Id: CID 1238993
2014-11-24 01:30:15 +00:00
Vittorio Giovara 065923b078 mpegenc: prevent a NULL pointer dereference
CC: libav-stable@libav.org
Bug-Id: CID 29261
2014-11-24 01:30:14 +00:00
Martin Storsjö f856d9c2f3 dashenc: Don't require the stream bitrate to be known
Don't write any bitrate attribute if it isn't known. As long as one
doesn't want automatic bitrate switching, playback can work just
fine even if it isn't set.

If strict standard compliance is requested, this is still considered
an error, since the attribute is mandatory according to the spec.

Based on a patch by Rodger Combs.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-22 22:16:37 +02:00
Martin Storsjö eec7f032a9 lavf: Remove a redundant include of sys/stat.h
The same file already includes this header a few lines further
above.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-22 22:11:44 +02:00
Michael Niedermayer 4b68edd08a flvenc: Remove an unused variable
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-22 22:10:52 +02:00
Luca Barbato fd9badd3cb xwma: Do not leak on failure path
CC: libav-stable@libav.org
Bug-Id: CID 1087092
2014-11-21 12:27:07 +00:00
Martin Storsjö 7fd10f66b7 hdsenc: Clear the previous codec tag when setting up the chained muxer
The chained flv muxer wants one set of tags - normally this set
could be signaled via the AVOutputFormat codec_tag field (as
smoothstreamingenc and dashenc do). hdsenc doesn't signal it, since
the FLV codec tag arrays aren't exported from flvenc.c. This can
lead to the caller keeping an original codec tag from the originating
container here, which would then be a mismatch for the FLV muxer.
Since we don't really care about what codec tag the caller might
have set, just clear it and let the lavf muxer layer set the right
one for the chained FLV muxer later instead.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-19 13:37:00 +02:00
Martin Storsjö f918b8a293 hdsenc: Use the right filename in an error message
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-19 13:36:43 +02:00
Vittorio Giovara 2007082d2d mov: check ff_get_wav_header() return value
CC: libav-stable@libav.org
Bug-Id: CID 717497
2014-11-18 00:40:06 +01:00
Vittorio Giovara a28468d0da librtmp: append the correct field to the string
Also prevent a NULL pointer dereference.

CC: libav-stable@libav.org
Bug-Id: CID 1250329 / CID 1250331
2014-11-18 00:38:26 +01:00
Martin Storsjö 9257692ac1 lavf: Only initialize s->offset once when using avoid_negative_ts make_zero
When given a stream starting at dts=0, it would previously consider
s->offset as uninitialized and set an offset when the second packet
was written, ending up writing two packets with dts=0. By initializing
this field to AV_NOPTS_VALUE, we make sure that we only initialize it
once, on the first packet.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-17 23:18:55 +02:00
Martin Storsjö c302d034ba tools: Add a sidxindex tool
This tool can write an MPD file for fragmented MP4 files with
a sidx index at the start of the file.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-17 16:17:07 +02:00
Martin Storsjö 40ed1cbf14 movenc: Allow writing a DASH sidx atom at the start of files
This is mapped to the faststart flag (which in this case
perhaps should be called "shift and write index at the
start of the file"), which for fragmented files will
write a sidx index at the start.

When segmenting DASH into files, there's usually one sidx
at the start of each segment (although it's not clear to me
whether that actually is necessary). When storing all of it
in one file, the MPD doesn't necessarily need to describe
the individual segments, but the offsets of the fragments can be
fetched from one large sidx atom at the start of the file. This
allows creating files for the DASH ISO BMFF on-demand profile.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-17 16:17:07 +02:00
Martin Storsjö 3847f3ab58 movenc: Add tfra entries for all tracks in a moof
Previously only tfra entries were added for the first track in each moof.

The frag_info array used for tfra can also be used for writing
other kinds of fragment indexes, where it's more important to
include all tracks.

When the separate_moof option is enabled (as in ismv), we write
a separate moof for each track, so this doesn't make any difference
in that case.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-17 16:17:07 +02:00
Martin Storsjö fe5e6e34c0 lavf: Add an MPEG-DASH ISOFF segmenting muxer
This is mostly to serve as a reference example on how to segment
the output from the mp4 muxer, capable of writing the segment
list in four different ways:
- SegmentTemplate with SegmentTimeline
- SegmentTemplate with implicit segments
- SegmentList with individual files
- SegmentList with one single file per track, and byte ranges

The muxer is able to serve live content (with optional windowing)
or create a static segmented MPD.

In advanced cases, users will probably want to do the segmenting
in their own application code.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-17 16:17:07 +02:00
Martin Storsjö 2ded57371a movenc: Add support for writing sidx atoms for DASH segments
A flag "dash" is added, which enables the necessary flags for
creating DASH compatible fragments.

When this is enabled, one sidx atom is written for each track
before every moof atom.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-17 16:16:46 +02:00
Martin Storsjö 2d9d6afb8d movenc: Factorize adding fragment info into a separate function
By calling this after writing the moof the first time (for
calculating the moof size), we can avoid intermediate storage
of tfrf_offset in MOVTrack.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-17 16:13:02 +02:00
Martin Storsjö 0f9eb9165b movenc: Include empty tracks in iods when writing fragmented mp4
When writing fragmented streams with an empty initial moov,
we won't have any samples in any tracks when writing the
moov atom, thus trust that any tracks that are added actually
will be present.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-17 16:12:02 +02:00
Andrew Stone c64f361511 flvenc: Send new metadata when FLAG_METADATA_UPDATED is set.
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2014-11-17 09:28:16 +01:00
Andrew Stone 4d0cd5f58c flvenc: move metadata updates into a single function
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2014-11-17 09:28:06 +01:00
Marvin Scholz 8562c1483b Icecast: Send content-type in all cases
This is needed because Icecast since version 2.4.1 doesn't default
to audio/mpeg anymore. AVOption default not used here, since a later
check if -content_type is set is performed and would break.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2014-11-15 09:15:39 +01:00
Marvin Scholz 3a6bb97350 Icecast: Send 100-continue header if possible
This allows for proper error reporting. Only do
this for non-legacy requests as only Icecast >2.4.0
will reply with a proper status.
Libav seems to accept both, 100 and 200 status codes, but
let's stay close to spec.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2014-11-15 09:14:04 +01:00
Vittorio Giovara 4b39cc1a09 riff: support ProRes in avi (APCN fourcc) 2014-11-14 20:24:38 +01:00
Martin Storsjö 9a5ac36b69 movenc: Require samples before trying to write edts
This avoids a potential crash if writing a fragmented psp mp4
(which probably is only a hypothetical scenario).

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-08 11:14:21 +02:00
Martin Storsjö 8cb7b7b461 movenc: Avoid leaking locally allocated data when returning on errors
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-08 11:14:08 +02:00
Martin Storsjö 95a449d3ce movenc: Remove an outdated comment
QuickTime does support files with an empty initial movie
these days.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-08 11:13:37 +02:00
Martin Storsjö 9cbf70fa0e movenc: Write correct presentation timestamps in tfra
Previously we wrote decoding timestamps here, while the specs
say it should be presentation timestamps.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-07 14:50:06 +02:00
Martin Storsjö e7d20f12c5 movenc: Remove a now redundant check
When using the new first_trun flag instead of checking the track id,
we don't need to have a special case for the separate_moof flag
any longer.

This simplifies the complicated codepath ever so slightly.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-07 13:46:19 +02:00
Martin Storsjö 1d8a0c1b43 movenc: Allow to request not to use edit lists
In this case, shift tracks to start from zero instead (potentially
stretching the first sample in tracks that start later than the
first one).

Some software does not support edit lists at all, the adobe flash
player seems to be one of these. This results in AV sync errors when
edit lists are used to adjust AV sync.

Some players, such as QuickTime, don't respect the duration for
audio packets, so if an audio track starts later than the video
track and the first audio sample gets a duration longer than the
actual amount of data in it, the result will be out of sync.

Based on patches by Michael Niedermayer.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-07 12:11:46 +02:00
Michael Niedermayer 897d5c3a42 lavf: Print a warning if failed to avoid negative timestamps when requested
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-07 12:11:46 +02:00
Michael Niedermayer 1384df6419 lavf: Add an option for avoiding negative timestamps
This is the same logic as is invoked on AVFMT_TS_NEGATIVE,
but which can be enabled manually, or can be enabled
in muxers which only need it in certain conditions.

Also allow using the same mechanism to force streams to start
at 0.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-07 12:11:35 +02:00
Anton Khirnov 05e59135b3 nutdec: do not set has_b_frames
It is not supposed to be set by demuxers.
2014-11-06 09:05:37 +01:00
Anton Khirnov e839de0f85 oggenc: accept only STREAMINFO extradata
The reasoning is the same as for
0097cbea69.
2014-11-06 09:04:32 +01:00
Anton Khirnov 7784f47762 lavf: stop using avpriv_flac_parse_streaminfo()
The only parameters needed by the demuxers are the sample rate and sample
count, which can be trivially extracted manually, without resorting to
an avpriv function.
2014-11-06 09:02:25 +01:00
Anton Khirnov 56dc46a189 riffenc: do not fall back on AVCodecContext.frame_size for MP3
It will not be set unless the codec context is used as the encoding
context, which is discouraged. For MP2, av_get_audio_frame_duration()
will already set the frame size properly. For MP3, set the frame size
explicitly.
2014-11-06 09:02:08 +01:00
Anton Khirnov 91e8d2eb1f lavf: use the format context strict_std_compliance instead of the codec one 2014-11-06 09:01:49 +01:00
Anton Khirnov 2f3fadfbe3 lavc,lavf: switch to the new vorbis parse API 2014-11-06 09:00:46 +01:00
Anton Khirnov 5e80fb7ff2 lavc: add a public API for parsing vorbis packets.
It is required by (at least) the ogg demuxer.

Mark the current semi-public apriv API for removal.
2014-11-06 08:51:25 +01:00
Anton Khirnov 6896f95b24 vorbis_parser: add an AV prefix to VorbisParseContext
This is done in preparation for making it public.
2014-11-06 08:47:54 +01:00
Martin Storsjö a490391157 rtmpproto: Ignore errors from the getStreamLength method
It is never an error if this method failed. If rt->live was
explicitly set to 0 (known to be a recorded file), print it
as a warning, otherwise print it as a debug message.

Based on a patch by Michael Niedermayer.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-05 09:18:22 +02:00
Martin Storsjö 2f221b6a93 movenc: Define the flag bits using shifts instead of as decimal numbers
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-03 11:43:58 +02:00
Martin Storsjö aae6b3b918 movenc: Don't write any iso brands in ismv files
We deviate slightly from the iso specs for these files.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-30 23:17:00 +02:00
Martin Storsjö c55d1d382c movenc: Don't write any tfdt atom for ismv files
The tfdt atom shouldn't be needed in those cases, we already
write tfxd atoms for ismv anyway, which is roughly equivalent.

This avoids having to declare the iso6 brand for ismv files.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-30 23:16:56 +02:00
Martin Storsjö 00c67fe1d0 movenc: Write a 0 duration in mdhd and tkhd for an empty initial moov
ISO/IEC 14496-12:2012/Cor 1:2013 is explicit about how this should be
handled. All zeros doesn't mean that the full file has got a zero
duration, only that the track samples described within the initial moov
have got zero duration. An all ones duration means an indeterminate
duration.

Keep writing a duration consisting of all ones for the ISM mode -
older windows media player versions won't play a file if this is
zero. (Newer windows media player versions play either version fine.)

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-30 23:16:50 +02:00
Martin Storsjö cf589faa5b movenc: Add a flag for using default-base-is-moof in tfhd atoms
Similarly to the omit_tfhd_offset flag added in e7bf085b, this
avoids writing absolute byte positions to the file, making them
more easily streamable.

This is a new feature from 14496-12:2012, so application support
isn't necessarily too widespread yet (support for it in libav was
added in 20f95f21f in July 2014).

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-29 23:04:04 +02:00
Martin Storsjö 600d5ee6b1 movenc: Signal iso6 in compatible_brands when using tfdt
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-29 23:03:52 +02:00
Martin Storsjö 1e0b81abe8 movenc: Use a local variable consistently
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-29 23:03:45 +02:00
Martin Storsjö b2b79eca6f movenc: Don't check the custom IO flag when using faststart
The custom IO flag actually never is set for muxers, only for
demuxers, so the check was pointless (unless a user intentionally
would set the flag to signal using custom IO).

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-29 23:02:02 +02:00
Martin Storsjö 573b1de2d7 movenc: Don't use track_id to decide which track is the first in a moof
If one track doesn't have any samples within a moof, no traf/trun
is written for it. When the omit_tfhd_offset flag is set, none
of the tfhd atoms have any base_data_offset set, and the implicit
offset (end of previous track fragment data, or start of the moof
for the first trun) is used.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-29 23:01:27 +02:00