コード例 #1
0
ファイル: dump_keyframes.c プロジェクト: AMDmi3/ffmpeg-fas
int main (int argc, char **argv)
{
  char * out_dir;
  char out_file[128];
  int i;
  seek_table_type table;
  fas_error_type video_error;
  fas_context_ref_type context, seek_context;

  cmdname = argv[0];

  if (argc < 3) {
    show_help();
    fail("arguments\n");
  }

  table = read_table_file(argv[2]);
  if (table.num_entries == 0)
    fail("bad table\n");

  fas_initialize (FAS_FALSE, FAS_RGB24);

  video_error = fas_open_video (&context, argv[1]);
  if (video_error != FAS_SUCCESS)    fail("fail on open\n");

  video_error = fas_put_seek_table(context, table);
  if (video_error != FAS_SUCCESS)    fail("fail on put_seek_table\n");

  video_error = fas_open_video (&seek_context, argv[1]);
  if (video_error != FAS_SUCCESS)    fail("fail on open\n");


  if (argc >= 4) {
    out_dir = argv[3];
    create_dir(out_dir);
  } else {
    out_dir = ".";
  }

  for(i=0;i<table.num_entries;i++)
    {
      fas_raw_image_type image_buffer;
      //      int frame_index = table.array[table.num_entries - i - 1].display_index;
      int frame_index = table.array[i].display_index;
      if (FAS_SUCCESS != fas_seek_to_frame(context, frame_index))
	fail("failed on seek");

      if (FAS_SUCCESS != fas_get_frame (context, &image_buffer))
	fail("failed on rgb image\n");

      sprintf(out_file, "%s/frame_%04d.ppm", out_dir, frame_index);

      fprintf(stderr, "Writing %s (seek_table_value=%d frame_index=%d)\n", out_file, frame_index, fas_get_frame_index(context));
      ppm_save(&image_buffer, out_file);

      fas_free_frame (image_buffer);
    }

  success();
}
コード例 #2
0
ファイル: external_seek_test.c プロジェクト: benob/ffmpeg-fas
int main (int argc, char **argv)
{
  fas_error_type video_error;
  fas_context_ref_type context;
  
  if (argc < 3) {
    fprintf (stderr, "usage: %s <video_file> <seek_table>\n", argv[0]);
    fail("arguments\n");
  }

  fprintf(stderr, "%s : ", argv[1]);

  seek_table_type table = read_table_file(argv[2]);
  if (table.num_entries == 0)
    fail("bad table\n");
  
  fas_initialize (FAS_FALSE, FAS_RGB24);
  
  video_error = fas_open_video (&context, argv[1]);
  if (video_error != FAS_SUCCESS)    fail("fail on open\n");
  
  video_error = fas_put_seek_table(context, table);
  if (video_error != FAS_SUCCESS)    fail("fail on put_seek_table\n");
    
  if (fas_get_frame_count(context) < 0)
    fail("n_frames = -1\n");

  if (fas_get_frame_count(context) < TEST_SET_SIZE)
      do_random_test(context, 0, fas_get_frame_count(context) - 1, N_ITERATIONS);
  else if (fas_get_frame_count(context) < TEST_SET_SIZE * 2)
    {
      do_random_test(context, 0, fas_get_frame_count(context) / 2 - 1, N_ITERATIONS / 2);
      do_random_test(context, fas_get_frame_count(context) / 2 + 1, fas_get_frame_count(context) - 1 , N_ITERATIONS / 2);   
    }
  else
    {
      do_random_test(context, 0, TEST_SET_SIZE, N_ITERATIONS / 2);
      do_random_test(context, fas_get_frame_count(context) - TEST_SET_SIZE, fas_get_frame_count(context) - 1 , N_ITERATIONS / 2);   
    }

  seek_release_table(&table);
  fas_close_video(context);
  
  success();
}