Skip to content
Snippets Groups Projects
ffmpeg.c 135 KiB
Newer Older
Fabrice Bellard's avatar
Fabrice Bellard committed
/*
 * FFmpeg main
Fabrice Bellard's avatar
Fabrice Bellard committed
 * Copyright (c) 2000-2003 Fabrice Bellard
Fabrice Bellard's avatar
Fabrice Bellard committed
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
Fabrice Bellard's avatar
Fabrice Bellard committed
 *
 * FFmpeg is distributed in the hope that it will be useful,
Fabrice Bellard's avatar
Fabrice Bellard committed
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
Fabrice Bellard's avatar
Fabrice Bellard committed
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Fabrice Bellard's avatar
Fabrice Bellard committed
 */
#include "config.h"
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <errno.h>
#include <signal.h>
#include <limits.h>
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
#include "libavformat/framehook.h"
#include "libavcodec/opt.h"
#include "libavutil/fifo.h"
#include "libavutil/avstring.h"
#include "libavformat/os_support.h"
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#elif defined(HAVE_GETPROCESSTIMES)
#include <windows.h>
#endif

#if defined(HAVE_TERMIOS_H)
Fabrice Bellard's avatar
Fabrice Bellard committed
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <termios.h>
#elif defined(HAVE_CONIO_H)
#include <conio.h>
Fabrice Bellard's avatar
Fabrice Bellard committed
#endif
Michael Niedermayer's avatar
Michael Niedermayer committed
#undef time //needed because HAVE_AV_CONFIG_H is defined on top
#include <time.h>
Fabrice Bellard's avatar
Fabrice Bellard committed

Fabrice Bellard's avatar
Fabrice Bellard committed
#include "cmdutils.h"

#undef NDEBUG
#include <assert.h>

#undef exit

const int program_birth_year = 2000;
Fabrice Bellard's avatar
Fabrice Bellard committed
/* select an input stream for an output stream */
typedef struct AVStreamMap {
    int file_index;
    int stream_index;
    int sync_file_index;
    int sync_stream_index;
Fabrice Bellard's avatar
Fabrice Bellard committed
} AVStreamMap;

/** select an input file for an output file */
typedef struct AVMetaDataMap {
    int out_file;
    int in_file;
} AVMetaDataMap;

Fabrice Bellard's avatar
Fabrice Bellard committed

#define MAX_FILES 20

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];
Fabrice Bellard's avatar
Fabrice Bellard committed
static int nb_input_files = 0;

static AVFormatContext *output_files[MAX_FILES];
static int nb_output_files = 0;

static AVStreamMap stream_maps[MAX_FILES];
static int nb_stream_maps;

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;
static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE;
static int frame_padtop  = 0;
static int frame_padbottom = 0;
static int frame_padleft  = 0;
static int frame_padright = 0;
static int padcolor[3] = {16,128,128}; /* default to black */
static int frame_topBand  = 0;
static int frame_bottomBand = 0;
static int frame_leftBand  = 0;
static int frame_rightBand = 0;
static int max_frames[4] = {INT_MAX, INT_MAX, INT_MAX, INT_MAX};
static AVRational frame_rate;
static uint16_t *intra_matrix = NULL;
static uint16_t *inter_matrix = NULL;
#if 0 //experimental, (can be removed)
static float video_rc_qsquish=1.0;
static float video_rc_qmod_amp=0;
static int video_rc_qmod_freq=0;
static const char *video_rc_override_string=NULL;
Fabrice Bellard's avatar
Fabrice Bellard committed
static int video_disable = 0;
static int video_discard = 0;
static char *video_codec_name = NULL;
Michael Niedermayer's avatar
Michael Niedermayer committed
static int video_codec_tag = 0;
Fabrice Bellard's avatar
Fabrice Bellard committed
static int same_quality = 0;
static int do_deinterlace = 0;
static int strict = 0;
static int top_field_first = -1;
Michael Niedermayer's avatar
Michael Niedermayer committed
static int intra_dc_precision = 8;
static int loop_input = 0;
static int loop_output = AVFMT_NOOUTPUTLOOP;
static int qp_hist = 0;
Fabrice Bellard's avatar
Fabrice Bellard committed

static int intra_only = 0;
static int audio_sample_rate = 44100;
#define QSCALE_NONE -99999
static float audio_qscale = QSCALE_NONE;
Fabrice Bellard's avatar
Fabrice Bellard committed
static int audio_disable = 0;
static int audio_channels = 1;
static char  *audio_codec_name = NULL;
Michael Niedermayer's avatar
Michael Niedermayer committed
static int audio_codec_tag = 0;
static int subtitle_disable = 0;
static char *subtitle_codec_name = NULL;
static char *subtitle_language = NULL;
Fabrice Bellard's avatar
Fabrice Bellard committed

static float mux_preload= 0.5;
static float mux_max_delay= 0.7;
static int64_t recording_time = 0;
static int64_t start_time = 0;
static int64_t input_ts_offset = 0;
Fabrice Bellard's avatar
Fabrice Bellard committed
static int file_overwrite = 0;
static char *str_title = NULL;
static char *str_author = NULL;
static char *str_copyright = NULL;
static char *str_comment = NULL;
static char *str_genre = NULL;
static char *str_album = NULL;
Fabrice Bellard's avatar
Fabrice Bellard committed
static int do_benchmark = 0;
static int do_hex_dump = 0;
static int do_pass = 0;
static char *pass_logfilename = NULL;
static int audio_stream_copy = 0;
static int video_stream_copy = 0;
static int video_sync_method= -1;
static int audio_sync_method= 0;
static float audio_drift_threshold= 0.1;
static int copy_ts= 0;
static char *vstats_filename;
static FILE *vstats_file;
static char *video_standard;
static int thread_count= 1;
static int64_t video_size = 0;
static int64_t audio_size = 0;
Loading
Loading full blame...