/*
- * FFmpeg main
+ * ffmpeg main
* Copyright (c) 2000-2003 Fabrice Bellard
*
* This file is part of FFmpeg.
#include "libavutil/avassert.h"
-const char program_name[] = "FFmpeg";
+const char program_name[] = "ffmpeg";
const int program_birth_year = 2000;
/* select an input stream for an output stream */
static int exit_on_error = 0;
static int using_stdin = 0;
static int verbose = 1;
-static int daemon = 0;
+static int run_as_daemon = 0;
static int thread_count= 1;
static int q_pressed = 0;
static int64_t video_size = 0;
{
av_log(NULL, AV_LOG_QUIET, "");
#if HAVE_TERMIOS_H
- if(!daemon)
+ if(!run_as_daemon)
tcsetattr (0, TCSANOW, &oldtty);
#endif
}
static void term_init(void)
{
#if HAVE_TERMIOS_H
- if(!daemon){
+ if(!run_as_daemon){
struct termios tty;
tcgetattr (0, &tty);
struct timeval tv;
fd_set rfds;
- if(daemon)
+ if(run_as_daemon)
return -1;
FD_ZERO(&rfds);
//av_log(NULL, AV_LOG_DEBUG, "%"PRId64" -> encoder\n", ost->sync_opts);
if (ost->forced_kf_index < ost->forced_kf_count &&
big_picture.pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
- big_picture.pict_type = FF_I_TYPE;
+ big_picture.pict_type = AV_PICTURE_TYPE_I;
ost->forced_kf_index++;
}
ret = avcodec_encode_video(enc,
avg_bitrate = (double)(video_size * 8) / ti1 / 1000.0;
fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
(double)video_size / 1024, ti1, bitrate, avg_bitrate);
- fprintf(vstats_file,"type= %c\n", av_get_pict_type_char(enc->coded_frame->pict_type));
+ fprintf(vstats_file,"type= %c\n", av_get_picture_type_char(enc->coded_frame->pict_type));
}
}
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
if (ost->input_video_filter && ost->source_index == ist_index) {
- AVRational sar;
- if (ist->st->sample_aspect_ratio.num) sar = ist->st->sample_aspect_ratio;
- else sar = ist->st->codec->sample_aspect_ratio;
+ if (!picture.sample_aspect_ratio.num)
+ picture.sample_aspect_ratio = ist->st->sample_aspect_ratio;
// add it to be filtered
av_vsrc_buffer_add_frame2(ost->input_video_filter, &picture,
ist->pts,
- sar, ist->st->codec->width, ist->st->codec->height,
- ist->st->codec->pix_fmt, "0:0"); //TODO user setable params
+ ist->st->codec->width, ist->st->codec->height,
+ ist->st->codec->pix_fmt, ""); //TODO user setable params
}
}
}
case AVMEDIA_TYPE_VIDEO:
#if CONFIG_AVFILTER
if (ost->picref->video && !ost->frame_aspect_ratio)
- ost->st->codec->sample_aspect_ratio = ost->picref->video->pixel_aspect;
+ ost->st->codec->sample_aspect_ratio = ost->picref->video->sample_aspect_ratio;
#endif
do_video_out(os, ost, ist, &picture, &frame_size);
if (vstats_filename && frame_size)
ic->subtitle_codec_id=
find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0,
avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance);
- ic->flags |= AVFMT_FLAG_NONBLOCK;
+ ic->flags |= AVFMT_FLAG_NONBLOCK | AVFMT_FLAG_PRIV_OPT;
/* open the input file with generic libav function */
err = av_open_input_file(&ic, filename, file_iformat, 0, ap);
+ if(err >= 0){
+ set_context_opts(ic, avformat_opts, AV_OPT_FLAG_DECODING_PARAM, NULL);
+ err = av_demuxer_open(ic, ap);
+ if(err < 0)
+ avformat_free_context(ic);
+ }
if (err < 0) {
print_error(filename, err);
ffmpeg_exit(1);
case AVMEDIA_TYPE_AUDIO:
input_codecs[nb_input_codecs-1] = avcodec_find_decoder_by_name(audio_codec_name);
set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM, input_codecs[nb_input_codecs-1]);
- //fprintf(stderr, "\nInput Audio channels: %d", dec->channels);
channel_layout = dec->channel_layout;
audio_channels = dec->channels;
audio_sample_rate = dec->sample_rate;
if (!strcmp(filename, "-"))
filename = "pipe:";
- oc = avformat_alloc_context();
+ oc = avformat_alloc_output_context(last_asked_format, NULL, filename);
+ last_asked_format = NULL;
if (!oc) {
print_error(filename, AVERROR(ENOMEM));
ffmpeg_exit(1);
}
-
- if (last_asked_format) {
- file_oformat = av_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);
- ffmpeg_exit(1);
- }
- last_asked_format = NULL;
- } else {
- file_oformat = av_guess_format(NULL, filename, NULL);
- if (!file_oformat) {
- fprintf(stderr, "Unable to find a suitable output format for '%s'\n",
- filename);
- ffmpeg_exit(1);
- }
- }
-
- oc->oformat = file_oformat;
- av_strlcpy(oc->filename, filename, sizeof(oc->filename));
+ file_oformat= oc->oformat;
if (!strcmp(file_oformat->name, "ffm") &&
av_strstart(filename, "http:", NULL)) {
/* check filename in case of an image number is expected */
if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
if (!av_filename_number_test(oc->filename)) {
- print_error(oc->filename, AVERROR_NUMEXPECTED);
+ print_error(oc->filename, AVERROR(EINVAL));
ffmpeg_exit(1);
}
}
av_log_set_flags(AV_LOG_SKIP_REPEATED);
if(argc>1 && !strcmp(argv[1], "-d")){
- daemon=1;
+ run_as_daemon=1;
verbose=-1;
av_log_set_callback(log_callback_null);
argc--;