Skip the codec_tag altogether here, to let the user (try to) set
whichever codec/tag is preferred; the individual chained muxer will
reject invalid codecs anyway.
(cherry picked from commit 61f589e31e)
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Provides a way to change bandwidth parameter inside DASH manifest after a non-CBR H.264 encoding.
Caller now is able to compute the bitrate by itself, after all packets have been written, and then set that value in AVFormatContext->streams->codecpar->bit_rate before calling av_write_trailer. As a result that value will be set in DASH manifest.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Skips using temporary files when outputting to a protocol other than
"file", which enables dash to output content over network
protocols. The logic has been copied from the HLS format.
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
The current implementation creates new segments comparing
pkt->pts - first_pts > nb_segs * min_seg_duration
This works fine, but if the keyframe interval is smaller than "min_seg_duration"
segments shorter than the minimum segment duration are created.
Example: keyint=50, min_seg_duration=3000000
segment 1 contains keyframe 1 (duration=2s < total_duration=3s)
and keyframe 2 (duration=4s >= total_duration=3s)
segment 2 contains keyframe 3 (duration=6s >= total_duration=6s)
segment 3 contains keyframe 4 (duration=8s < total_duration=9s)
and keyframe 5 (duration=10s >= total_duration=9s)
...
Segment 2 is only 2s long, shorter than min_seg_duration = 3s.
To fix this, new segments are created based on the actual written duration.
Otherwise the option name "min_seg_duration" is misleading.
Signed-off-by: Peter Große <pegro@friiks.de>
Signed-off-by: Martin Storsjö <martin@martin.st>
If set, adds a UTCTiming tag in the manifest.
This is part of the recommendations listed in the "Guidelines for
Implementations: DASH-IF Interoperability Points" [1][2]
Section 4.7 describes means for the Availability Time Synchronization.
A usable default is "https://time.akamai.com/?iso"
[1] http://dashif.org/guidelines/
[2] http://dashif.org/wp-content/uploads/2016/12/DASH-IF-IOP-v4.0-clean.pdf
(current version as of writing)
Signed-off-by: Peter Große <pegro@friiks.de>
Signed-off-by: Martin Storsjö <martin@martin.st>
to avoid rebuffering on the clientside for difficult network conditions.
Signed-off-by: Anton Schubert <ischluff@mailbox.org>
Signed-off-by: Martin Storsjö <martin@martin.st>
Appends Z to timestamp to force ISO8601 datetime parsing as UTC.
Without Z, some browsers (Chrome) interpret the timestamp as
localtime and others (Firefox) interpret it as UTC.
Signed-off-by: Anton Schubert <ischluff@mailbox.org>
Signed-off-by: Martin Storsjö <martin@martin.st>
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.
Some (de)muxers open additional files beyond the main IO context.
Currently, they call avio_open() directly, which prevents the caller
from using custom IO for such streams.
This commit adds callbacks to AVFormatContext that default to
avio_open2()/avio_close(), but can be overridden by the caller. All
muxers and demuxers using AVIO are switched to using those callbacks
instead of calling avio_open()/avio_close() directly.
(de)muxers that use the URLProtocol layer directly instead of AVIO
remain unconverted for now. This should be fixed in later commits.
DASH manifest should have framerate specified as an attribute in the
AdaptationSet element and Representation elements. Though ISO/IEC
23009-1:2014 doesn't seem to define frameRate as a required attribute,
it is at least optional, and DASH-IF IOP 3.0 seems to require it. See
section 3.2.4 of http://dashif.org/w/2015/04/DASH-IF-IOP-v3.0.pdf
In the event that avg_frame_rate is not set in the muxer, we ignore the
frameRate tag altogther.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
id should be an integer, not a string. It is also optional, so use
contentType instead which is the proper attribute for these values.
This addresses ticket #4545, fixing an MPD validation error.
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This makes sure that the time + duration of the first segment
matches the start time of the next segment for e.g. AAC audio
with encoder delay.
Signed-off-by: Martin Storsjö <martin@martin.st>
id should be an integer, not a string. It is also optional, so use
contentType instead which is the proper attribute for these values.
This fixes an MPD validation error.
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
This avoids that the mp4 muxer does a similar heuristic, adjusting
the timestamps in a way that the dash muxer doesn't know the actual
timestamps written to the file in the end. By making sure that the
mp4 muxer internal heuristic isn't applied, we know the exact
timestamps written to file, so that the timestamps in manifest match
the files.
Signed-off-by: Martin Storsjö <martin@martin.st>
The mov muxer already supports picking up extradata that wasn't
present during the avformat_write_header call - we just need to
propagate it. Since the dash muxer uses delay_moov, we have time
up until the first segment is written to get extradata filled in.
Also update the codec description string when the extradata becomes
available.
Signed-off-by: Martin Storsjö <martin@martin.st>
This should be more correct. This also should give more sensible
switching between video streams with different amount of b-frame
delay.
The current dash.js release (1.2.0) fails to start playback of
such files from the start (if the start pts is > 0), but this has
been fixed in the current git version of dash.js.
Also enable the use of edit lists, so that streams in many cases
start at pts=0.
Signed-off-by: Martin Storsjö <martin@martin.st>
When writing an explicit time, reset the cur_time variable to this
value as well. This avoids writing excessive time attributes for each
segment in the timeline, as long as the segments are continuous.
Signed-off-by: Martin Storsjö <martin@martin.st>
This is the same adjustment that the mp4 muxer does to the start
timestamp of fragments, since the timestamp of a sample in an mp4
file is implicit from the sum of earlier sample durations.
This avoids gaps in the timeline (which can stop dash.js from
playing it back), and makes sure the timestamp on the segmenter
level matches what the mp4 muxer actually writes into the segments.
This is only an issue if the AVPacket duration of the last
packet of a segment doesn't point to the actual start timestamp
of the next packet (the first in the next segment).
Signed-off-by: Martin Storsjö <martin@martin.st>
Write a new start time if the duration of the previous segment
didn't match the start of the next one. Check that segments
actually are continuous before writing a repeat count.
This makes sure timestamps deduced from the timeline actually
match the real start timestamp as written in filenames (if
using a template containing $Time$).
Signed-off-by: Martin Storsjö <martin@martin.st>
For the last_duration field, it's mostly theoretical, but the
total_duration field more probably may need to actually be 64 bit.
Bug-Id: CID 1254944
Signed-off-by: Martin Storsjö <martin@martin.st>
As the manifest/segments are flushed to disk, log to stderr the
progress, when in verbose logging mode
Signed-off-by: Martin Storsjö <martin@martin.st>
This fixes the build on compilers that interpreted the earlier
code as a variable length array (which we intentionally disallow).
Signed-off-by: Martin Storsjö <martin@martin.st>
This allows one to specify templated segment names for init-segments,
media-segments, and for the base-url in the case of single-file.
Signed-off-by: Martin Storsjö <martin@martin.st>
This reverts commit b9d08c77a4.
After taking MoveFileEx into use, we can replace files with renames
on windows as well.
Signed-off-by: Martin Storsjö <martin@martin.st>
On windows, rename(2) will fail if the target file exists. On
unix this trick is used to make sure that people reading the file
either will get the full previous file, or the full new version
of the file, but no intermediate version.
Signed-off-by: Martin Storsjö <martin@martin.st>
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>