Commit Graph

229 Commits

Author SHA1 Message Date
James Almer
1f5d6e6b66 avformat/dashenc: add missing startWithSap attribute to AdaptationSet elements
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-20 13:49:15 -03:00
James Almer
ff327a58f1 avformat/dashenc: add a PlaybackRate element
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-20 13:49:15 -03:00
James Almer
0ea41ee32e avformat/dashenc: add a maxSegmentDuration attribute to the Manifest
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-20 13:49:15 -03:00
James Almer
e6fb3aba42 avformat/dashenc: fix typo in ProducerReferenceTime elements
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-15 17:09:34 -03:00
Limin Wang
cd8c5e89ba avformat: add subtitle support in master playlist m3u8
Test with the following command for the webvtt subtitle:
$ ./ffmpeg -y -i input_with_subtitle.mkv \
 -b✌️0 5250k -c:v h264 -pix_fmt yuv420p -profile:v main -level 4.1 \
 -b🅰️0 256k \
 -c:s webvtt -c:a mp2 -ar 48000 -ac 2 -map 0:v -map 0🅰️0 -map 0:s:0 \
 -f hls -var_stream_map "v:0,a:0,s:0,sgroup:subtitle" \
 -master_pl_name master.m3u8 -t 300 -hls_time 10 -hls_init_time 4 -hls_list_size \
 10 -master_pl_publish_rate 10  -hls_flags \
 delete_segments+discont_start+split_by_time ./tmp/video.m3u8

Check the master m3u8:
$ cat tmp/master.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subtitle",NAME="subtitle_0",DEFAULT=YES,URI="video_vtt.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=6056600,RESOLUTION=1280x720,CODECS="avc1.4d4829,mp4a.40.33",SUBTITLES="subtitle"
video.m3u8

Check the result by convert to mkv:
$ ./ffmpeg -strict experimental -i ./tmp/master.m3u8 -c:v copy -c:a mp2 -c:s srt ./test.mkv

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-04-08 23:02:41 +08:00
James Almer
e9aa1bfd8c avformat/dashenc: use a quieter log lever when informing prft was automatically enabled
Suggested-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-02-26 11:05:45 -03:00
James Almer
5dda6c173f avformat/dashenc: always attempt to enable prft in ldash mode
Signed-off-by: James Almer <jamrial@gmail.com>
2020-02-22 23:19:07 -03:00
James Almer
dbd02443ae avformat/dashenc: write a capture time Producer Reference Time element when none is provided by the encoder
This way, the element will be present in any scenario when the write_prft option is used.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-02-22 23:19:07 -03:00
James Almer
7098989e70 avformat/dashenc: write the styp box when the first frame of a segment is ready
This ensures it's written at the beginning of a segment in non streaming mode
when segment duration differs from fragment duration.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-02-22 23:19:07 -03:00
James Almer
601d574440 avformat/dashenc: warn if Producer Reference Time element option is missing when ldash mode is used
Signed-off-by: James Almer <jamrial@gmail.com>
2020-02-17 12:44:18 -03:00
James Almer
55cbccbc2c avformat/dashenc: disable Resync elements when using DVB-DASH profile
Signed-off-by: James Almer <jamrial@gmail.com>
2020-02-17 12:16:07 -03:00
James Almer
17ece3f745 avformat/dashenc: always set coding_dependency to 1 if a parser isn't used
Signed-off-by: James Almer <jamrial@gmail.com>
2020-02-16 14:42:00 -03:00
James Almer
29be3de926 avformat/dashenc: include an availabilityTimeComplete element in all streaming modes
It's not exclusive for Low Latency streaming. The muxer will serve partial
segments regardless of streaming mode.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-02-16 14:02:45 -03:00
James Almer
d2a33f665c avformat/dashenc: add Trick Mode support for AdaptationSets
Signed-off-by: James Almer <jamrial@gmail.com>
2020-02-16 14:02:38 -03:00
James Almer
4d27def59c avformat/dashenc: make AdaptationSet id an integer value
Unlike Representation id, it's defined as an integer in the spec, and not as a
string.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-02-16 13:11:16 -03:00
Marton Balint
3cdc71348e avformat/dashenc: use AV_OPT_TYPE_DICT for http_opts
This changes the separator character from comma to colon, but since this option
was only added recently I think it should be done for consistency with other
similar options.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-02-03 21:42:35 +01:00
Alfred E. Heggestad
d550a28560 dashenc: check pts to prevent division by zero error
this usecase will cause a division by zero trap:

1. dashenc has received one frame
2. os->max_pts and os->start_pts have same value
3. delta between max_pts and start_pts is 0
4. av_rescale_q(0, x, y) returns 0
5. this value is used as denominator in division
6. Bang! -> segfault

