1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00
Commit Graph

261 Commits

Author SHA1 Message Date
Andreas Rheinhardt
f4a2d722aa avformat/internal: Move muxing-only functions to new mux.h header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 07:27:01 +02:00
Martin Storsjö
a78f136f3f configure: Use a separate config_components.h header for $ALL_COMPONENTS
This avoids unnecessary rebuilds of most source files if only the
list of enabled components has changed, but not the other properties
of the build, set in config.h.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-16 14:12:49 +02:00
Vittorio Giovara
e4fc86a458 dash: convert to new channel layout API
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:31 -03:00
Marton Balint
64834bb86a avformat: introduce AVFormatContext io_close2 which returns an int
Otherwise there is no way to detect an error returned by avio_close() because
ff_format_io_close cannot get the return value.

Checking the return value of the close function is important in order to check
if all data was successfully written and the underlying close() operation was
successful.

It can also be useful even for read mode because it can return any pending
AVIOContext error, so the user don't have to manually check AVIOContext->error.

In order to still support if the user overrides io_close, the generic code only
uses io_close2 if io_close is either NULL or the default io_close callback.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-12-12 00:32:20 +01:00
Andreas Rheinhardt
5e01fc8318 avformat/dashenc: Don't use stack packet
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-27 12:55:41 +01:00
Andreas Rheinhardt
a5ee166327 avformat/avformat: Add AVStream parameter to check_bitstream() sig
For most check_bitstream() functions this just avoids having
to dereference s->streams[pkt->stream_index] themselves; but for
meta-muxers it will allow to forward the packet to stream with
a different stream_index (belonging to a different AVFormatContext)
without using a spare packet.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-27 12:55:41 +01:00
Zhao Zhili
a0f9650046 avformat/dashenc: enabling streaming and hls_playlist for lhls
Try to make the feature easier to use, especially since the user
have enabled -strict experimental manually. The user shouldn't
be surprised that hls_playlist is enabled for lhls automatically,
so change the log level from warning to info for that.
2021-11-05 15:32:11 -03:00
Zhao Zhili
f6b90d5fef avformat/dashenc: enabling streaming automatically for ldash
There is a little chance that user specified contradicted options
like -streaming 0 -ldash 1, however, it's more likely that user
didn't know or forgot to enable streaming for ldash. So enabling
streaming automatically to make the feature easier to use, similar
like enable FF_MOV_FLAG_FRAGMENT/EMPTY_MOOV/DEFAULT_BASE_MOOF and
so on for FF_MOV_FLAG_CMAF.
2021-11-05 15:30:43 -03:00
Limin Wang
f05559554c avformat/dashenc: Fix comparing double with 0
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-03 21:38:37 +08:00
Andreas Rheinhardt
40bdd8cc05 avformat: Avoid allocation for AVStreamInternal
Do this by allocating AVStream together with the data that is
currently in AVStreamInternal; or rather: Put AVStream at the
beginning of a new structure called FFStream (which encompasses
more than just the internal fields and is a proper context in its own
right, hence the name) and remove AVStreamInternal altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 13:22:25 +02:00
Andreas Rheinhardt
fd101c9c3b avformat/internal: Move ff_read_line_to_bprint_overwrite to avio_internal.h
It only uses an AVIOContext and an AVBPrint.

When doing so, it turned out that several non-users of
ff_read_line_to_bprint_overwrite() and ff_bprint_to_codecpar_extradata()
relied on libavformat/internal.h to include bprint.h or avstring.h
for them. In order to avoid a repeat of this and in order to reduce
unnecessary dependencies, a forward declaration of struct AVBPrint is
used instead of including bprint.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-29 22:02:05 +02:00
Kevin LaFlamme
3f5d5c1c2d Fix double write of DASH manifest in streaming mode
When streaming mode is enabled, the DASH manifest is written on the
first packet for the segment so that the segment can be advertised
immediately to clients. It was also still writing the manifest at the
end of the segment leading to two duplicate writes.
2021-07-14 19:54:14 +05:30
Kevin LaFlamme
7d1464721e dashenc: Write out DASH manifest immediately in streaming mode
When streaming mode is enabled with fMP4/CMAF for DASH output, the
segment files are available to read by players as soon as the first byte
is written instead of only after the file is fully written. The DASH
manifest currently only gets written when the final write to the segment
file occurs. This means that players cannot stream the first segment
while it is being written.

