46 #define BUFFER_DURATION 0
48 #define MAX_HEADER_SIZE (7 + 4 + 12)
50 #define MAX_PACKET_SIZE (UINT16_MAX - MAX_HEADER_SIZE)
70 int data_size,
int index_pos)
75 unsigned char *data_offset_ptr, *start_ptr;
76 const char *desc, *mimetype;
77 int nb_packets, packet_total_size, packet_max_size,
size, packet_avg_size, i;
93 packet_total_size = 0;
113 packet_avg_size = packet_total_size / nb_packets;
122 data_offset_ptr =
s->buf_ptr;
145 for(i=0;i<ctx->nb_streams;i++) {
148 stream = &rm->streams[i];
151 desc =
"The Audio Stream";
152 mimetype =
"audio/x-pn-realaudio";
153 codec_data_size = 73;
155 desc =
"The Video Stream";
156 mimetype =
"video/x-pn-realvideo";
157 codec_data_size = 34;
161 size = 10 + 9 * 4 + strlen(desc) + strlen(mimetype) + codec_data_size;
169 if (stream->nb_packets > 0)
170 packet_avg_size = stream->packet_total_size /
178 if (!
s->seekable || !stream->total_frames)
188 sample_rate = stream->enc->sample_rate;
189 coded_frame_size = (stream->enc->bit_rate *
190 stream->enc->frame_size) / (8 * sample_rate);
200 switch(sample_rate) {
220 if (coded_frame_size == 557)
234 if (stream->enc->codec_tag) {
255 avio_wb16(
s, stream->frame_rate.num / stream->frame_rate.den);
257 avio_wb16(
s, stream->frame_rate.num / stream->frame_rate.den);
272 data_pos =
s->buf_ptr - start_ptr;
273 rm->data_pos = data_pos;
274 data_offset_ptr[0] = data_pos >> 24;
275 data_offset_ptr[1] = data_pos >> 16;
276 data_offset_ptr[2] = data_pos >> 8;
277 data_offset_ptr[3] = data_pos;
290 int length,
int key_frame)
317 av_log(s,
AV_LOG_ERROR,
"At most 2 streams are currently supported for muxing in RM\n");
372 for (i = 0; i <
size; i += 2) {
396 av_log(s,
AV_LOG_ERROR,
"Muxing packets larger than 64 kB (%d) is not supported\n", size);
421 avio_wb16(pb, 0x4000 + packet_number * 126);
443 int data_size, index_pos, i;
449 data_size = index_pos - rm->
data_pos;
474 .mime_type =
"application/vnd.rn-realmedia",
475 .extensions =
"rm,ra",
static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int flags)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
unsigned char * buf_ptr
Current position in the buffer.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
void avio_wl32(AVIOContext *s, unsigned int val)
int id
Format-specific stream ID.
AVStream ** streams
A list of all streams in the file.
static void put_str(AVIOContext *s, const char *tag)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static void put_str8(AVIOContext *s, const char *tag)
StreamInfo * audio_stream
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int flags
A combination of AV_PKT_FLAG values.
AVCodecContext * codec
Codec context associated with this stream.
static void write_packet_header(AVFormatContext *ctx, StreamInfo *stream, int length, int key_frame)
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, enum AVRounding rnd)
Rescale a 64-bit integer by 2 rational numbers with specified rounding.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int bit_rate
the average bitrate
int void avio_flush(AVIOContext *s)
Force flushing of buffered data.
static int write_trailer(AVFormatContext *s1)
static int rm_write_header(AVFormatContext *s)
static int rm_write_packet(AVFormatContext *s, AVPacket *pkt)
#define FF_ARRAY_ELEMS(a)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int frame_size
Number of samples per channel in an audio frame.
const AVCodecTag ff_rm_codec_tags[]
enum AVMediaType codec_type
int sample_rate
samples per second
AVIOContext * pb
I/O context.
void avio_w8(AVIOContext *s, int b)
main external API structure.
rational number numerator/denominator
static int rm_write_trailer(AVFormatContext *s)
void avio_wb16(AVIOContext *s, unsigned int val)
const char *const ff_rm_metadata[4]
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
AVOutputFormat ff_rm_muxer
static int rv10_write_header(AVFormatContext *ctx, int data_size, int index_pos)
void * priv_data
Format private data.
static void write_header(FFV1Context *f)
void avio_wb32(AVIOContext *s, unsigned int val)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size, int flags)
This structure stores compressed data.
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
StreamInfo * video_stream