#define MAX_FILES 20
+static char *last_asked_format = NULL;
static AVFormatContext *input_files[MAX_FILES];
static int64_t input_files_ts_offset[MAX_FILES];
static double input_files_ts_scale[MAX_FILES][MAX_STREAMS];
static AVMetaDataMap meta_data_maps[MAX_FILES];
static int nb_meta_data_maps;
-static AVInputFormat *file_iformat;
-static AVOutputFormat *file_oformat;
static int frame_width = 0;
static int frame_height = 0;
static float frame_aspect_ratio = 0;
st = av_mallocz(sizeof(AVStream));
memcpy(st, ic->streams[i], sizeof(AVStream));
st->codec = avcodec_alloc_context();
+ if (!st->codec) {
+ print_error(filename, AVERROR(ENOMEM));
+ av_exit(1);
+ }
memcpy(st->codec, ic->streams[i]->codec, sizeof(AVCodecContext));
s->streams[i] = st;
AVSubtitle subtitle, *subtitle_to_free;
int got_subtitle;
AVPacket avpkt;
+ int bps = av_get_bits_per_sample_format(ist->st->codec->sample_fmt)>>3;
if(ist->next_pts == AV_NOPTS_VALUE)
ist->next_pts= ist->pts;
handle_eof:
ist->pts= ist->next_pts;
- if(avpkt.size && avpkt.size != pkt->size && verbose>0)
+ if(avpkt.size && avpkt.size != pkt->size &&
+ !(ist->st->codec->codec->capabilities & CODEC_CAP_SUBFRAMES) && verbose>0)
fprintf(stderr, "Multiple frames in a packet from stream %d\n", pkt->stream_index);
/* decode the packet if needed */
continue;
}
data_buf = (uint8_t *)samples;
- ist->next_pts += ((int64_t)AV_TIME_BASE/2 * data_size) /
+ ist->next_pts += ((int64_t)AV_TIME_BASE/bps * data_size) /
(ist->st->codec->sample_rate * ist->st->codec->channels);
break;}
case CODEC_TYPE_VIDEO:
fprintf(stderr, "pgmyuv format is deprecated, use image2\n");
}
- file_iformat = av_find_input_format(arg);
- file_oformat = guess_format(arg, NULL, NULL);
- if (!file_iformat && !file_oformat) {
- fprintf(stderr, "Unknown input or output format: %s\n", arg);
- av_exit(1);
- }
+ last_asked_format = arg;
}
static void opt_video_rc_override_string(const char *arg)
{
AVFormatContext *ic;
AVFormatParameters params, *ap = ¶ms;
+ AVInputFormat *file_iformat = NULL;
int err, i, ret, rfps, rfps_base;
int64_t timestamp;
+ if (last_asked_format) {
+ file_iformat = av_find_input_format(last_asked_format);
+ last_asked_format = NULL;
+ }
+
if (!strcmp(filename, "-"))
filename = "pipe:";
/* get default parameters from command line */
ic = avformat_alloc_context();
+ if (!ic) {
+ print_error(filename, AVERROR(ENOMEM));
+ av_exit(1);
+ }
memset(ap, 0, sizeof(*ap));
ap->prealloced_context = 1;
dump_format(ic, nb_input_files, filename, 0);
nb_input_files++;
- file_iformat = NULL;
- file_oformat = NULL;
video_channel = 0;
int use_video, use_audio, use_subtitle;
int input_has_video, input_has_audio, input_has_subtitle;
AVFormatParameters params, *ap = ¶ms;
+ AVOutputFormat *file_oformat;
if (!strcmp(filename, "-"))
filename = "pipe:";
oc = avformat_alloc_context();
+ if (!oc) {
+ print_error(filename, AVERROR(ENOMEM));
+ av_exit(1);
+ }
- if (!file_oformat) {
+ if (last_asked_format) {
+ file_oformat = guess_format(last_asked_format, NULL, NULL);
+ if (!file_oformat) {
+ fprintf(stderr, "Requested output format '%s' is not a suitable output format\n", last_asked_format);
+ av_exit(1);
+ }
+ last_asked_format = NULL;
+ } else {
file_oformat = guess_format(NULL, filename, NULL);
if (!file_oformat) {
fprintf(stderr, "Unable to find a suitable output format for '%s'\n",
oc->flags |= AVFMT_FLAG_NONBLOCK;
set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM);
-
- /* reset some options */
- file_oformat = NULL;
- file_iformat = NULL;
}
/* same option as mencoder */
FFMPEG_DATADIR,
};
- for(i=!base[0]; i<2 && !f; i++){
- snprintf(filename, sizeof(filename), "%s%s/%s.ffpreset", base[i], i ? "" : "/.ffmpeg", arg);
- f= fopen(filename, "r");
- if(!f){
- char *codec_name= *opt == 'v' ? video_codec_name :
- *opt == 'a' ? audio_codec_name :
- subtitle_codec_name;
- snprintf(filename, sizeof(filename), "%s%s/%s-%s.ffpreset", base[i], i ? "" : "/.ffmpeg", codec_name, arg);
+ if (*opt != 'f') {
+ for(i=!base[0]; i<2 && !f; i++){
+ snprintf(filename, sizeof(filename), "%s%s/%s.ffpreset", base[i], i ? "" : "/.ffmpeg", arg);
f= fopen(filename, "r");
+ if(!f){
+ char *codec_name= *opt == 'v' ? video_codec_name :
+ *opt == 'a' ? audio_codec_name :
+ subtitle_codec_name;
+ snprintf(filename, sizeof(filename), "%s%s/%s-%s.ffpreset", base[i], i ? "" : "/.ffmpeg", codec_name, arg);
+ f= fopen(filename, "r");
+ }
}
- }
- if(!f && ((arg[0]=='.' && arg[1]=='/') || arg[0]=='/' ||
- is_dos_path(arg))){
+ } else {
av_strlcpy(filename, arg, sizeof(filename));
f= fopen(filename, "r");
}
{ "L", OPT_EXIT, {(void*)show_license}, "show license" },
{ "h", OPT_EXIT, {(void*)show_help}, "show help" },
{ "version", OPT_EXIT, {(void*)show_version}, "show version" },
- { "formats", OPT_EXIT, {(void*)show_formats}, "show available formats, codecs, protocols, ..." },
+ { "formats" , OPT_EXIT, {(void*)show_formats }, "show available formats" },
+ { "codecs" , OPT_EXIT, {(void*)show_codecs }, "show available codecs" },
+ { "bsfs" , OPT_EXIT, {(void*)show_bsfs }, "show available bit stream filters" },
+ { "protocols", OPT_EXIT, {(void*)show_protocols}, "show available protocols" },
{ "f", HAS_ARG, {(void*)opt_format}, "force format", "fmt" },
{ "i", HAS_ARG, {(void*)opt_input_file}, "input file name", "filename" },
{ "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" },
{ "loop_input", OPT_BOOL | OPT_EXPERT, {(void*)&loop_input}, "loop (current only works with images)" },
{ "loop_output", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&loop_output}, "number of times to loop output in formats that support looping (0 loops forever)", "" },
{ "v", HAS_ARG | OPT_FUNC2, {(void*)opt_verbose}, "set ffmpeg verbosity level", "number" },
- { "loglevel", HAS_ARG | OPT_FUNC2, {(void*)opt_loglevel}, "set libav* logging level", "logging level number or string" },
+ { "loglevel", HAS_ARG | OPT_FUNC2, {(void*)opt_loglevel}, "set libav* logging level", "loglevel" },
{ "target", HAS_ARG, {(void*)opt_target}, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" },
{ "threads", OPT_FUNC2 | HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
{ "vsync", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&video_sync_method}, "video sync method", "" },
{ "apre", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_EXPERT, {(void*)opt_preset}, "set the audio options to the indicated preset", "preset" },
{ "vpre", OPT_FUNC2 | HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_preset}, "set the video options to the indicated preset", "preset" },
{ "spre", OPT_FUNC2 | HAS_ARG | OPT_SUBTITLE | OPT_EXPERT, {(void*)opt_preset}, "set the subtitle options to the indicated preset", "preset" },
+ { "fpre", OPT_FUNC2 | HAS_ARG | OPT_EXPERT, {(void*)opt_preset}, "set options to the indicated preset file", "filename" },
{ "default", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
{ NULL, },