this fix checks that max_pts > start_pts.
the fix has been tested and works.

Signed-off-by: Alfred E. Heggestad <alfred.heggestad@gmail.com>
Reviewed-by: Jeyapal, Karthick <kjeyapal@akamai.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-31 10:15:37 -03:00
Marton Balint
b5dba152ef avformat/dashenc: use ff_rename instead of avpriv_io_move
ff_rename always logs the error message.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-19 22:17:04 +01:00
James Almer
05b3460991 avformat/dashenc: add an option to write a Latency element
Allows to set an intended target latency while streaming that clients can use
to measure when using low latency mode.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-15 23:34:22 -03:00
Anton Khirnov
bc4f0e713b dashenc: support setting arbitrary HTTP protocol options
Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-15 23:34:22 -03:00
James Almer
c96a9636c8 avformat/dashenc: allow setting custom movflags using format_options
Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-15 23:34:21 -03:00
James Almer
f63407a986 avformat/dashenc: implement DVB-DASH profile
Add new required elements and constrain presence and values for existing
ones based on the spec.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-15 23:34:21 -03:00
James Almer
21847e2a52 avformat/dashenc: add an option to enable low latency Dash manifest
In combination with the streaming option it constrains the value of a few elements,
to prevet clients from buffering too much data before starting presentation.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-15 23:34:20 -03:00
James Almer
7e5d143bb5 avformat/dashenc: Write a Producer Reference Time element
Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-15 23:34:20 -03:00
James Almer
ea5a910628 avformat/dashenc: allow splitting fragments following P-Frame reordering
Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-15 12:22:29 -03:00
James Almer
ceb236c1c5 avformat/dashenc: allow setting fragment durations
Implemented as as a frag_duration muxer option and key=value entry in the
adaptation_sets muxer option. It has the same syntax as the seg_duration option.
A new frag_type option is also introduced to select the kind of fragmentation.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-15 12:22:28 -03:00
James Almer
0c19dd2df4 avformat/dashenc: allow setting segment durations per AdaptationSet
Implemented as as a seg_duration key=value entry in the adaptation_sets muxer
option.
It has the same syntax as the global seg_duration option, and has precedence
over it if set.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-15 12:22:28 -03:00
Andreas Rheinhardt
8aeab0dbc1 avformat/dashenc: Fix leak of AVFormatContext on error
The Dash muxer uses submuxers and when one such submuxer has been allocated,
it is initially only stored in a temporary variable. Therefore it leaks
if an error happens between the allocation and storing it permanently.
This commit changes this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: "Jeyapal, Karthick" <kjeyapal@akamai.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-01-08 01:32:26 +01:00
Marton Balint
59172164f3 avformat/dashenc: use AV_OPT_TYPE_DICT for format_options
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-01 20:41:34 +01:00
Steven Liu
b26225a3c7 avformat/dashenc: remove unused check of avformat_free_context
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: Jun Zhao <barryjzhao@tencent.com>
Reviewed-by: Jeyapal, Karthick <kjeyapal@akamai.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-12-02 00:08:07 +08:00
James Almer
1cf2f040e3 avformat/dashenc: fix writing the AV1 codec string in mp4 mode
From https://aomediacodec.github.io/av1-isobmff/#codecsparam, the parameters
sample entry 4CC, profile, level, tier, and bitDepth are all mandatory fields.
All the other fields are optional, mutually inclusive (all or none).

Fixes ticket #8049

Signed-off-by: James Almer <jamrial@gmail.com>
2019-08-03 12:33:15 -03:00
James Almer
ce6a98e830 avformat/dashenc: update stream extradata from packet side data
codecpar->extradata is not going to change between packets. New extradata
is instead propagated using packet side data.

Use ff_alloc_extradata() as well.