When -lhls is enabled with MP4 segments the HLS manifest is written
immediately to advertise the in-flight segments. This change adds the
same behavior for the DASH manifest so players can stream it
immediately.
2021-06-14 21:47:09 +05:30
Limin Wang
f21626b67b avformat/dashenc: use av_match_ext()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-06-14 21:11:24 +05:30
Valerii Zapodovnikov
812f39ee85 Revert "avformat/dashenc: Disable writing CODECS tag for HEVC streams"
This reverts commit d6d407d2d7.
Hack not needed after a2b1dd0ce3.
Will fix #7480 and #8904.
This will include e.g. CODECS="hvc1.2.4.L123.B0" into m3u8.

Signed-off-by: Valerii Zapodovnikov <val.zapod.vz@gmail.com>
2021-06-08 22:59:26 +05:30
Przemysław Sobala
575e52272d lavf/dashenc.c: Fix creating audio-only HLS playlists
With audio/video HLS playlists, audio chunklists are treated as
alternative renditions for video chunklists. This is wrong for
audio-only HLS playlists.

fixes: 9252
2021-06-01 11:58:26 +05:30
Anton Khirnov
9d4c018497 avio: do not export avpriv_io_{move,delete}
They are private and not used by anything outside of lavf. There is no
reason for them to be exported.
2021-05-22 15:27:55 +02:00
Andreas Rheinhardt
bc70684e74 avformat: Constify all muxer/demuxers
This is possible now that the next-API is gone.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 11:48:06 -03:00
Andreas Rheinhardt
ef6a9e5e31 avutil/buffer: Switch AVBuffer API to size_t
Announced in 14040a1d91.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:13 -03:00
Andreas Rheinhardt
e5bcda6473 avformat/dashenc: Remove deprecated min_seg_duration option
Deprecated in 01ba52852d.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:09 -03:00
James Almer
e07126f54a avformat: use the buffer_size_t typedef where required
Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-10 20:26:36 -03:00
Chris Miceli
4136652289 libavformat/dashenc: Reduce confusion in par error message
In ticket #8754 there is discourse surrounding the error
message which is printed upon a mismatched aspect ratio in
derived encodings. This should make it clearer to the user
as to the issues which they are experiencing.

Reviewed-by: "Jeyapal, Karthick" <kjeyapal@akamai.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-31 23:43:06 +02:00
Siyuan Huang
05feb7a26b libavformat/dashenc.c: Support mpd update period
According ISO 23009-1, in live cases, mpd refresh period should be configurable

Signed-off-by: Siyuan Huang <saber.huang@samsung.com>
2020-07-09 11:17:32 +05:30
Przemysław Sobala
82352f3c1a avformat/dashenc: Calculate average bitrate for adaptation sets in static manifest
If stream's bitrate is not specified:
- for static manifest: an average bitrate will be calculated and used,
- for dynamic manifest: first segment's bitrate will be calculated and used, as before,
for bandwidth setting in adaptation sets.
2020-06-22 10:32:44 +05:30
Przemysław Sobala
19726288d8 Revert "avformat/dashenc: use AVStream timebase when computing missing bitrate"
This reverts commit 2a9ffd89fc as duration is always in AV_TIME_BASE units
2020-06-22 10:32:10 +05:30
Przemysław Sobala
9d80f3ec4b avformat/dashenc: Add hls_master_name option 2020-06-15 12:31:57 +05:30
Przemysław Sobala
2a9ffd89fc avformat/dashenc: use AVStream timebase when computing missing bitrate 2020-06-01 18:58:04 +05:30
Limin Wang
52bd9342dc avformat/dashenc: remove the arbitrary restrictions for filename
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-01 22:57:29 +08:00
Limin Wang
a9029703bb avformat/dashenc: use av_reallocp_array()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-04-29 11:58:03 +05:30
Limin Wang
759565ccf8 avformat/dashenc: use local variable and avoid calculate duration multiple times
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-04-29 11:57:31 +05:30
Limin Wang
839d024fab avformat/dashenc: cosmetics
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-04-29 11:56:56 +05:30
Marton Balint
1128aa8753 avformat: only allow a single bitstream filter when muxing
Current muxers only use a single bitstream filter, so there is no need to
maintain code which operates on a list of bitstream filters. When multiple
bitstream filters are needed muxers can simply use a list bitstream filter.

If there is a use case in the future when different bitstream filters should be
added at subsequent packets then a new API possibly involving reconfiguring the
list bitstream filter can be added knowing the exact requirements.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-26 22:39:01 +02:00
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