comparison libmpdemux/muxer_lavf.c @ 17480:3993a5fad89a

pass vbv_size & max_rate from encoder to muxer over muxer_stream_t (if this is wrong/silly/10000000l then dont hesitate to flame / reverse) make a few things like mux_rate, mux_max_delay, ... user settable fixed buffer underflow errors when muxing to mpeg-ps
author michael
date Wed, 25 Jan 2006 01:17:57 +0000
parents 92a9690cc3e2
children e6dc1aeaf8a5
comparison
equal deleted inserted replaced
17479:92a9690cc3e2 17480:3993a5fad89a
41 AVStream *avstream; 41 AVStream *avstream;
42 } muxer_stream_priv_t; 42 } muxer_stream_priv_t;
43 43
44 static char *conf_format = NULL; 44 static char *conf_format = NULL;
45 static int conf_allow_lavf = 0; 45 static int conf_allow_lavf = 0;
46 static int mux_rate= 0;
47 static int mux_packet_size= 0;
48 static float mux_preload= 0.5;
49 static float mux_max_delay= 0.7;
46 50
47 m_option_t lavfopts_conf[] = { 51 m_option_t lavfopts_conf[] = {
48 {"format", &(conf_format), CONF_TYPE_STRING, 0, 0, 0, NULL}, 52 {"format", &(conf_format), CONF_TYPE_STRING, 0, 0, 0, NULL},
49 {"i_certify_that_my_video_stream_does_not_use_b_frames", &conf_allow_lavf, CONF_TYPE_FLAG, 0, 0, 1, NULL}, 53 {"i_certify_that_my_video_stream_does_not_use_b_frames", &conf_allow_lavf, CONF_TYPE_FLAG, 0, 0, 1, NULL},
54 {"muxrate", &mux_rate, CONF_TYPE_INT, CONF_RANGE, 0, INT_MAX, NULL},
55 {"packetsize", &mux_packet_size, CONF_TYPE_INT, CONF_RANGE, 0, INT_MAX, NULL},
56 {"preload", &mux_preload, CONF_TYPE_FLOAT, CONF_RANGE, 0, INT_MAX, NULL},
57 {"delay", &mux_max_delay, CONF_TYPE_FLOAT, CONF_RANGE, 0, INT_MAX, NULL},
58
50 {NULL, NULL, 0, 0, 0, 0, NULL} 59 {NULL, NULL, 0, 0, 0, 0, NULL}
51 }; 60 };
52 61
53 static int mp_open(URLContext *h, const char *filename, int flags) 62 static int mp_open(URLContext *h, const char *filename, int flags)
54 { 63 {
171 ctx = spriv->avstream->codec; 180 ctx = spriv->avstream->codec;
172 #else 181 #else
173 ctx = &(spriv->avstream->codec); 182 ctx = &(spriv->avstream->codec);
174 #endif 183 #endif
175 184
185 if(stream->wf && stream->wf->nAvgBytesPerSec)
186 ctx->bit_rate = stream->wf->nAvgBytesPerSec * 8;
187 ctx->rc_buffer_size= stream->vbv_size;
188 ctx->rc_max_rate= stream->max_rate;
189
176 if(stream->type == MUXER_TYPE_AUDIO) 190 if(stream->type == MUXER_TYPE_AUDIO)
177 { 191 {
178 ctx->codec_id = codec_get_wav_id(stream->wf->wFormatTag); 192 ctx->codec_id = codec_get_wav_id(stream->wf->wFormatTag);
179 ctx->codec_tag = codec_get_wav_tag(ctx->codec_id); 193 ctx->codec_tag = codec_get_wav_tag(ctx->codec_id);
180 mp_msg(MSGT_MUXER, MSGL_INFO, "AUDIO CODEC ID: %x, TAG: %x\n", ctx->codec_id, (uint32_t) ctx->codec_tag); 194 mp_msg(MSGT_MUXER, MSGL_INFO, "AUDIO CODEC ID: %x, TAG: %x\n", ctx->codec_id, (uint32_t) ctx->codec_tag);
181 ctx->bit_rate = stream->wf->nAvgBytesPerSec * 8;
182 ctx->sample_rate = stream->wf->nSamplesPerSec; 195 ctx->sample_rate = stream->wf->nSamplesPerSec;
183 // mp_msg(MSGT_MUXER, MSGL_INFO, "stream->h.dwSampleSize: %d\n", stream->h.dwSampleSize); 196 // mp_msg(MSGT_MUXER, MSGL_INFO, "stream->h.dwSampleSize: %d\n", stream->h.dwSampleSize);
184 ctx->channels = stream->wf->nChannels; 197 ctx->channels = stream->wf->nChannels;
185 if(stream->h.dwRate && (stream->h.dwScale * (int64_t)ctx->sample_rate) % stream->h.dwRate == 0) 198 if(stream->h.dwRate && (stream->h.dwScale * (int64_t)ctx->sample_rate) % stream->h.dwRate == 0)
186 ctx->frame_size= (stream->h.dwScale * (int64_t)ctx->sample_rate) / stream->h.dwRate; 199 ctx->frame_size= (stream->h.dwScale * (int64_t)ctx->sample_rate) / stream->h.dwRate;
351 if(av_set_parameters(priv->oc, NULL) < 0) 364 if(av_set_parameters(priv->oc, NULL) < 0)
352 { 365 {
353 mp_msg(MSGT_MUXER, MSGL_FATAL, "Invalid output format parameters\n"); 366 mp_msg(MSGT_MUXER, MSGL_FATAL, "Invalid output format parameters\n");
354 goto fail; 367 goto fail;
355 } 368 }
356 369 priv->oc->packet_size= mux_packet_size;
370 priv->oc->mux_rate= mux_rate;
371 priv->oc->preload= (int)(mux_preload*AV_TIME_BASE);
372 priv->oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE);
373
357 register_protocol(&mp_protocol); 374 register_protocol(&mp_protocol);
358 375
359 if(url_fopen(&priv->oc->pb, mp_filename, URL_WRONLY)) 376 if(url_fopen(&priv->oc->pb, mp_filename, URL_WRONLY))
360 { 377 {
361 mp_msg(MSGT_MUXER, MSGL_FATAL, "Coulnd't open outfile\n"); 378 mp_msg(MSGT_MUXER, MSGL_FATAL, "Coulnd't open outfile\n");