コード例 #1
0
EXPORT void *init_bitstream(const char*in, const char *out)
{
	// structure with ffmpeg variables
	struct liveStream *ctx = NULL;
	struct inputCfg cfg = { IN_STREAM, 0};
	//Used for error checking
	int ret = 0;


	// allocation of Live Stream structure
	ctx = malloc(sizeof(struct liveStream));
	if(ctx == NULL)
	{
		fprintf(stderr,"Error in web play struct alloc\n");
		return NULL;
	}
	memset(ctx, 0, sizeof(*ctx));

	init_ffmpeg();

	ret = configure_input(ctx, in, &cfg);
	if (ret < 0)
	{
		ret = -1;
		fprintf(stderr, "Error while configuring Input %s\n",in);
	}

	ctx->have_filter = 0;

	ctx->video_avg_frame_rate.num = 30;
	ctx->video_avg_frame_rate.den = 1;

	ret = init_muxer(ctx, out);
	if(ret < 0)
	{
		printf("Error in muxer init for %s\n", out);
		ret =-1;
		goto end;
	}

end:
	if(ret < 0)
	{
		stop_bitstream((void*)ctx);
		return NULL;
	}
	return ctx;


}
コード例 #2
0
ファイル: mux.c プロジェクト: Justin790126/libav
int avformat_write_header(AVFormatContext *s, AVDictionary **options)
{
    int ret = 0;

    if (ret = init_muxer(s, options))
        return ret;

    if (s->oformat->write_header) {
        ret = s->oformat->write_header(s);
        if (ret < 0)
            return ret;
    }

    if (s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO) {
        if (s->oformat->flags & (AVFMT_TS_NEGATIVE | AVFMT_NOTIMESTAMPS)) {
            s->avoid_negative_ts = 0;
        } else
            s->avoid_negative_ts = AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE;
    }

    return 0;
}