av_dict_copy(&copts, ffmpeg->opts, 0);
int ret = 0;
// this should be avformat_copy_context(), but no copy avail
- ret = avformat_open_input(&fmt_ctx, ffmpeg->fmt_ctx->filename, NULL, &copts);
+ ret = avformat_open_input(&fmt_ctx,
+ ffmpeg->fmt_ctx->url, ffmpeg->fmt_ctx->iformat, &copts);
if( ret >= 0 ) {
ret = avformat_find_stream_info(fmt_ctx, 0);
st = fmt_ctx->streams[fidx];
ret = AVERROR(ENOMEM);
}
if( ret >= 0 ) {
- av_codec_set_pkt_timebase(avctx, st->time_base);
- if( decoder->capabilities & AV_CODEC_CAP_DR1 )
- avctx->flags |= CODEC_FLAG_EMU_EDGE;
avcodec_parameters_to_context(avctx, st->codecpar);
if( !av_dict_get(copts, "threads", NULL, 0) )
avctx->thread_count = ffmpeg->ff_cpus();
ff_err(ret, "FFAudioStream::decode_frame: Could not read audio frame\n");
return -1;
}
- int64_t pkt_ts = av_frame_get_best_effort_timestamp(frame);
+ int64_t pkt_ts = frame->best_effort_timestamp;
if( pkt_ts != AV_NOPTS_VALUE )
curr_pos = ffmpeg->to_secs(pkt_ts - nudge, st->time_base) * sample_rate + 0.5;
return 1;
{
if( writing >= 0 ) return writing;
if( !avctx->codec ) return writing = 0;
- frame_sz = avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE ?
+ frame_sz = avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE ?
10000 : avctx->frame_size;
return FFStream::encode_activate();
}
ff_err(ret, "FFVideoStream::decode_frame: Could not read video frame\n");
return -1;
}
- int64_t pkt_ts = av_frame_get_best_effort_timestamp(frame);
+ int64_t pkt_ts = frame->best_effort_timestamp;
if( pkt_ts != AV_NOPTS_VALUE )
curr_pos = ffmpeg->to_secs(pkt_ts - nudge, st->time_base) * frame_rate + 0.5;
return 1;
{
int ret = convert_cmodel(frame, ifp);
if( ret > 0 ) {
- const AVDictionary *src = av_frame_get_metadata(ifp);
+ const AVDictionary *src = ifp->metadata;
AVDictionaryEntry *t = NULL;
BC_Hash *hp = frame->get_params();
//hp->clear();
int ret = convert_pixfmt(frame, ofp);
if( ret > 0 ) {
BC_Hash *hp = frame->get_params();
- AVDictionary **dict = avpriv_frame_get_metadatap(ofp);
+ AVDictionary **dict = &ofp->metadata;
//av_dict_free(dict);
for( int i=0; i<hp->size(); ++i ) {
char *key = hp->get_key(i), *val = hp->get_value(i);
int FFMPEG::init_decoder(const char *filename)
{
ff_lock("FFMPEG::init_decoder");
- av_register_all();
char file_opts[BCTEXTLEN];
char *bp = strrchr(strcpy(file_opts, filename), '/');
char *sp = strrchr(!bp ? file_opts : bp, '.');
+ if( !sp ) sp = bp + strlen(bp);
FILE *fp = 0;
+ AVInputFormat *ifmt = 0;
if( sp ) {
strcpy(sp, ".opts");
fp = fopen(file_opts, "r");
if( fp ) {
read_options(fp, file_opts, opts);
fclose(fp);
+ AVDictionaryEntry *tag;
+ if( (tag=av_dict_get(opts, "format", NULL, 0)) != 0 ) {
+ ifmt = av_find_input_format(tag->value);
+ }
}
else
load_options("decode.opts", opts);
AVDictionary *fopts = 0;
av_dict_copy(&fopts, opts, 0);
- int ret = avformat_open_input(&fmt_ctx, filename, NULL, &fopts);
+ int ret = avformat_open_input(&fmt_ctx, filename, ifmt, &fopts);
av_dict_free(&fopts);
if( ret >= 0 )
ret = avformat_find_stream_info(fmt_ctx, NULL);
int FFMPEG::open_decoder()
{
struct stat st;
- if( stat(fmt_ctx->filename, &st) < 0 ) {
- eprintf(_("can't stat file: %s\n"), fmt_ctx->filename);
+ if( stat(fmt_ctx->url, &st) < 0 ) {
+ eprintf(_("can't stat file: %s\n"), fmt_ctx->url);
return 1;
}
return 1;
}
ff_lock("FFMPEG::init_encoder");
- av_register_all();
char format[BCSTRLEN];
if( get_format(format, "format", file_format) )
strcpy(format, file_format);
ctx->qmin = ctx->qmax = asset->ff_audio_quality;
ctx->mb_lmin = ctx->qmin * FF_QP2LAMBDA;
ctx->mb_lmax = ctx->qmax * FF_QP2LAMBDA;
- ctx->flags |= CODEC_FLAG_QSCALE;
+ ctx->flags |= AV_CODEC_FLAG_QSCALE;
char arg[BCSTRLEN];
av_dict_set(&sopts, "flags", "+qscale", 0);
sprintf(arg, "%d", asset->ff_audio_quality);
ctx->qmin = ctx->qmax = asset->ff_video_quality;
ctx->mb_lmin = ctx->qmin * FF_QP2LAMBDA;
ctx->mb_lmax = ctx->qmax * FF_QP2LAMBDA;
- ctx->flags |= CODEC_FLAG_QSCALE;
+ ctx->flags |= AV_CODEC_FLAG_QSCALE;
char arg[BCSTRLEN];
av_dict_set(&sopts, "flags", "+qscale", 0);
sprintf(arg, "%d", asset->ff_video_quality);
}
if( !ret ) {
if( fmt_ctx->oformat->flags & AVFMT_GLOBALHEADER )
- ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
+ ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
if( fst->stats_filename && (ret=fst->init_stats_file()) )
eprintf(_("error: stats file = %s\n"), fst->stats_filename);
}
if( encoding < 0 ) {
encoding = 0;
if( !(fmt_ctx->flags & AVFMT_NOFILE) &&
- (ret=avio_open(&fmt_ctx->pb, fmt_ctx->filename, AVIO_FLAG_WRITE)) < 0 ) {
+ (ret=avio_open(&fmt_ctx->pb, fmt_ctx->url, AVIO_FLAG_WRITE)) < 0 ) {
ff_err(ret, "FFMPEG::encode_activate: err opening : %s\n",
- fmt_ctx->filename);
+ fmt_ctx->url);
return -1;
}
while( --pi >= 0 && fmt_ctx->programs[pi]->id != prog_id );
AVDictionary **meta = &prog->metadata;
av_dict_set(meta, "service_provider", "cin5", 0);
- const char *path = fmt_ctx->filename, *bp = strrchr(path,'/');
+ const char *path = fmt_ctx->url, *bp = strrchr(path,'/');
if( bp ) path = bp + 1;
av_dict_set(meta, "title", path, 0);
ret = avformat_write_header(fmt_ctx, &fopts);
if( ret < 0 ) {
ff_err(ret, "FFMPEG::encode_activate: write header failed %s\n",
- fmt_ctx->filename);
+ fmt_ctx->url);
return -1;
}
av_dict_free(&fopts);
int FFVideoStream::create_filter(const char *filter_spec, AVCodecParameters *avpar)
{
- avfilter_register_all();
const char *sp = filter_spec;
char filter_name[BCSTRLEN], *np = filter_name;
int i = sizeof(filter_name);
while( --i>=0 && *sp!=0 && !strchr(" \t:=,",*sp) ) *np++ = *sp++;
*np = 0;
- AVFilter *filter = !filter_name[0] ? 0 : avfilter_get_by_name(filter_name);
+ const AVFilter *filter = !filter_name[0] ? 0 : avfilter_get_by_name(filter_name);
if( !filter || avfilter_pad_get_type(filter->inputs,0) != AVMEDIA_TYPE_VIDEO ) {
ff_err(AVERROR(EINVAL), "FFVideoStream::create_filter: %s\n", filter_spec);
return -1;
}
filter_graph = avfilter_graph_alloc();
- AVFilter *buffersrc = avfilter_get_by_name("buffer");
- AVFilter *buffersink = avfilter_get_by_name("buffersink");
+ const AVFilter *buffersrc = avfilter_get_by_name("buffer");
+ const AVFilter *buffersink = avfilter_get_by_name("buffersink");
int ret = 0; char args[BCTEXTLEN];
AVPixelFormat pix_fmt = (AVPixelFormat)avpar->format;
int FFAudioStream::create_filter(const char *filter_spec, AVCodecParameters *avpar)
{
- avfilter_register_all();
const char *sp = filter_spec;
char filter_name[BCSTRLEN], *np = filter_name;
int i = sizeof(filter_name);
while( --i>=0 && *sp!=0 && !strchr(" \t:=,",*sp) ) *np++ = *sp++;
*np = 0;
- AVFilter *filter = !filter_name[0] ? 0 : avfilter_get_by_name(filter_name);
+ const AVFilter *filter = !filter_name[0] ? 0 : avfilter_get_by_name(filter_name);
if( !filter || avfilter_pad_get_type(filter->inputs,0) != AVMEDIA_TYPE_AUDIO ) {
ff_err(AVERROR(EINVAL), "FFAudioStream::create_filter: %s\n", filter_spec);
return -1;
}
filter_graph = avfilter_graph_alloc();
- AVFilter *buffersrc = avfilter_get_by_name("abuffer");
- AVFilter *buffersink = avfilter_get_by_name("abuffersink");
+ const AVFilter *buffersrc = avfilter_get_by_name("abuffer");
+ const AVFilter *buffersink = avfilter_get_by_name("abuffersink");
int ret = 0; char args[BCTEXTLEN];
AVSampleFormat sample_fmt = (AVSampleFormat)avpar->format;
snprintf(args, sizeof(args),