Exemplo n.º 1
0
int main(int argc, char *argv[])
{
	long bytes = 0;
	int i;
	
	if(argc < 2)
	{
		fprintf(stderr, "Split elementary streams into chunks of bytes.\n"
			"Usage: mpeg3split -b bytes <infile>\n");
		exit(1);
	}
	
	for(i = 1; i < argc; i++)
	{
		if(!strcmp(argv[i], "-b"))
		{
			if(i < argc - 1)
			{
				i++;
				bytes = atol(argv[i]);
			}
			else
			{
				fprintf(stderr, "-b must be paired with a value\n");
				exit(1);
			}
		}
		else
		if(bytes > 0)
		{
// Split a file
			split_video(argv[i], bytes);
		}
		else
		{
			fprintf(stderr, "No value for bytes specified,\n");
			exit(1);
		}
	}
}
Exemplo n.º 2
0
int main(int argc, char **argv)
{
    const char *input_file;
    const char *output_template;
    AVDictionary *opt = NULL;
    int gop_size = 30;
    int chunk_size = 120;
    int skip = 0;
    long long length = -1;
    int c;
    static int help = 0;
    char *end;

    while(1)
    {
      static struct option long_options[] =
        {
          /* These options set a flag. */
          {"gop-size",  required_argument, 0, 'g'},
          {"chunk-size",  required_argument, 0, 'c'},
          {"skip", required_argument, 0, 's'},
          {"length", required_argument, 0, 'n'},
          {"help", no_argument, &help, 'h'},
          {0, 0, 0, 0}
        };
      /* getopt_long stores the option index here. */
      int option_index = 0;

      c = getopt_long (argc, argv, "g:c:s:n:h",
                       long_options, &option_index);

      /* Detect the end of the options. */
      if (c == -1)
        break;

      switch (c)
        {
        case 'g':
            gop_size = (int)strtoul(optarg, &end, 10);
            break;

        case 'c':
            chunk_size = (int)strtoul(optarg, &end, 10);
            break;

        case 's':
            skip = (int)strtoul(optarg, &end, 10);
            break;

        case 'n':
            length = strtoul(optarg, &end, 10);
            break;

        case 'h':
            print_help(argv[0]);
            exit(0);
            break;

        case '?':
            break;

        default:
            abort();
        }
    }

    if (chunk_size % gop_size != 0) {
        fprintf(stderr, "chunk size (%d) must be a multiple of gop size (%d)",
                chunk_size, gop_size);
        return 1;
    }

    if (argc - optind != 2) {
        print_help(argv[0]);
        return 1;
    }

    input_file = argv[optind];
    output_template = argv[optind+1];

    printf("GOP size: %d\n", gop_size);
    printf("Chunk size: %d\n", chunk_size);

    av_dict_set(&opt, "crf", "18", 0);
    av_dict_set(&opt, "movflags", "faststart", 0);

    /* register all the codecs */
    av_register_all();
    avcodec_register_all();
    av_log_set_level(AV_LOG_WARNING);

    split_video(input_file, output_template, gop_size, chunk_size, skip, length, opt);

    return 0;
}