Commit Graph

170 Commits

Author SHA1 Message Date
Michael Niedermayer
21b459e4bb avformat/segment: Fix header_filename handling
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-10 17:59:58 +01:00
Derek Buitenhuis
bc9a5965c8 Merge commit '9f61abc8111c7c43f49ca012e957a108b9cc7610'
This also deprecates our old duplicated callbacks.

* commit '9f61abc8111c7c43f49ca012e957a108b9cc7610':
  lavf: allow custom IO for all files

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-10 14:42:41 +00:00
Michael Niedermayer
fe3fed0b14 Update demuxers and protocols for protocol whitelist support
Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-02 04:16:50 +01:00
Marton Balint
369a6a6ed4 lavf/segment: add new option segment_clocktime_wrap_duration
This option can force the segmenter to only start a new segment if a packet
reaches the muxer within the specified duration after the segmenting clock
time, which makes it more resilient to backward local time jumps, such as leap
seconds or transition to standard time from daylight savings time.

Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2016-01-28 21:35:44 +01:00
Marton Balint
1036a1b8a3 lavf/segment: add support for specifying clock time offset
Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2016-01-28 21:35:37 +01:00
Anton Khirnov
9f61abc811 lavf: allow custom IO for all files
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.
2016-01-24 16:45:32 +01:00
Lvqier
93d336fb07 avformat/segment: Fix memory leak of cur_entry.filename
Solution suggested-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-12 23:19:22 +01:00
Clément Bœsch
43ecec0f03 avformat: use AV_OPT_TYPE_BOOL in a bunch of places 2015-12-04 15:43:33 +01:00
Michael Niedermayer
e2b19a533d avformat/segment: atomically update list if possible
Fixes Ticket4802

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-08-28 00:09:56 +02:00
Michael Niedermayer
dda6925357 avformat/segment: Do not free the filename twice
Bug introduced in 83a508cda5

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-08-26 03:50:52 +02:00
Carl Eugen Hoyos
83a508cda5 lavf/segment: Fix memleak.
Reviewed-by: Stefano Sabatini
Reviewed-by: Ganesh Ajjanagadde
2015-08-25 13:36:24 +02:00
Ronald S. Bultje
229843aa35 Replace av_dlog with ff_dlog.
ff_dlog checks compilability, and is non-public. av_dlog is deprecated
and no longer exists if FF_API_DLOG=0.
2015-08-18 10:24:01 -04:00
Michael Niedermayer
449c74f629 Merge commit '8a78ae2d2101622fd244b99178d8bc61175c878e'
* commit '8a78ae2d2101622fd244b99178d8bc61175c878e':
  segment: Check open_null_ctx() return value

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-12 22:10:47 +02:00
Vittorio Giovara
8a78ae2d21 segment: Check open_null_ctx() return value
Reported-By: infer
2015-06-12 17:02:48 +01:00
Rodger Combs
e60b018c74 lavf/segment: add an option to allow breaking on non-keyframes
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-09 13:26:00 +02:00
Michael Niedermayer
235589ee9e avformat/segment: Change enum to int, which is accessed via AVOption as int
This fixes depending on implementation defined behavior

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-07 23:21:48 +02:00
Rodger Combs
5cba5291a7 lavf/segment: style nits
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-31 04:34:32 +02:00
Rodger Combs
de2aaf1a2a lavf/segment: Mark output contexts as non-seekable when applicable
This prevents sub-muxers from trying to seek back to the beginning of the
whole stream, only to find themselves overwriting some video data in the
current (often last) segment.

We only do this when not writing individual header/trailers.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-29 19:04:17 +02:00
Rodger Combs
7b060a96ad libavformat/segment: add an option to write the header to a separate file
This permits some interesting segmenting techniques with formats like Matroska,
where you can concatenate the header and segments [N, nb_segments) and get
a working file that starts at segment N's start time.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-29 16:17:04 +02:00
Rodger Combs
481f0f153a libavformat/segment: don't leave the list pb open when not in use
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-29 14:44:21 +02:00
Michael Niedermayer
a0fe1a25fa Merge commit 'daf8cf358a098a903d59adb6c0d0cc3262a8c93e'
* commit 'daf8cf358a098a903d59adb6c0d0cc3262a8c93e':
  avformat: Don't anonymously typedef structs

Conflicts:
	libavformat/adtsenc.c
	libavformat/aiffenc.c
	libavformat/avidec.c
	libavformat/gif.c
	libavformat/iff.c
	libavformat/img2dec.c
	libavformat/jvdec.c
	libavformat/matroskadec.c
	libavformat/udp.c
	libavformat/wtvdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-14 21:07:40 +01:00
Diego Biurrun
daf8cf358a avformat: Don't anonymously typedef structs 2015-02-14 10:13:47 -08:00
Vittorio Giovara
3a6dfec864 segment: Check av_get_frame_filename() return value
CC: libav-stable@libav.org
Bug-Id: CID 1265713
2015-01-23 14:55:03 +00:00
Michael Niedermayer
e2404096b0 avformat/segment: Clear contexts after deallocation
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-07 22:29:16 +01:00
Michael Niedermayer
2a741baeff Merge commit 'b3f04657368a32a9903406395f865e230b1de348'
* commit 'b3f04657368a32a9903406395f865e230b1de348':
  segment: Fix the failure paths

Conflicts:
	libavformat/segment.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-07 22:15:45 +01:00
Luca Barbato
b3f0465736 segment: Fix the failure paths
A failure in segment_end() or segment_start() would lead to freeing
a dangling pointer and in general further calls to seg_write_packet()
or to seg_write_trailer() would have the same faulty behaviour.

