帧区间处理
This commit is contained in:
parent
ed7bd25157
commit
81d21ecfff
68
avs2bdnxml.c
68
avs2bdnxml.c
@ -803,6 +803,7 @@ int main (int argc, char *argv[])
|
||||
, {NULL, NULL, 0, 0, 0, 0}
|
||||
};
|
||||
char *avs_filename = NULL;
|
||||
char *ranges_filename = NULL;
|
||||
char *track_name = "Undefined";
|
||||
char *language = "und";
|
||||
char *video_format = "1080p";
|
||||
@ -820,15 +821,14 @@ int main (int argc, char *argv[])
|
||||
char *even_y_string = "0";
|
||||
char *auto_crop_image = "1";
|
||||
char *ugly_option = "0";
|
||||
char *seek_string = "0";
|
||||
char *allow_empty_string = "0";
|
||||
char *stricter_string = "0";
|
||||
char *count_string = "2147483647";
|
||||
char *in_img = NULL, *old_img = NULL, *tmp = NULL, *out_buf = NULL;
|
||||
char *intc_buf = NULL, *outtc_buf = NULL;
|
||||
char *drop_frame = NULL;
|
||||
char *mark_forced_string = "0";
|
||||
char png_dir[MAX_PATH + 1] = {0};
|
||||
FILE* ranges_fp;
|
||||
crop_t crops[2];
|
||||
pic_t pic;
|
||||
uint32_t *pal = NULL;
|
||||
@ -868,6 +868,11 @@ int main (int argc, char *argv[])
|
||||
event_list_t *events = event_list_new();
|
||||
event_t *event;
|
||||
FILE *fh;
|
||||
int range_frame_count = 0;
|
||||
char range_line_str[100];
|
||||
char range_start_str[50];
|
||||
char range_end_str[50];
|
||||
int before_range_frame_count = 0;
|
||||
|
||||
/* Get args */
|
||||
if (argc < 2)
|
||||
@ -879,8 +884,7 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
static struct option long_options[] =
|
||||
{ {"output", required_argument, 0, 'o'}
|
||||
, {"seek", required_argument, 0, 'j'}
|
||||
, {"count", required_argument, 0, 'c'}
|
||||
, {"ranges-file", required_argument, 0, 'r'}
|
||||
, {"trackname", required_argument, 0, 't'}
|
||||
, {"language", required_argument, 0, 'l'}
|
||||
, {"video-format", required_argument, 0, 'v'}
|
||||
@ -902,7 +906,7 @@ int main (int argc, char *argv[])
|
||||
};
|
||||
int option_index = 0;
|
||||
|
||||
c = getopt_long(argc, argv, "o:j:c:t:l:v:f:x:y:d:b:s:m:e:p:a:u:n:z:F:", long_options, &option_index);
|
||||
c = getopt_long(argc, argv, "o:r:t:l:v:f:x:y:d:b:s:m:e:p:a:u:n:z:F:", long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c)
|
||||
@ -916,11 +920,8 @@ int main (int argc, char *argv[])
|
||||
exit(0);
|
||||
}
|
||||
break;
|
||||
case 'j':
|
||||
seek_string = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
count_string = optarg;
|
||||
case 'r':
|
||||
ranges_filename = optarg;
|
||||
break;
|
||||
case 't':
|
||||
track_name = optarg;
|
||||
@ -988,7 +989,7 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Both input and output filenames are required */
|
||||
if (avs_filename == NULL)
|
||||
if (avs_filename == NULL || ranges_filename == NULL)
|
||||
{
|
||||
print_usage();
|
||||
return 0;
|
||||
@ -1036,8 +1037,6 @@ int main (int argc, char *argv[])
|
||||
ugly = parse_int(ugly_option, "ugly", NULL);
|
||||
allow_empty = parse_int(allow_empty_string, "null-xml", NULL);
|
||||
stricter = parse_int(stricter_string, "stricter", NULL);
|
||||
init_frame = parse_int(seek_string, "seek", NULL);
|
||||
count_frames = parse_int(count_string, "count", NULL);
|
||||
min_split = parse_int(minimum_split, "min-split", NULL);
|
||||
if (!min_split)
|
||||
min_split = 1;
|
||||
@ -1106,8 +1105,36 @@ int main (int argc, char *argv[])
|
||||
crops[0].w = pic.w;
|
||||
crops[0].h = pic.h;
|
||||
|
||||
/* Get frame number */
|
||||
/* Get total frame number */
|
||||
frames = get_frame_total_avis(avis_hnd);
|
||||
|
||||
ranges_fp = fopen(ranges_filename, "r");
|
||||
|
||||
if (fscanf(ranges_fp, "%s", range_line_str) != EOF) {
|
||||
fprintf(stderr, "%s\n", range_line_str);
|
||||
range_frame_count = parse_int(range_line_str, "range_frame_count", NULL);
|
||||
}
|
||||
|
||||
if (range_frame_count <= 0) {
|
||||
fprintf(stderr, "Error: Error reading range_frame_count.\n");
|
||||
fclose(ranges_fp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Open SUP writer, if applicable */
|
||||
if (sup_output) {
|
||||
sw = new_sup_writer(sup_output_fn, pic.w, pic.h, fps_num, fps_den);
|
||||
}
|
||||
|
||||
while (fscanf(ranges_fp, "%s %s", range_start_str, range_end_str) != EOF)
|
||||
{
|
||||
int range_start = parse_int(range_start_str, "range_start", NULL);
|
||||
int range_end = parse_int(range_end_str, "range_end", NULL);
|
||||
|
||||
init_frame = range_start;
|
||||
count_frames = range_end - range_start + 1;
|
||||
|
||||
/* Get frame number */
|
||||
if (count_frames + init_frame > frames)
|
||||
{
|
||||
count_frames = frames - init_frame;
|
||||
@ -1118,7 +1145,7 @@ int main (int argc, char *argv[])
|
||||
if (count_frames < 1)
|
||||
{
|
||||
fprintf(stderr, "No frames found.\n");
|
||||
return 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Set progress step */
|
||||
@ -1132,10 +1159,6 @@ int main (int argc, char *argv[])
|
||||
progress_step = 1;
|
||||
}
|
||||
|
||||
/* Open SUP writer, if applicable */
|
||||
if (sup_output)
|
||||
sw = new_sup_writer(sup_output_fn, pic.w, pic.h, fps_num, fps_den);
|
||||
|
||||
/* Process frames */
|
||||
for (i = init_frame; i < last_frame; i++)
|
||||
{
|
||||
@ -1149,7 +1172,7 @@ int main (int argc, char *argv[])
|
||||
/* Progress indicator */
|
||||
if (i % (count_frames / progress_step) == 0)
|
||||
{
|
||||
fprintf(stderr, "\rProgress: %d/%d - Lines: %d", i - init_frame, count_frames, num_of_events);
|
||||
fprintf(stderr, "\rProgress: %d/%d - Lines: %d", i - init_frame + before_range_frame_count, range_frame_count, num_of_events);
|
||||
}
|
||||
|
||||
/* If we are outside any lines, check for empty frames first */
|
||||
@ -1230,7 +1253,8 @@ int main (int argc, char *argv[])
|
||||
old_img = tmp;
|
||||
}
|
||||
|
||||
fprintf(stderr, "\rProgress: %d/%d - Lines: %d - Done\n", i - init_frame, count_frames, num_of_events);
|
||||
before_range_frame_count += i - init_frame;
|
||||
fprintf(stderr, "\rProgress: %d/%d - Lines: %d\n", before_range_frame_count, range_frame_count, num_of_events);
|
||||
|
||||
/* Add last event, if available */
|
||||
if (have_line)
|
||||
@ -1252,6 +1276,7 @@ int main (int argc, char *argv[])
|
||||
auto_cut = 1;
|
||||
end_frame = i - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (sup_output)
|
||||
{
|
||||
@ -1338,6 +1363,7 @@ int main (int argc, char *argv[])
|
||||
|
||||
/* Cleanup */
|
||||
close_file_avis(avis_hnd);
|
||||
fclose(ranges_fp);
|
||||
|
||||
/* Give runtime */
|
||||
if (0)
|
||||
|
Loading…
Reference in New Issue
Block a user