FFmpeg: libavformat/webm_chunk.c Source File
Go to the documentation of this file. 1 /*
2 * Copyright (c) 2015, Vignesh Venkatasubramanian
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file WebM Chunk Muxer
23 * The chunk muxer enables writing WebM Live chunks where there is a header
24 * chunk, followed by data chunks where each Cluster is written out as a Chunk.
25 */
26
32
36
37 #define MAX_FILENAME_SIZE 1024
38
50
52 {
59
60 // DASH Streams can only have one track per file.
61 if (
s->nb_streams != 1)
63
67 }
68
70
72 if (!oformat)
74
79
82
88
90
93
95 if (!st)
97
106
112
118
119 // Copy the timing info back to the original stream
120 // so that the timestamps of the packets are directly usable
123
124 // This ensures that the timestamps will already be properly shifted
125 // when the packets arrive here, so we don't need to shift again.
131
132 return 0;
133 }
134
136 {
138 if (!filename) {
140 }
145 }
146 return 0;
147 }
148
150 {
155
163 return 0;
164 }
165
167 {
171
176 return 0;
177 }
178
180 {
184 int buffer_size;
189
191 return 0;
192
194 // Flush the cluster in WebM muxer.
212 return (
ret < 0) ?
ret : 0;
213 }
214
216 {
221
228 }
229
230 // For video, a new chunk is started only on key frames. For audio, a new
231 // chunk is started based on chunk_duration. Also, a new chunk is started
232 // unconditionally if there is no currently open chunk.
240 }
241 }
242
243 // We only have one stream, so use the non-interleaving av_write_frame.
245 }
246
248 {
252
257 }
262 }
263
265 {
267
269 return;
270
273 else
277 }
278
279 #define OFFSET(x) offsetof(WebMChunkContext, x)
286 };
287
293 };
294
296 .
p.
name =
"webm_chunk",
298 .p.mime_type = "video/webm",
299 .p.extensions = "chk",
309 };
static const AVClass webm_chunk_class
static int chunk_start(AVFormatContext *s)
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVMediaType codec_type
General type of the encoded data.
static int webm_chunk_write_header(AVFormatContext *s)
AVStream ** streams
A list of all streams in the file.
static void deinit(AVFormatContext *s)
int strict_std_compliance
Allow non-standard and experimental extension.
const FFOutputFormat ff_webm_chunk_muxer
av_warn_unused_result int avformat_init_output(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and initialize the codec, but do not write the header.
int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
static int get_chunk_filename(AVFormatContext *s, char filename[MAX_FILENAME_SIZE])
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
static int webm_chunk_write_trailer(AVFormatContext *s)
int flush_packets
Flush the I/O context after each packet.
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
static int chunk_end(AVFormatContext *s, int flush)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
enum FFFormatContext::@317 avoid_negative_ts_status
Whether the timestamp shift offset has already been determined.
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
int flags
Flags modifying the (de)muxer behaviour.
#define AVIO_FLAG_WRITE
write-only
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static int webm_chunk_write_packet(AVFormatContext *s, AVPacket *pkt)
av_warn_unused_result int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
static int write_trailer(AVFormatContext *s1)
Rational number (pair of numerator and denominator).
const char * av_default_item_name(void *ptr)
Return the context name.
AVIOContext * pb
I/O context.
void(* flush)(AVBSFContext *ctx)
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
#define AV_OPT_FLAG_ENCODING_PARAM
A generic parameter which can be set by the user for muxing or encoding.
static int webm_chunk_init(AVFormatContext *s)
static const AVOption options[]
int(* init)(AVBSFContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
char * url
input or output URL.
#define AV_NOPTS_VALUE
Undefined timestamp value.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
int flags
A combination of AV_PKT_FLAG values.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AVERROR_MUXER_NOT_FOUND
Muxer not found.
int avoid_negative_ts
Avoid negative timestamps during muxing.
static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set() that converts the value to a string and stores it.
static void webm_chunk_deinit(AVFormatContext *s)
const AVOutputFormat * av_guess_format(const char *short_name, const char *filename, const char *mime_type)
Return the output format in the list of registered output formats which best matches the provided par...
#define MAX_FILENAME_SIZE
This structure stores compressed data.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
static void write_header(FFV1Context *f)
int pts_wrap_bits
Number of bits in timestamps.
int64_t lowest_ts_allowed
This is the lowest ts allowed in this track; it may be set by the muxer during init or write_header a...
uint64_t duration_written
int avoid_negative_ts_use_pts
Generated on Thu Sep 26 2024 23:15:53 for FFmpeg by
doxygen
1.8.17