Signed-off-by: James Almer <jamrial@gmail.com>
2019-08-03 12:33:14 -03:00
Leo Zhang
116303cd24 avformat/dashenc: add descriptor which is useful to the scheme defined by ISO/IEC 23009-1:2014/Amd.2:2015.
Signed-off-by: leozhang <leozhang@qiyi.com>
2019-07-22 07:57:39 +05:30
Alfred E. Heggestad
2b634e7c23 avformat/dashenc: split extension for MP4 into .mp4 or .m4s 2019-06-25 15:07:44 +05:30
Steven Liu
fa7a6dbd76 avformat/hlsenc: add EXT-X-I-FRAMES-ONLY tag support
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-06-14 10:53:23 +08:00
Michael Niedermayer
359d4e10a0 avformat/dashenc: use 64bit for handling the return of avio_tell()
The return code is 64bit, so this is more correct, especially in case it
actually would be a file of such large size

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-05-17 09:32:21 +05:30
Karthick J
eeca67e023 avformat/dashenc: Fix a bug with writing "final" manifest
This bug was introduced in the commit 951561b64e
2019-04-22 11:31:25 +05:30
Karthick J
bcde9ec020 avformat/dashenc: Disable streaming for webm output
Currently streaming for webm output doesn't work.
Disabling explicitly will make sure that the manifest will get generated correctly.
2019-04-16 15:59:05 +05:30
joepadmiraal
951561b64e libavformat/dashenc : Prevent writing manifest files multiple times 2019-04-10 12:32:17 +05:30
Karthick J
6aeaac3e1c avformat/dashenc: Add support for Global SIDX 2019-04-02 11:16:06 +05:30
joepadmiraal
056a2ac168 avformat/dashenc: Added #EXT-X-PROGRAM-DATE-TIME to HLS playlists 2019-03-06 10:58:57 +05:30
Karthick J
2e67f751b5 avformat/dashenc: Added comments
Added comments regarding usage of certain movflags in streaming mode.
2019-02-25 11:40:54 +05:30
Karthick J
ca5ec4cbbc avformat/dashenc: Added option to repeatedly publish master playlist
The master playlist can be published at a specified interval with this option
2019-02-25 11:40:47 +05:30
Steven Liu
1e03d60054 avformat/hlsenc: add var_stream_map LANGUAGE field string parameter
use a:0,agroup:aud_low,default:Yes,language:CHN a:1,agroup:aud_low,language:ENG
        a:2,agroup:aud_high,default:YesYes,language:CHN a:3,agroup:aud_high,language:ENG
        v:0,agroup:aud_low v:1,agroup:aud_high
        create master m3u8 list.

result:
EXTM3U
EXT-X-VERSION:3
EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_aud_low",NAME="audio_0",DEFAULT=YES,LANGUAGE="CHN",URI="out_0.m3u8"
EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_aud_low",NAME="audio_1",DEFAULT=NO,LANGUAGE="ENG",URI="out_1.m3u8"
EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_aud_high",NAME="audio_2",DEFAULT=YES,LANGUAGE="CHN",URI="out_2.m3u8"
EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_aud_high",NAME="audio_3",DEFAULT=NO,LANGUAGE="ENG",URI="out_3.m3u8"
EXT-X-STREAM-INF:BANDWIDTH=1170400,RESOLUTION=640x480,CODECS="avc1.64001e,mp4a.40.2",AUDIO="group_aud_low"
out_4.m3u8
EXT-X-STREAM-INF:BANDWIDTH=3440800,RESOLUTION=640x480,CODECS="avc1.64001e,mp4a.40.2",AUDIO="group_aud_high"
out_5.m3u8

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-01-31 16:17:11 +08:00
Karthick J
1db30d6cec avformat/dashenc: Skip writing trailer for MP4 output when in streaming mode
In streaming mode mp4 trailer is not required for playout.
2019-01-28 11:07:10 +05:30
Karthick J
b6d96a6bcc avformat/dashenc: Format xs:datetime in millisecond precision
For low latency streaming even milliseconds matter!
2019-01-21 14:50:23 +05:30
kjeyapal@akamai.com
f22fcd4483 avformat/dashenc: Added support for Low-latency HLS(Experimental)
Apple doesn't have an official spec for LHLS. Meanwhile hls.js player folks are
trying to standardize a open LHLS spec. The draft spec is available in https://github.com/video-dev/hlsjs-rfcs/blob/lhls-spec/proposals/0001-lhls.md
This option will also try to comply with the above open spec, till Apple's spec officially supports it.
Applicable only when @var{streaming} and @var{hls_playlist} options are enabled.
2018-12-17 12:11:55 +05:30
kjeyapal@akamai.com
d209a3d50f avformat/dashenc : Refactored HLS media playlist related code
Made it as a separate function, so that it could be reused (in future)
2018-12-17 12:11:18 +05:30
kjeyapal@akamai.com
876ed08b0d avformat/dashenc: Used the movenc option skip_sidx instead of global_sidx
Anyways the intended behaviour was to disable SIDX atom.
2018-12-11 10:53:18 +05:30
Andrey Semashev
f176d6587b lavf/dashenc: Write media trailers when DASH trailer is written.
This commit ensures that all (potentially, long) filesystem activity is
performed when the user calls av_write_trailer on the DASH libavformat
context, not when freeing the context. Also, this defers media segment
deletion until after the media trailers are written.
2018-12-04 10:34:29 +05:30