CC: libav-stable@libav.org
Reported-By: luodalongde@gmail.com
2015-01-07 12:36:28 +01:00
Pedro E. M. Brito
202947a066 libavformat/segment.c: Add strftime expansion for segment filename templates
Allows expansion of the filename template with strftime() with the option
-strftime 1 (disabled by default). This allows segments to be named by time of
creation, adding some flexibility.

Fixes Ticket 4104 (add strftime to segment muxer)

Signed-off-by: Pedro E. M. Brito <pedroembrito@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-28 21:48:44 +01:00
Michael Niedermayer
68fa549230 avformat/segment: Use av_freep() avoid leaving stale pointers in memory
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-25 12:51:48 +01:00
Michael Niedermayer
ce80f9fee9 avformat/segment: export inner muxer timebase
Fixes "Non-monotonous DTS in output stream 0:0"
Fixes Ticket4020

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-16 03:02:29 +01:00
Michael Niedermayer
32a2876b12 avformat/segment: use time_internal.h, simplify code
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-02 20:07:34 +01:00
Mika Raento
75c8d7c2b4 hlsenc.c, segment.c: propagate defaults to mpegts
This fixes the abnormally high ts overhead in the files produced by the
HLS and segments muxers. See https://trac.ffmpeg.org/ticket/2857 . For
example makes it much more likely that it can produces streams that fit
under the 64kb App store limit.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-17 21:31:25 +02:00
Michael Niedermayer
3726d07a2a Merge commit '28816050e47b6dba430a52e429d21a864cffda8e'
* commit '28816050e47b6dba430a52e429d21a864cffda8e':
  lavf: Set the stream time base hint properly for chained muxers

Conflicts:
	libavformat/segment.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-07 02:51:08 +02:00
Martin Storsjö
28816050e4 lavf: Set the stream time base hint properly for chained muxers
This avoids warnings about using the codec time base as time
base hint.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-06 23:30:52 +03:00
Stefano Sabatini
f51de9cac2 lavf/segment: abort in case of invalid segment format options 2014-09-08 15:22:55 +02:00
Stefano Sabatini
4f5493fe23 lavf/segment: add segment_format_options option 2014-09-07 13:17:46 +02:00
Mika Raento
502fc3b3d4 segment: fix copying stream metadata
To get mpegts metadata copied when segmenting.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-09-02 12:31:04 +02:00
Mika Raento
413fa76f61 segment: use mpegts_flags instead of the deprecated resend_headers option
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-09-02 12:31:04 +02:00
Michael Niedermayer
0ffe32cf8f avformat/segment: Use avformat_alloc_output_context2()
This avoids having to assign oformat, allows returning the
correct error code and allocates priv_data

Based on patch by: Mika Raento <mika.raento@elisa.fi>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-09-02 12:31:04 +02:00
Mika Raento
58e0402e02 segment: don't access outside seg->frames array
Fixes wrong number of segments output and undefined memory access.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-09-02 11:38:36 +02:00
Gabriel Dume
4b1f5e5090 cosmetics: Write NULL pointer inequality checks more compactly
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2014-08-15 05:34:13 -07:00
Michael Niedermayer
66ae994c54 avformat/segment: re-interleave packets if needed
Fixes part of Ticket 3797

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-24 23:22:33 +02:00
Michael Niedermayer
351b22caae avformat/mux: support re-interleaving packets in ff_write_chained()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-24 22:39:22 +02:00
Stefano Sabatini
44071b0d25 lavf/segment: sanitize segment end time in case last packet do not have a defined duration
In particular, avoids to set segments with duration set to 0
(e.g. segment with a single reference frame for which duration is
undefined).
2014-07-22 13:53:31 +02:00
Stefano Sabatini
713157484a lavf/segment: do not allow to create segments with no key-frames
Fix trac ticket #3749.
2014-07-22 13:43:06 +02:00
Stefano Sabatini
526bd7bdfa lavf/segment: set segment end time when the first packet arrives
Avoid negative durations in case there is a single packet in the current
segment, since in that case the end time is still set to the previous
segment end time.
2014-07-17 16:51:51 +02:00
Stefano Sabatini
3d38c99041 lavf/segment: fix weird indent 2014-07-17 16:51:51 +02:00
Stefano Sabatini
b6a8c5245f lavf/segment: show incoming packet duration in debug message 2014-07-17 16:51:51 +02:00
Stefano Sabatini
5acad50056 lavf/segment: only use reference frames for computing the segment end time
This avoids a systematic overestimate of the segments duration when there
are several streams.

Fix trac ticket #3724.
2014-07-17 16:51:50 +02:00
Simon Thelen
fa6716c66d libavformat/segment: change segment_list_size behavior to match hls_list_size behavior.
Make the segment muxer keep segment_list_size segments instead of
segment_list_size + 1 segments. This patch also changes the
documentation for segment_list_size to reduce possible confusion over
how many segments are kept.

this allows the segment list to
be limited to containing only one segment which used to be impossible
because a segment_list_size of 0 kept all the segments and a
segment_list_size of 1 kept 2 segments.

Signed-off-by: Simon Thelen <ffmpeg-dev@c-14.de>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-17 02:35:56 +02:00
Michael Niedermayer
7125b6ca90 avformat/segment: remove gettimeofday() use, remove sys/time.h
It causes portability issues, and would need ifdef hell if its kept

Found-by: jamrial
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-08 22:52:39 +02:00