Commit f21f294e authored by Anton Khirnov's avatar Anton Khirnov Committed by Alex Converse

avconv: rescue poor abused limit_filesize global.

Keep a per-OutputFile instance of it, thus making -fs work with multiple
output files.
Signed-off-by: 's avatarAlex Converse <alex.converse@gmail.com>
parent e6d2b737
...@@ -197,7 +197,7 @@ static int64_t extra_size = 0; ...@@ -197,7 +197,7 @@ static int64_t extra_size = 0;
static int nb_frames_dup = 0; static int nb_frames_dup = 0;
static int nb_frames_drop = 0; static int nb_frames_drop = 0;
static int input_sync; static int input_sync;
static uint64_t limit_filesize = 0; static uint64_t limit_filesize = UINT64_MAX;
static int force_fps = 0; static int force_fps = 0;
static char *forced_key_frames = NULL; static char *forced_key_frames = NULL;
...@@ -303,6 +303,7 @@ typedef struct OutputFile { ...@@ -303,6 +303,7 @@ typedef struct OutputFile {
int ost_index; /* index of the first stream in output_streams */ int ost_index; /* index of the first stream in output_streams */
int64_t recording_time; /* desired length of the resulting file in microseconds */ int64_t recording_time; /* desired length of the resulting file in microseconds */
int64_t start_time; /* start time in microseconds */ int64_t start_time; /* start time in microseconds */
uint64_t limit_filesize;
} OutputFile; } OutputFile;
static InputStream *input_streams = NULL; static InputStream *input_streams = NULL;
...@@ -2246,12 +2247,15 @@ static int transcode(OutputFile *output_files, ...@@ -2246,12 +2247,15 @@ static int transcode(OutputFile *output_files,
smallest output pts */ smallest output pts */
file_index = -1; file_index = -1;
for (i = 0; i < nb_output_streams; i++) { for (i = 0; i < nb_output_streams; i++) {
OutputFile *of;
int64_t ipts; int64_t ipts;
double opts; double opts;
ost = &output_streams[i]; ost = &output_streams[i];
of = &output_files[ost->file_index];
os = output_files[ost->file_index].ctx; os = output_files[ost->file_index].ctx;
ist = &input_streams[ost->source_index]; ist = &input_streams[ost->source_index];
if(ost->is_past_recording_time || no_packet[ist->file_index]) if (ost->is_past_recording_time || no_packet[ist->file_index] ||
(os->pb && avio_tell(os->pb) >= of->limit_filesize))
continue; continue;
opts = ost->st->pts.val * av_q2d(ost->st->time_base); opts = ost->st->pts.val * av_q2d(ost->st->time_base);
ipts = ist->pts; ipts = ist->pts;
...@@ -2281,10 +2285,6 @@ static int transcode(OutputFile *output_files, ...@@ -2281,10 +2285,6 @@ static int transcode(OutputFile *output_files,
break; break;
} }
/* finish if limit size exhausted */
if (limit_filesize != 0 && limit_filesize <= avio_tell(output_files[0].ctx->pb))
break;
/* read a frame from it and output it in the fifo */ /* read a frame from it and output it in the fifo */
is = input_files[file_index].ctx; is = input_files[file_index].ctx;
ret= av_read_frame(is, &pkt); ret= av_read_frame(is, &pkt);
...@@ -3568,6 +3568,7 @@ static void opt_output_file(const char *filename) ...@@ -3568,6 +3568,7 @@ static void opt_output_file(const char *filename)
output_files[nb_output_files - 1].ost_index = nb_output_streams - oc->nb_streams; output_files[nb_output_files - 1].ost_index = nb_output_streams - oc->nb_streams;
output_files[nb_output_files - 1].recording_time = recording_time; output_files[nb_output_files - 1].recording_time = recording_time;
output_files[nb_output_files - 1].start_time = start_time; output_files[nb_output_files - 1].start_time = start_time;
output_files[nb_output_files - 1].limit_filesize = limit_filesize;
av_dict_copy(&output_files[nb_output_files - 1].opts, format_opts, 0); av_dict_copy(&output_files[nb_output_files - 1].opts, format_opts, 0);
/* check filename in case of an image number is expected */ /* check filename in case of an image number is expected */
...@@ -3695,6 +3696,7 @@ static void opt_output_file(const char *filename) ...@@ -3695,6 +3696,7 @@ static void opt_output_file(const char *filename)
chapters_input_file = INT_MAX; chapters_input_file = INT_MAX;
recording_time = INT64_MAX; recording_time = INT64_MAX;
start_time = 0; start_time = 0;
limit_filesize = UINT64_MAX;
av_freep(&meta_data_maps); av_freep(&meta_data_maps);
nb_meta_data_maps = 0; nb_meta_data_maps = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment