帧区间处理
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}
|
, {NULL, NULL, 0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
char *avs_filename = NULL;
|
char *avs_filename = NULL;
|
||||||
|
char *ranges_filename = NULL;
|
||||||
char *track_name = "Undefined";
|
char *track_name = "Undefined";
|
||||||
char *language = "und";
|
char *language = "und";
|
||||||
char *video_format = "1080p";
|
char *video_format = "1080p";
|
||||||
@ -820,15 +821,14 @@ int main (int argc, char *argv[])
|
|||||||
char *even_y_string = "0";
|
char *even_y_string = "0";
|
||||||
char *auto_crop_image = "1";
|
char *auto_crop_image = "1";
|
||||||
char *ugly_option = "0";
|
char *ugly_option = "0";
|
||||||
char *seek_string = "0";
|
|
||||||
char *allow_empty_string = "0";
|
char *allow_empty_string = "0";
|
||||||
char *stricter_string = "0";
|
char *stricter_string = "0";
|
||||||
char *count_string = "2147483647";
|
|
||||||
char *in_img = NULL, *old_img = NULL, *tmp = NULL, *out_buf = NULL;
|
char *in_img = NULL, *old_img = NULL, *tmp = NULL, *out_buf = NULL;
|
||||||
char *intc_buf = NULL, *outtc_buf = NULL;
|
char *intc_buf = NULL, *outtc_buf = NULL;
|
||||||
char *drop_frame = NULL;
|
char *drop_frame = NULL;
|
||||||
char *mark_forced_string = "0";
|
char *mark_forced_string = "0";
|
||||||
char png_dir[MAX_PATH + 1] = {0};
|
char png_dir[MAX_PATH + 1] = {0};
|
||||||
|
FILE* ranges_fp;
|
||||||
crop_t crops[2];
|
crop_t crops[2];
|
||||||
pic_t pic;
|
pic_t pic;
|
||||||
uint32_t *pal = NULL;
|
uint32_t *pal = NULL;
|
||||||
@ -868,6 +868,11 @@ int main (int argc, char *argv[])
|
|||||||
event_list_t *events = event_list_new();
|
event_list_t *events = event_list_new();
|
||||||
event_t *event;
|
event_t *event;
|
||||||
FILE *fh;
|
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 */
|
/* Get args */
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
@ -879,8 +884,7 @@ int main (int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
{ {"output", required_argument, 0, 'o'}
|
{ {"output", required_argument, 0, 'o'}
|
||||||
, {"seek", required_argument, 0, 'j'}
|
, {"ranges-file", required_argument, 0, 'r'}
|
||||||
, {"count", required_argument, 0, 'c'}
|
|
||||||
, {"trackname", required_argument, 0, 't'}
|
, {"trackname", required_argument, 0, 't'}
|
||||||
, {"language", required_argument, 0, 'l'}
|
, {"language", required_argument, 0, 'l'}
|
||||||
, {"video-format", required_argument, 0, 'v'}
|
, {"video-format", required_argument, 0, 'v'}
|
||||||
@ -902,7 +906,7 @@ int main (int argc, char *argv[])
|
|||||||
};
|
};
|
||||||
int option_index = 0;
|
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)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
switch (c)
|
switch (c)
|
||||||
@ -916,11 +920,8 @@ int main (int argc, char *argv[])
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'j':
|
case 'r':
|
||||||
seek_string = optarg;
|
ranges_filename = optarg;
|
||||||
break;
|
|
||||||
case 'c':
|
|
||||||
count_string = optarg;
|
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
track_name = optarg;
|
track_name = optarg;
|
||||||
@ -988,7 +989,7 @@ int main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Both input and output filenames are required */
|
/* Both input and output filenames are required */
|
||||||
if (avs_filename == NULL)
|
if (avs_filename == NULL || ranges_filename == NULL)
|
||||||
{
|
{
|
||||||
print_usage();
|
print_usage();
|
||||||
return 0;
|
return 0;
|
||||||
@ -1036,8 +1037,6 @@ int main (int argc, char *argv[])
|
|||||||
ugly = parse_int(ugly_option, "ugly", NULL);
|
ugly = parse_int(ugly_option, "ugly", NULL);
|
||||||
allow_empty = parse_int(allow_empty_string, "null-xml", NULL);
|
allow_empty = parse_int(allow_empty_string, "null-xml", NULL);
|
||||||
stricter = parse_int(stricter_string, "stricter", 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);
|
min_split = parse_int(minimum_split, "min-split", NULL);
|
||||||
if (!min_split)
|
if (!min_split)
|
||||||
min_split = 1;
|
min_split = 1;
|
||||||
@ -1106,8 +1105,36 @@ int main (int argc, char *argv[])
|
|||||||
crops[0].w = pic.w;
|
crops[0].w = pic.w;
|
||||||
crops[0].h = pic.h;
|
crops[0].h = pic.h;
|
||||||
|
|
||||||
/* Get frame number */
|
/* Get total frame number */
|
||||||
frames = get_frame_total_avis(avis_hnd);
|
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)
|
if (count_frames + init_frame > frames)
|
||||||
{
|
{
|
||||||
count_frames = frames - init_frame;
|
count_frames = frames - init_frame;
|
||||||
@ -1118,7 +1145,7 @@ int main (int argc, char *argv[])
|
|||||||
if (count_frames < 1)
|
if (count_frames < 1)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No frames found.\n");
|
fprintf(stderr, "No frames found.\n");
|
||||||
return 0;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set progress step */
|
/* Set progress step */
|
||||||
@ -1132,10 +1159,6 @@ int main (int argc, char *argv[])
|
|||||||
progress_step = 1;
|
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 */
|
/* Process frames */
|
||||||
for (i = init_frame; i < last_frame; i++)
|
for (i = init_frame; i < last_frame; i++)
|
||||||
{
|
{
|
||||||
@ -1149,7 +1172,7 @@ int main (int argc, char *argv[])
|
|||||||
/* Progress indicator */
|
/* Progress indicator */
|
||||||
if (i % (count_frames / progress_step) == 0)
|
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 */
|
/* If we are outside any lines, check for empty frames first */
|
||||||
@ -1230,7 +1253,8 @@ int main (int argc, char *argv[])
|
|||||||
old_img = tmp;
|
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 */
|
/* Add last event, if available */
|
||||||
if (have_line)
|
if (have_line)
|
||||||
@ -1252,6 +1276,7 @@ int main (int argc, char *argv[])
|
|||||||
auto_cut = 1;
|
auto_cut = 1;
|
||||||
end_frame = i - 1;
|
end_frame = i - 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sup_output)
|
if (sup_output)
|
||||||
{
|
{
|
||||||
@ -1338,6 +1363,7 @@ int main (int argc, char *argv[])
|
|||||||
|
|
||||||
/* Cleanup */
|
/* Cleanup */
|
||||||
close_file_avis(avis_hnd);
|
close_file_avis(avis_hnd);
|
||||||
|
fclose(ranges_fp);
|
||||||
|
|
||||||
/* Give runtime */
|
/* Give runtime */
|
||||||
if (0)
|
if (0)
|
||||||
|
Loading…
Reference in New Issue
Block a user