@@ -109,6 +109,8 @@ static void print_usage()
109109 fprintf (stderr, " -1 input1-path input image1 path (jpg/png/webp)\n " );
110110 fprintf (stderr, " -i input-path input image directory (jpg/png/webp)\n " );
111111 fprintf (stderr, " -o output-path output image path (jpg/png/webp) or directory\n " );
112+ fprintf (stderr, " -n num-frame target frame count (default=N*2)\n " );
113+ fprintf (stderr, " -s time-step time step (0~1, default=0.5)\n " );
112114 fprintf (stderr, " -m model-path rife model path (default=rife-HD)\n " );
113115 fprintf (stderr, " -g gpu-id gpu device to use (-1=cpu, default=auto) can be 0,1,2 for multi-gpu\n " );
114116 fprintf (stderr, " -j load:proc:save thread count for load/proc/save (default=1:2:2) can be 1:2,2,2:2 for multi-gpu\n " );
@@ -443,6 +445,8 @@ int main(int argc, char** argv)
443445 path_t input1path;
444446 path_t inputpath;
445447 path_t outputpath;
448+ int numframe = 0 ;
449+ float timestep = 0 .5f ;
446450 path_t model = PATHSTR (" rife-HD" );
447451 std::vector<int > gpuid;
448452 int jobs_load = 1 ;
@@ -456,7 +460,7 @@ int main(int argc, char** argv)
456460#if _WIN32
457461 setlocale (LC_ALL, " " );
458462 wchar_t opt;
459- while ((opt = getopt (argc, argv, L" 0:1:i:o:m:g:j:f:vxuh" )) != (wchar_t )-1 )
463+ while ((opt = getopt (argc, argv, L" 0:1:i:o:n:s: m:g:j:f:vxuh" )) != (wchar_t )-1 )
460464 {
461465 switch (opt)
462466 {
@@ -472,6 +476,12 @@ int main(int argc, char** argv)
472476 case L' o' :
473477 outputpath = optarg;
474478 break ;
479+ case L' n' :
480+ numframe = _wtoi (optarg);
481+ break ;
482+ case L' s' :
483+ timestep = _wtof (optarg);
484+ break ;
475485 case L' m' :
476486 model = optarg;
477487 break ;
@@ -502,7 +512,7 @@ int main(int argc, char** argv)
502512 }
503513#else // _WIN32
504514 int opt;
505- while ((opt = getopt (argc, argv, " 0:1:i:o:m:g:j:f:vxuh" )) != -1 )
515+ while ((opt = getopt (argc, argv, " 0:1:i:o:n:s: m:g:j:f:vxuh" )) != -1 )
506516 {
507517 switch (opt)
508518 {
@@ -518,6 +528,12 @@ int main(int argc, char** argv)
518528 case ' o' :
519529 outputpath = optarg;
520530 break ;
531+ case ' n' :
532+ numframe = atoi (optarg);
533+ break ;
534+ case ' s' :
535+ timestep = atof (optarg);
536+ break ;
521537 case ' m' :
522538 model = optarg;
523539 break ;
@@ -554,6 +570,18 @@ int main(int argc, char** argv)
554570 return -1 ;
555571 }
556572
573+ if (inputpath.empty () && (timestep <= 0 .f || timestep >= 1 .f ))
574+ {
575+ fprintf (stderr, " invalid timestep argument, must be 0~1\n " );
576+ return -1 ;
577+ }
578+
579+ if (!inputpath.empty () && numframe < 0 )
580+ {
581+ fprintf (stderr, " invalid numframe argument, must not be negative\n " );
582+ return -1 ;
583+ }
584+
557585 if (jobs_load < 1 || jobs_save < 1 )
558586 {
559587 fprintf (stderr, " invalid thread count argument\n " );
@@ -619,6 +647,39 @@ int main(int argc, char** argv)
619647 return -1 ;
620648 }
621649
650+ bool rife_v2 = false ;
651+ bool rife_v4 = false ;
652+ if (model.find (PATHSTR (" rife-v2" )) != path_t ::npos)
653+ {
654+ // fine
655+ rife_v2 = true ;
656+ }
657+ else if (model.find (PATHSTR (" rife-v3" )) != path_t ::npos)
658+ {
659+ // fine
660+ rife_v2 = true ;
661+ }
662+ else if (model.find (PATHSTR (" rife-v4" )) != path_t ::npos)
663+ {
664+ // fine
665+ rife_v4 = true ;
666+ }
667+ else if (model.find (PATHSTR (" rife" )) != path_t ::npos)
668+ {
669+ // fine
670+ }
671+ else
672+ {
673+ fprintf (stderr, " unknown model dir type\n " );
674+ return -1 ;
675+ }
676+
677+ if (!rife_v4 && (numframe != 0 || timestep != 0.5 ))
678+ {
679+ fprintf (stderr, " only rife-v4 model support custom numframe and timestep\n " );
680+ return -1 ;
681+ }
682+
622683 // collect input and output filepath
623684 std::vector<path_t > input0_files;
624685 std::vector<path_t > input1_files;
@@ -633,7 +694,8 @@ int main(int argc, char** argv)
633694 return -1 ;
634695
635696 const int count = filenames.size ();
636- const int numframe = count * 2 ;
697+ if (numframe == 0 )
698+ numframe = count * 2 ;
637699
638700 input0_files.resize (numframe);
639701 input1_files.resize (numframe);
@@ -685,7 +747,7 @@ int main(int argc, char** argv)
685747 input0_files.push_back (input0path);
686748 input1_files.push_back (input1path);
687749 output_files.push_back (outputpath);
688- timesteps.push_back (0 . 5f );
750+ timesteps.push_back (timestep );
689751 }
690752 else
691753 {
@@ -695,33 +757,6 @@ int main(int argc, char** argv)
695757 }
696758 }
697759
698- bool rife_v2 = false ;
699- bool rife_v4 = false ;
700- if (model.find (PATHSTR (" rife-v2" )) != path_t ::npos)
701- {
702- // fine
703- rife_v2 = true ;
704- }
705- else if (model.find (PATHSTR (" rife-v3" )) != path_t ::npos)
706- {
707- // fine
708- rife_v2 = true ;
709- }
710- else if (model.find (PATHSTR (" rife-v4" )) != path_t ::npos)
711- {
712- // fine
713- rife_v4 = true ;
714- }
715- else if (model.find (PATHSTR (" rife" )) != path_t ::npos)
716- {
717- // fine
718- }
719- else
720- {
721- fprintf (stderr, " unknown model dir type\n " );
722- return -1 ;
723- }
724-
725760 path_t modeldir = sanitize_dirpath (model);
726761
727762#if _WIN32
0 commit comments