diff options
Diffstat (limited to 'libmpdemux/muxer_lavf.c')
-rw-r--r-- | libmpdemux/muxer_lavf.c | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/libmpdemux/muxer_lavf.c b/libmpdemux/muxer_lavf.c index f1cd641d13..12410f542e 100644 --- a/libmpdemux/muxer_lavf.c +++ b/libmpdemux/muxer_lavf.c @@ -10,6 +10,7 @@ #include "aviheader.h" #include "ms_hdr.h" +#include "av_opts.h" #include "stream/stream.h" #include "muxer.h" @@ -50,6 +51,7 @@ static int mux_rate= 0; static int mux_packet_size= 0; static float mux_preload= 0.5; static float mux_max_delay= 0.7; +static char *mux_avopt = NULL; m_option_t lavfopts_conf[] = { {"format", &(conf_format), CONF_TYPE_STRING, 0, 0, 0, NULL}, @@ -57,12 +59,20 @@ m_option_t lavfopts_conf[] = { {"packetsize", &mux_packet_size, CONF_TYPE_INT, CONF_RANGE, 0, INT_MAX, NULL}, {"preload", &mux_preload, CONF_TYPE_FLOAT, CONF_RANGE, 0, INT_MAX, NULL}, {"delay", &mux_max_delay, CONF_TYPE_FLOAT, CONF_RANGE, 0, INT_MAX, NULL}, + {"o", &mux_avopt, CONF_TYPE_STRING, 0, 0, 0, NULL}, {NULL, NULL, 0, 0, 0, 0, NULL} }; +/* This should be transmitted to mp_open() through the filename when + * thread safety is needed but MPlayer == no threads and especially + * not multiple muxers being initialized at once so there is no + * point in the extra complexity, a static is simpler. */ +static muxer_t *priv_data; + static int mp_open(URLContext *h, const char *filename, int flags) { + h->priv_data= priv_data; return 0; } @@ -127,21 +137,21 @@ static muxer_stream_t* lavf_new_stream(muxer_t *muxer, int type) if(!muxer || (type != MUXER_TYPE_VIDEO && type != MUXER_TYPE_AUDIO)) { - mp_msg(MSGT_MUXER, MSGL_ERR, "UNKNOW TYPE %d\n", type); + mp_msg(MSGT_MUXER, MSGL_ERR, "UNKNOWN TYPE %d\n", type); return NULL; } stream = calloc(1, sizeof(muxer_stream_t)); if(!stream) { - mp_msg(MSGT_MUXER, MSGL_ERR, "Could not alloc muxer_stream, EXIT\n"); + mp_msg(MSGT_MUXER, MSGL_ERR, "Could not allocate muxer_stream, EXIT.\n"); return NULL; } muxer->streams[muxer->avih.dwStreams] = stream; stream->b_buffer = malloc(2048); if(!stream->b_buffer) { - mp_msg(MSGT_MUXER, MSGL_ERR, "Could not alloc b_buffer, EXIT\n"); + mp_msg(MSGT_MUXER, MSGL_ERR, "Could not allocate b_buffer, EXIT.\n"); free(stream); return NULL; } @@ -160,7 +170,7 @@ static muxer_stream_t* lavf_new_stream(muxer_t *muxer, int type) spriv->avstream = av_new_stream(priv->oc, 1); if(!spriv->avstream) { - mp_msg(MSGT_MUXER, MSGL_ERR, "Could not alloc avstream, EXIT\n"); + mp_msg(MSGT_MUXER, MSGL_ERR, "Could not allocate avstream, EXIT.\n"); return NULL; } spriv->avstream->stream_copy = 1; @@ -223,7 +233,7 @@ static void fix_parameters(muxer_stream_t *stream) memcpy(ctx->extradata, stream->wf+1, ctx->extradata_size); } else - mp_msg(MSGT_MUXER, MSGL_ERR, "MUXER_LAVF(audio stream) error! couldn't allocate %d bytes for extradata\n", + mp_msg(MSGT_MUXER, MSGL_ERR, "MUXER_LAVF(audio stream) error! Could not allocate %d bytes for extradata.\n", stream->wf->cbSize); } } @@ -248,7 +258,7 @@ static void fix_parameters(muxer_stream_t *stream) memcpy(ctx->extradata, stream->bih+1, ctx->extradata_size); else { - mp_msg(MSGT_MUXER, MSGL_ERR, "MUXER_LAVF(video stream) error! couldn't allocate %d bytes for extradata\n", + mp_msg(MSGT_MUXER, MSGL_ERR, "MUXER_LAVF(video stream) error! Could not allocate %d bytes for extradata.\n", ctx->extradata_size); ctx->extradata_size = 0; } @@ -281,7 +291,7 @@ static void write_chunk(muxer_stream_t *stream, size_t len, unsigned int flags, if(av_interleaved_write_frame(priv->oc, &pkt) != 0) //av_write_frame(priv->oc, &pkt) { - mp_msg(MSGT_MUXER, MSGL_ERR, "Error while writing frame\n"); + mp_msg(MSGT_MUXER, MSGL_ERR, "Error while writing frame.\n"); } } @@ -340,7 +350,7 @@ int muxer_init_muxer_lavf(muxer_t *muxer) mp_msg(MSGT_MUXER, MSGL_WARN, "** MUXER_LAVF *****************************************************************\n"); mp_msg(MSGT_MUXER, MSGL_WARN, "REMEMBER: MEncoder's libavformat muxing is presently broken and can generate\n" -"INCORRECT files in the presence of B frames. Moreover, due to bugs MPlayer\n" +"INCORRECT files in the presence of B-frames. Moreover, due to bugs MPlayer\n" "will play these INCORRECT files as if nothing were wrong!\n" "*******************************************************************************\n"); @@ -351,7 +361,7 @@ int muxer_init_muxer_lavf(muxer_t *muxer) priv->oc = av_alloc_format_context(); if(!priv->oc) { - mp_msg(MSGT_MUXER, MSGL_FATAL, "Couldn't get format context\n"); + mp_msg(MSGT_MUXER, MSGL_FATAL, "Could not get format context.\n"); goto fail; } @@ -361,7 +371,7 @@ int muxer_init_muxer_lavf(muxer_t *muxer) fmt = guess_format(NULL, out_filename, NULL); if(! fmt) { - mp_msg(MSGT_MUXER, MSGL_FATAL, "CAN'T GET SPECIFIED FORMAT\n"); + mp_msg(MSGT_MUXER, MSGL_FATAL, "Cannot get specified format.\n"); goto fail; } priv->oc->oformat = fmt; @@ -369,7 +379,7 @@ int muxer_init_muxer_lavf(muxer_t *muxer) if(av_set_parameters(priv->oc, NULL) < 0) { - mp_msg(MSGT_MUXER, MSGL_FATAL, "Invalid output format parameters\n"); + mp_msg(MSGT_MUXER, MSGL_FATAL, "invalid output format parameters\n"); goto fail; } priv->oc->packet_size= mux_packet_size; @@ -386,23 +396,30 @@ int muxer_init_muxer_lavf(muxer_t *muxer) av_strlcpy(priv->oc->copyright, info_copyright, sizeof(priv->oc->copyright)); if (info_comment) av_strlcpy(priv->oc->comment , info_comment, sizeof(priv->oc->comment )); + + if(mux_avopt){ + if(parse_avopts(priv->oc, mux_avopt) < 0){ + mp_msg(MSGT_MUXER,MSGL_ERR, "Your options /%s/ look like gibberish to me pal.\n", mux_avopt); + goto fail; + } + } + register_protocol(&mp_protocol); + priv_data= muxer; if(url_fopen(&priv->oc->pb, mp_filename, URL_WRONLY)) { - mp_msg(MSGT_MUXER, MSGL_FATAL, "Could not open outfile\n"); + mp_msg(MSGT_MUXER, MSGL_FATAL, "Could not open outfile.\n"); goto fail; } - ((URLContext*)(priv->oc->pb->opaque))->priv_data= muxer; - muxer->priv = (void *) priv; muxer->cont_new_stream = &lavf_new_stream; muxer->cont_write_chunk = &write_chunk; muxer->cont_write_header = &write_header; muxer->cont_write_index = &write_trailer; muxer->fix_stream_parameters = &fix_parameters; - mp_msg(MSGT_MUXER, MSGL_INFO, "OK, exit\n"); + mp_msg(MSGT_MUXER, MSGL_INFO, "OK, exit.\n"); return 1; fail: |