Muxers take encoded data in the form of AVPackets and write it into files or other output bytestreams in the specified container format. More...
Muxers take encoded data in the form of AVPackets and write it into files or other output bytestreams in the specified container format.
The main API functions for muxing are avformat_write_header() for writing the file header, av_write_frame() / av_interleaved_write_frame() for writing the packets and av_write_trailer() for finalizing the file.
At the beginning of the muxing process, the caller must first call avformat_alloc_context() to create a muxing context. The caller then sets up the muxer by filling the various fields in this context:
When the muxing context is fully set up, the caller must call avformat_write_header() to initialize the muxer internals and write the file header. Whether anything actually is written to the IO context at this step depends on the muxer, but this function must always be called. Any muxer private options must be passed in the options parameter to this function.
The data is then sent to the muxer by repeatedly calling av_write_frame() or av_interleaved_write_frame() (consult those functions' documentation for discussion on the difference between them; only one of them may be used with a single muxing context, they should not be mixed). Do note that the timing information on the packets sent to the muxer must be in the corresponding AVStream's timebase. That timebase is set by the muxer (in the avformat_write_header() step) and may be different from the timebase requested by the caller.
Once all the data has been written, the caller must call av_write_trailer() to flush any buffered packets and finalize the output file, then close the IO context (if any) and finally free the muxing context with avformat_free_context().
stream parameters initialized in avformat_write_header
Definition at line 2384 of file avformat.h.
stream parameters initialized in avformat_init_output
Definition at line 2385 of file avformat.h.
Allocate the stream private data and write the stream header to an output media file.
Definition at line 467 of file mux.c.
Referenced by create_rtp_muxer(), dash_write_header(), dec_enc(), ff_rtp_chain_mux_open(), fifo_basic_test(), fifo_overflow_drop_test(), fifo_thread_write_header(), hds_write_header(), hls_start(), hls_write_header(), init_fps(), ism_write_header(), main(), mov_write_ttml_document_from_queue(), mpegts_init(), mux_check_init(), open_output_file(), open_slave(), rtp_mpegts_write_header(), seg_init(), seg_write_header(), segment_start(), webm_chunk_write_header(), write_muxed_file(), and write_output_file_header().
Allocate the stream private data and initialize the codec, but do not write the header.
May optionally be used before avformat_write_header() to initialize stream parameters before actually writing the header. If using this function, do not pass the same options to avformat_write_header().
Definition at line 446 of file mux.c.
Referenced by avformat_write_header(), dash_init(), hls_mux_init(), seg_init(), and webm_chunk_init().
Write a packet to an output media file.
This function passes the packet directly to the muxer, without any buffering or reordering. The caller is responsible for correctly interleaving the packets if the format requires it. Callers that want libavformat to handle the interleaving should call av_interleaved_write_frame() instead of this function.
Definition at line 1176 of file mux.c.
Referenced by chunk_end(), dash_write_packet(), encode_audio_frame(), ff_write_chained(), fifo_basic_test(), fifo_overflow_drop_test(), fifo_thread_flush_output(), fifo_thread_write_packet(), flush_dynbuf(), hls_write_packet(), hls_write_trailer(), ism_flush(), main(), mov_write_ttml_document_from_queue(), mpegts_write_packet_internal(), mux_frames(), mux_id3(), rtp_mpegts_write_packet(), seg_write_header(), segment_end(), signal_init_ts(), webm_chunk_write_packet(), and write_uncoded_frame_internal().
Write a packet to an output media file ensuring correct interleaving.
This function will buffer the packets internally as needed to make sure the packets in the output file are properly interleaved, usually ordered by increasing dts. Callers doing their own interleaving should call av_write_frame() instead of this function.
Using this function instead of av_write_frame() can give muxers advance knowledge of future packets, improving e.g. the behaviour of the mp4 muxer for VFR content in fragmenting mode.
Definition at line 1223 of file mux.c.
Referenced by encode_write(), encode_write_frame(), ff_write_chained(), main(), mux_frames(), tee_write_packet(), write_frame(), write_muxed_file(), write_packet(), and write_uncoded_frame_internal().
Write an uncoded frame to an output media file.
The frame must be correctly interleaved according to the container specification; if not, av_interleaved_write_uncoded_frame() must be used.
See av_interleaved_write_uncoded_frame() for details.
Write an uncoded frame to an output media file.
If the muxer supports it, this function makes it possible to write an AVFrame structure directly, without encoding it into a packet. It is mostly useful for devices and similar special muxers that use raw video or PCM data and will not serialize it into a byte stream.
To test whether it is possible to use it with a given muxer and stream, use av_write_uncoded_frame_query().
The caller gives up ownership of the frame and must not access it afterwards.
Definition at line 1422 of file mux.c.
Referenced by main().
Write the stream trailer to an output media file and free the file private data.
May only be called after a successful call to avformat_write_header.
Definition at line 1238 of file mux.c.
Referenced by close_slave(), dash_flush(), ff_mov_close_hinting(), ff_rtsp_undo_setup(), fifo_basic_test(), fifo_overflow_drop_test(), fifo_thread_write_trailer(), finish(), hds_free(), hls_write_trailer(), main(), mov_write_ttml_document_from_queue(), of_write_trailer(), rtp_mpegts_write_close(), sap_write_close(), seg_write_trailer(), segment_end(), webm_chunk_write_trailer(), whip_deinit(), write_muxed_file(), and write_output_file_trailer().
Return the output format in the list of registered output formats which best matches the provided parameters, or return NULL if there is no match.
Definition at line 79 of file format.c.
Referenced by av_guess_codec(), avformat_alloc_output_context2(), create_rtp_muxer(), dash_init(), ff_rtp_chain_mux_open(), fifo_init(), hds_write_header(), hls_init(), init_fps(), ism_write_header(), mpegts_init(), open_output_file(), rtp_mpegts_write_header(), seg_init(), show_help_muxer(), and webm_chunk_init().
Guess the codec ID based upon muxer and filename.
Definition at line 117 of file format.c.
Referenced by choose_encoder(), map_auto_audio(), map_auto_data(), and map_auto_video().
Get timing information for the data currently output.
The exact meaning of "currently output" depends on the format. It is mostly relevant for devices that have an internal buffer and/or work in real time.