diff --git a/AnyOption.cpp b/AnyOption.cpp deleted file mode 100644 index 85153c0..0000000 --- a/AnyOption.cpp +++ /dev/null @@ -1,1176 +0,0 @@ -/* - * AnyOption 1.3 - * - * kishan at hackorama dot com www.hackorama.com JULY 2001 - * - * + Acts as a common facade class for reading - * commandline options as well as options from - * an optionfile with delimited type value pairs - * - * + Handles the POSIX style single character options ( -w ) - * as well as the newer GNU long options ( --width ) - * - * + The option file assumes the traditional format of - * first character based comment lines and type value - * pairs with a delimiter , and flags which are not pairs - * - * # this is a coment - * # next line is an option value pair - * width : 100 - * # next line is a flag - * noimages - * - * + Supports printing out Help and Usage - * - * + Why not just use getopt() ? - * - * getopt() Its a POSIX standard not part of ANSI-C. - * So it may not be available on platforms like Windows. - * - * + Why it is so long ? - * - * The actual code which does command line parsing - * and option file parsing are done in few methods. - * Most of the extra code are for providing a flexible - * common public interface to both a resourcefile and - * and command line supporting POSIX style and - * GNU long option as well as mixing of both. - * - * + Please see "anyoption.h" for public method descriptions - * - */ - -/* Updated Auguest 2004 - * Fix from Michael D Peters (mpeters at sandia.gov) - * to remove static local variables, allowing multiple instantiations - * of the reader (for using multiple configuration files). There is - * an error in the destructor when using multiple instances, so you - * cannot delete your objects (it will crash), but not calling the - * destructor only introduces a small memory leak, so I - * have not bothered tracking it down. - * - * Also updated to use modern C++ style headers, rather than - * depricated iostream.h (it was causing my compiler problems) -*/ - -/* - * Updated September 2006 - * Fix from Boyan Asenov for a bug in mixing up option indexes - * leading to exception when mixing different options types - */ - -#include "AnyOption.h" - - - -AnyOption::AnyOption() -{ - init(); -} - -AnyOption::AnyOption(int maxopt) -{ - init( maxopt , maxopt ); -} - -AnyOption::AnyOption(int maxopt, int maxcharopt) -{ - init( maxopt , maxcharopt ); -} - -AnyOption::~AnyOption() -{ - if( mem_allocated ) - cleanup(); -} - -void -AnyOption::init() -{ - init( DEFAULT_MAXOPTS , DEFAULT_MAXOPTS ); -} - -void -AnyOption::init(int maxopt, int maxcharopt ) -{ - - max_options = maxopt; - max_char_options = maxcharopt; - max_usage_lines = DEFAULT_MAXUSAGE; - usage_lines = 0 ; - argc = 0; - argv = NULL; - posix_style = true; - verbose = false; - filename = NULL; - appname = NULL; - option_counter = 0; - optchar_counter = 0; - new_argv = NULL; - new_argc = 0 ; - max_legal_args = 0 ; - command_set = false; - file_set = false; - values = NULL; - g_value_counter = 0; - mem_allocated = false; - command_set = false; - file_set = false; - opt_prefix_char = '-'; - file_delimiter_char = ':'; - file_comment_char = '#'; - equalsign = '='; - comment = '#' ; - delimiter = ':' ; - endofline = '\n'; - whitespace = ' ' ; - nullterminate = '\0'; - set = false; - once = true; - hasoptions = false; - autousage = false; - - strcpy( long_opt_prefix , "--" ); - - if( alloc() == false ){ - cout << endl << "OPTIONS ERROR : Failed allocating memory" ; - cout << endl ; - cout << "Exiting." << endl ; - exit (0); - } -} - -bool -AnyOption::alloc() -{ - int i = 0 ; - int size = 0 ; - - if( mem_allocated ) - return true; - - size = (max_options+1) * sizeof(const char*); - options = (const char**)malloc( size ); - optiontype = (int*) malloc( (max_options+1)*sizeof(int) ); - optionindex = (int*) malloc( (max_options+1)*sizeof(int) ); - if( options == NULL || optiontype == NULL || optionindex == NULL ) - return false; - else - mem_allocated = true; - for( i = 0 ; i < max_options ; i++ ){ - options[i] = NULL; - optiontype[i] = 0 ; - optionindex[i] = -1 ; - } - optionchars = (char*) malloc( (max_char_options+1)*sizeof(char) ); - optchartype = (int*) malloc( (max_char_options+1)*sizeof(int) ); - optcharindex = (int*) malloc( (max_char_options+1)*sizeof(int) ); - if( optionchars == NULL || - optchartype == NULL || - optcharindex == NULL ) - { - mem_allocated = false; - return false; - } - for( i = 0 ; i < max_char_options ; i++ ){ - optionchars[i] = '0'; - optchartype[i] = 0 ; - optcharindex[i] = -1 ; - } - - size = (max_usage_lines+1) * sizeof(const char*) ; - usage = (const char**) malloc( size ); - - if( usage == NULL ){ - mem_allocated = false; - return false; - } - for( i = 0 ; i < max_usage_lines ; i++ ) - usage[i] = NULL; - - return true; -} - -bool -AnyOption::doubleOptStorage() -{ - options = (const char**)realloc( options, - ((2*max_options)+1) * sizeof( const char*) ); - optiontype = (int*) realloc( optiontype , - ((2 * max_options)+1)* sizeof(int) ); - optionindex = (int*) realloc( optionindex, - ((2 * max_options)+1) * sizeof(int) ); - if( options == NULL || optiontype == NULL || optionindex == NULL ) - return false; - /* init new storage */ - for( int i = max_options ; i < 2*max_options ; i++ ){ - options[i] = NULL; - optiontype[i] = 0 ; - optionindex[i] = -1 ; - } - max_options = 2 * max_options ; - return true; -} - -bool -AnyOption::doubleCharStorage() -{ - optionchars = (char*) realloc( optionchars, - ((2*max_char_options)+1)*sizeof(char) ); - optchartype = (int*) realloc( optchartype, - ((2*max_char_options)+1)*sizeof(int) ); - optcharindex = (int*) realloc( optcharindex, - ((2*max_char_options)+1)*sizeof(int) ); - if( optionchars == NULL || - optchartype == NULL || - optcharindex == NULL ) - return false; - /* init new storage */ - for( int i = max_char_options ; i < 2*max_char_options ; i++ ){ - optionchars[i] = '0'; - optchartype[i] = 0 ; - optcharindex[i] = -1 ; - } - max_char_options = 2 * max_char_options; - return true; -} - -bool -AnyOption::doubleUsageStorage() -{ - usage = (const char**)realloc( usage, - ((2*max_usage_lines)+1) * sizeof( const char*) ); - if ( usage == NULL ) - return false; - for( int i = max_usage_lines ; i < 2*max_usage_lines ; i++ ) - usage[i] = NULL; - max_usage_lines = 2 * max_usage_lines ; - return true; - -} - - -void -AnyOption::cleanup() -{ - free (options); - free (optiontype); - free (optionindex); - free (optionchars); - free (optchartype); - free (optcharindex); - free (usage); - if( values != NULL ) - free (values); - if( new_argv != NULL ) - free (new_argv); -} - -void -AnyOption::setCommandPrefixChar( char _prefix ) -{ - opt_prefix_char = _prefix; -} - -void -AnyOption::setCommandLongPrefix( char *_prefix ) -{ - if( strlen( _prefix ) > MAX_LONG_PREFIX_LENGTH ){ - *( _prefix + MAX_LONG_PREFIX_LENGTH ) = '\0'; - } - - strcpy (long_opt_prefix, _prefix); -} - -void -AnyOption::setFileCommentChar( char _comment ) -{ - file_delimiter_char = _comment; -} - - -void -AnyOption::setFileDelimiterChar( char _delimiter ) -{ - file_comment_char = _delimiter ; -} - -bool -AnyOption::CommandSet() -{ - return( command_set ); -} - -bool -AnyOption::FileSet() -{ - return( file_set ); -} - -void -AnyOption::noPOSIX() -{ - posix_style = false; -} - -bool -AnyOption::POSIX() -{ - return posix_style; -} - - -void -AnyOption::setVerbose() -{ - verbose = true ; -} - -void -AnyOption::printVerbose() -{ - if( verbose ) - cout << endl ; -} -void -AnyOption::printVerbose( const char *msg ) -{ - if( verbose ) - cout << msg ; -} - -void -AnyOption::printVerbose( char *msg ) -{ - if( verbose ) - cout << msg ; -} - -void -AnyOption::printVerbose( char ch ) -{ - if( verbose ) - cout << ch ; -} - -bool -AnyOption::hasOptions() -{ - return hasoptions; -} - -void -AnyOption::autoUsagePrint(bool _autousage) -{ - autousage = _autousage; -} - -void -AnyOption::useCommandArgs( int _argc, char **_argv ) -{ - argc = _argc; - argv = _argv; - command_set = true; - appname = argv[0]; - if(argc > 1) hasoptions = true; -} - -void -AnyOption::useFiileName( const char *_filename ) -{ - filename = _filename; - file_set = true; -} - -/* - * set methods for options - */ - -void -AnyOption::setCommandOption( const char *opt ) -{ - addOption( opt , COMMAND_OPT ); - g_value_counter++; -} - -void -AnyOption::setCommandOption( char opt ) -{ - addOption( opt , COMMAND_OPT ); - g_value_counter++; -} - -void -AnyOption::setCommandOption( const char *opt , char optchar ) -{ - addOption( opt , COMMAND_OPT ); - addOption( optchar , COMMAND_OPT ); - g_value_counter++; -} - -void -AnyOption::setCommandFlag( const char *opt ) -{ - addOption( opt , COMMAND_FLAG ); - g_value_counter++; -} - -void -AnyOption::setCommandFlag( char opt ) -{ - addOption( opt , COMMAND_FLAG ); - g_value_counter++; -} - -void -AnyOption::setCommandFlag( const char *opt , char optchar ) -{ - addOption( opt , COMMAND_FLAG ); - addOption( optchar , COMMAND_FLAG ); - g_value_counter++; -} - -void -AnyOption::setFileOption( const char *opt ) -{ - addOption( opt , FILE_OPT ); - g_value_counter++; -} - -void -AnyOption::setFileOption( char opt ) -{ - addOption( opt , FILE_OPT ); - g_value_counter++; -} - -void -AnyOption::setFileOption( const char *opt , char optchar ) -{ - addOption( opt , FILE_OPT ); - addOption( optchar, FILE_OPT ); - g_value_counter++; -} - -void -AnyOption::setFileFlag( const char *opt ) -{ - addOption( opt , FILE_FLAG ); - g_value_counter++; -} - -void -AnyOption::setFileFlag( char opt ) -{ - addOption( opt , FILE_FLAG ); - g_value_counter++; -} - -void -AnyOption::setFileFlag( const char *opt , char optchar ) -{ - addOption( opt , FILE_FLAG ); - addOption( optchar , FILE_FLAG ); - g_value_counter++; -} - -void -AnyOption::setOption( const char *opt ) -{ - addOption( opt , COMMON_OPT ); - g_value_counter++; -} - -void -AnyOption::setOption( char opt ) -{ - addOption( opt , COMMON_OPT ); - g_value_counter++; -} - -void -AnyOption::setOption( const char *opt , char optchar ) -{ - addOption( opt , COMMON_OPT ); - addOption( optchar , COMMON_OPT ); - g_value_counter++; -} - -void -AnyOption::setFlag( const char *opt ) -{ - addOption( opt , COMMON_FLAG ); - g_value_counter++; -} - -void -AnyOption::setFlag( const char opt ) -{ - addOption( opt , COMMON_FLAG ); - g_value_counter++; -} - -void -AnyOption::setFlag( const char *opt , char optchar ) -{ - addOption( opt , COMMON_FLAG ); - addOption( optchar , COMMON_FLAG ); - g_value_counter++; -} - -void -AnyOption::addOption( const char *opt, int type ) -{ - if( option_counter >= max_options ){ - if( doubleOptStorage() == false ){ - addOptionError( opt ); - return; - } - } - options[ option_counter ] = opt ; - optiontype[ option_counter ] = type ; - optionindex[ option_counter ] = g_value_counter; - option_counter++; -} - -void -AnyOption::addOption( char opt, int type ) -{ - if( !POSIX() ){ - printVerbose("Ignoring the option character \""); - printVerbose( opt ); - printVerbose( "\" ( POSIX options are turned off )" ); - printVerbose(); - return; - } - - - if( optchar_counter >= max_char_options ){ - if( doubleCharStorage() == false ){ - addOptionError( opt ); - return; - } - } - optionchars[ optchar_counter ] = opt ; - optchartype[ optchar_counter ] = type ; - optcharindex[ optchar_counter ] = g_value_counter; - optchar_counter++; -} - -void -AnyOption::addOptionError( const char *opt ) -{ - cout << endl ; - cout << "OPTIONS ERROR : Failed allocating extra memory " << endl ; - cout << "While adding the option : \""<< opt << "\"" << endl; - cout << "Exiting." << endl ; - cout << endl ; - exit(0); -} - -void -AnyOption::addOptionError( char opt ) -{ - cout << endl ; - cout << "OPTIONS ERROR : Failed allocating extra memory " << endl ; - cout << "While adding the option: \""<< opt << "\"" << endl; - cout << "Exiting." << endl ; - cout << endl ; - exit(0); -} - -void -AnyOption::processOptions() -{ - if( ! valueStoreOK() ) - return; -} - -void -AnyOption::processCommandArgs(int max_args) -{ - max_legal_args = max_args; - processCommandArgs(); -} - -void -AnyOption::processCommandArgs( int _argc, char **_argv, int max_args ) -{ - max_legal_args = max_args; - processCommandArgs( _argc, _argv ); -} - -void -AnyOption::processCommandArgs( int _argc, char **_argv ) -{ - useCommandArgs( _argc, _argv ); - processCommandArgs(); -} - -void -AnyOption::processCommandArgs() -{ - if( ! ( valueStoreOK() && CommandSet() ) ) - return; - - if( max_legal_args == 0 ) - max_legal_args = argc; - new_argv = (int*) malloc( (max_legal_args+1) * sizeof(int) ); - for( int i = 1 ; i < argc ; i++ ){/* ignore first argv */ - if( argv[i][0] == long_opt_prefix[0] && - argv[i][1] == long_opt_prefix[1] ) { /* long GNU option */ - int match_at = parseGNU( argv[i]+2 ); /* skip -- */ - if( match_at >= 0 && i < argc-1 ) /* found match */ - setValue( options[match_at] , argv[++i] ); - }else if( argv[i][0] == opt_prefix_char ) { /* POSIX char */ - if( POSIX() ){ - char ch = parsePOSIX( argv[i]+1 );/* skip - */ - if( ch != '0' && i < argc-1 ) /* matching char */ - setValue( ch , argv[++i] ); - } else { /* treat it as GNU option with a - */ - int match_at = parseGNU( argv[i]+1 ); /* skip - */ - if( match_at >= 0 && i < argc-1 ) /* found match */ - setValue( options[match_at] , argv[++i] ); - } - }else { /* not option but an argument keep index */ - if( new_argc < max_legal_args ){ - new_argv[ new_argc ] = i ; - new_argc++; - }else{ /* ignore extra arguments */ - printVerbose( "Ignoring extra argument: " ); - printVerbose( argv[i] ); - printVerbose( ); - printAutoUsage(); - } - printVerbose( "Unknown command argument option : " ); - printVerbose( argv[i] ); - printVerbose( ); - printAutoUsage(); - } - } -} - -char -AnyOption::parsePOSIX( char* arg ) -{ - - for( unsigned int i = 0 ; i < strlen(arg) ; i++ ){ - char ch = arg[i] ; - if( matchChar(ch) ) { /* keep matching flags till an option */ - /*if last char argv[++i] is the value */ - if( i == strlen(arg)-1 ){ - return ch; - }else{/* else the rest of arg is the value */ - i++; /* skip any '=' and ' ' */ - while( arg[i] == whitespace - || arg[i] == equalsign ) - i++; - setValue( ch , arg+i ); - return '0'; - } - } - } - printVerbose( "Unknown command argument option : " ); - printVerbose( arg ); - printVerbose( ); - printAutoUsage(); - return '0'; -} - -int -AnyOption::parseGNU( char *arg ) -{ - int split_at = 0; - /* if has a '=' sign get value */ - for( unsigned int i = 0 ; i < strlen(arg) ; i++ ){ - if(arg[i] == equalsign ){ - split_at = i ; /* store index */ - i = strlen(arg); /* get out of loop */ - } - } - if( split_at > 0 ){ /* it is an option value pair */ - char* tmp = (char*) malloc( (split_at+1)*sizeof(char) ); - for( int i = 0 ; i < split_at ; i++ ) - tmp[i] = arg[i]; - tmp[split_at] = '\0'; - - if ( matchOpt( tmp ) >= 0 ){ - setValue( options[matchOpt(tmp)] , arg+split_at+1 ); - free (tmp); - }else{ - printVerbose( "Unknown command argument option : " ); - printVerbose( arg ); - printVerbose( ); - printAutoUsage(); - free (tmp); - return -1; - } - }else{ /* regular options with no '=' sign */ - return matchOpt(arg); - } - return -1; -} - - -int -AnyOption::matchOpt( char *opt ) -{ - for( int i = 0 ; i < option_counter ; i++ ){ - if( strcmp( options[i], opt ) == 0 ){ - if( optiontype[i] == COMMON_OPT || - optiontype[i] == COMMAND_OPT ) - { /* found option return index */ - return i; - }else if( optiontype[i] == COMMON_FLAG || - optiontype[i] == COMMAND_FLAG ) - { /* found flag, set it */ - setFlagOn( opt ); - return -1; - } - } - } - printVerbose( "Unknown command argument option : " ); - printVerbose( opt ) ; - printVerbose( ); - printAutoUsage(); - return -1; -} -bool -AnyOption::matchChar( char c ) -{ - for( int i = 0 ; i < optchar_counter ; i++ ){ - if( optionchars[i] == c ) { /* found match */ - if(optchartype[i] == COMMON_OPT || - optchartype[i] == COMMAND_OPT ) - { /* an option store and stop scanning */ - return true; - }else if( optchartype[i] == COMMON_FLAG || - optchartype[i] == COMMAND_FLAG ) { /* a flag store and keep scanning */ - setFlagOn( c ); - return false; - } - } - } - printVerbose( "Unknown command argument option : " ); - printVerbose( c ) ; - printVerbose( ); - printAutoUsage(); - return false; -} - -bool -AnyOption::valueStoreOK( ) -{ - int size= 0; - if( !set ){ - if( g_value_counter > 0 ){ - size = g_value_counter * sizeof(char*); - values = (char**)malloc( size ); - for( int i = 0 ; i < g_value_counter ; i++) - values[i] = NULL; - set = true; - } - } - return set; -} - -/* - * public get methods - */ -char* -AnyOption::getValue( const char *option ) -{ - if( !valueStoreOK() ) - return NULL; - - for( int i = 0 ; i < option_counter ; i++ ){ - if( strcmp( options[i], option ) == 0 ) - return values[ optionindex[i] ]; - } - return NULL; -} - -bool -AnyOption::getFlag( const char *option ) -{ - if( !valueStoreOK() ) - return false; - for( int i = 0 ; i < option_counter ; i++ ){ - if( strcmp( options[i], option ) == 0 ) - return findFlag( values[ optionindex[i] ] ); - } - return false; -} - -char* -AnyOption::getValue( char option ) -{ - if( !valueStoreOK() ) - return NULL; - for( int i = 0 ; i < optchar_counter ; i++ ){ - if( optionchars[i] == option ) - return values[ optcharindex[i] ]; - } - return NULL; -} - -bool -AnyOption::getFlag( char option ) -{ - if( !valueStoreOK() ) - return false; - for( int i = 0 ; i < optchar_counter ; i++ ){ - if( optionchars[i] == option ) - return findFlag( values[ optcharindex[i] ] ) ; - } - return false; -} - -bool -AnyOption::findFlag( char* val ) -{ - if( val == NULL ) - return false; - - if( strcmp( TRUE_FLAG , val ) == 0 ) - return true; - - return false; -} - -/* - * private set methods - */ -bool -AnyOption::setValue( const char *option , char *value ) -{ - if( !valueStoreOK() ) - return false; - for( int i = 0 ; i < option_counter ; i++ ){ - if( strcmp( options[i], option ) == 0 ){ - values[ optionindex[i] ] = (char*) malloc((strlen(value)+1)*sizeof(char)); - strcpy( values[ optionindex[i] ], value ); - return true; - } - } - return false; -} - -bool -AnyOption::setFlagOn( const char *option ) -{ - if( !valueStoreOK() ) - return false; - for( int i = 0 ; i < option_counter ; i++ ){ - if( strcmp( options[i], option ) == 0 ){ - values[ optionindex[i] ] = (char*) malloc((strlen(TRUE_FLAG)+1)*sizeof(char)); - strcpy( values[ optionindex[i] ] , TRUE_FLAG ); - return true; - } - } - return false; -} - -bool -AnyOption::setValue( char option , char *value ) -{ - if( !valueStoreOK() ) - return false; - for( int i = 0 ; i < optchar_counter ; i++ ){ - if( optionchars[i] == option ){ - values[ optcharindex[i] ] = (char*) malloc((strlen(value)+1)*sizeof(char)); - strcpy( values[ optcharindex[i] ], value ); - return true; - } - } - return false; -} - -bool -AnyOption::setFlagOn( char option ) -{ - if( !valueStoreOK() ) - return false; - for( int i = 0 ; i < optchar_counter ; i++ ){ - if( optionchars[i] == option ){ - values[ optcharindex[i] ] = (char*) malloc((strlen(TRUE_FLAG)+1)*sizeof(char)); - strcpy( values[ optcharindex[i] ] , TRUE_FLAG ); - return true; - } - } - return false; -} - - -int -AnyOption::getArgc( ) -{ - return new_argc; -} - -char* -AnyOption::getArgv( int index ) -{ - if( index < new_argc ){ - return ( argv[ new_argv[ index ] ] ); - } - return NULL; -} - -/* dotfile sub routines */ - -bool -AnyOption::processFile() -{ - if( ! (valueStoreOK() && FileSet()) ) - return false; - return ( consumeFile(readFile()) ); -} - -bool -AnyOption::processFile( const char *filename ) -{ - useFiileName(filename ); - return ( processFile() ); -} - -char* -AnyOption::readFile() -{ - return ( readFile(filename) ); -} - -/* - * read the file contents to a character buffer - */ - -char* -AnyOption::readFile( const char* fname ) -{ - int length; - char *buffer; - ifstream is; - is.open ( fname , ifstream::in ); - if( ! is.good() ){ - is.close(); - return NULL; - } - is.seekg (0, ios::end); - length = is.tellg(); - is.seekg (0, ios::beg); - buffer = (char*) malloc(length*sizeof(char)); - is.read (buffer,length); - is.close(); - return buffer; -} - -/* - * scans a char* buffer for lines that does not - * start with the specified comment character. - */ -bool -AnyOption::consumeFile( char *buffer ) -{ - - if( buffer == NULL ) - return false; - - char *cursor = buffer;/* preserve the ptr */ - char *pline = NULL ; - int linelength = 0; - bool newline = true; - for( unsigned int i = 0 ; i < strlen( buffer ) ; i++ ){ - if( *cursor == endofline ) { /* end of line */ - if( pline != NULL ) /* valid line */ - processLine( pline, linelength ); - pline = NULL; - newline = true; - }else if( newline ){ /* start of line */ - newline = false; - if( (*cursor != comment ) ){ /* not a comment */ - pline = cursor ; - linelength = 0 ; - } - } - cursor++; /* keep moving */ - linelength++; - } - free (buffer); - return true; -} - - -/* - * find a valid type value pair separated by a delimiter - * character and pass it to valuePairs() - * any line which is not valid will be considered a value - * and will get passed on to justValue() - * - * assuming delimiter is ':' the behaviour will be, - * - * width:10 - valid pair valuePairs( width, 10 ); - * width : 10 - valid pair valuepairs( width, 10 ); - * - * :::: - not valid - * width - not valid - * :10 - not valid - * width: - not valid - * :: - not valid - * : - not valid - * - */ - -void -AnyOption::processLine( char *theline, int length ) -{ - bool found = false; - char *pline = (char*) malloc( (length+1)*sizeof(char) ); - for( int i = 0 ; i < length ; i ++ ) - pline[i]= *(theline++); - pline[length] = nullterminate; - char *cursor = pline ; /* preserve the ptr */ - if( *cursor == delimiter || *(cursor+length-1) == delimiter ){ - justValue( pline );/* line with start/end delimiter */ - }else{ - for( int i = 1 ; i < length-1 && !found ; i++){/* delimiter */ - if( *cursor == delimiter ){ - *(cursor-1) = nullterminate; /* two strings */ - found = true; - valuePairs( pline , cursor+1 ); - } - cursor++; - } - cursor++; - if( !found ) /* not a pair */ - justValue( pline ); - } - free (pline); -} - -/* - * removes trailing and preceeding whitespaces from a string - */ -char* -AnyOption::chomp( char *str ) -{ - while( *str == whitespace ) - str++; - char *end = str+strlen(str)-1; - while( *end == whitespace ) - end--; - *(end+1) = nullterminate; - return str; -} - -void -AnyOption::valuePairs( char *type, char *value ) -{ - if ( strlen(chomp(type)) == 1 ){ /* this is a char option */ - for( int i = 0 ; i < optchar_counter ; i++ ){ - if( optionchars[i] == type[0] ){ /* match */ - if( optchartype[i] == COMMON_OPT || - optchartype[i] == FILE_OPT ) - { - setValue( type[0] , chomp(value) ); - return; - } - } - } - } - /* if no char options matched */ - for( int i = 0 ; i < option_counter ; i++ ){ - if( strcmp( options[i], type ) == 0 ){ /* match */ - if( optiontype[i] == COMMON_OPT || - optiontype[i] == FILE_OPT ) - { - setValue( type , chomp(value) ); - return; - } - } - } - printVerbose( "Unknown option in resourcefile : " ); - printVerbose( type ); - printVerbose( ); -} - -void -AnyOption::justValue( char *type ) -{ - - if ( strlen(chomp(type)) == 1 ){ /* this is a char option */ - for( int i = 0 ; i < optchar_counter ; i++ ){ - if( optionchars[i] == type[0] ){ /* match */ - if( optchartype[i] == COMMON_FLAG || - optchartype[i] == FILE_FLAG ) - { - setFlagOn( type[0] ); - return; - } - } - } - } - /* if no char options matched */ - for( int i = 0 ; i < option_counter ; i++ ){ - if( strcmp( options[i], type ) == 0 ){ /* match */ - if( optiontype[i] == COMMON_FLAG || - optiontype[i] == FILE_FLAG ) - { - setFlagOn( type ); - return; - } - } - } - printVerbose( "Unknown option in resourcefile : " ); - printVerbose( type ); - printVerbose( ); -} - -/* - * usage and help - */ - - -void -AnyOption::printAutoUsage() -{ - if( autousage ) printUsage(); -} - -void -AnyOption::printUsage() -{ - - if( once ) { - once = false ; - cout << endl ; - for( int i = 0 ; i < usage_lines ; i++ ) - cout << usage[i] << endl ; - cout << endl ; - } -} - - -void -AnyOption::addUsage( const char *line ) -{ - if( usage_lines >= max_usage_lines ){ - if( doubleUsageStorage() == false ){ - addUsageError( line ); - exit(1); - } - } - usage[ usage_lines ] = line ; - usage_lines++; -} - -void -AnyOption::addUsageError( const char *line ) -{ - cout << endl ; - cout << "OPTIONS ERROR : Failed allocating extra memory " << endl ; - cout << "While adding the usage/help : \""<< line << "\"" << endl; - cout << "Exiting." << endl ; - cout << endl ; - exit(0); - -} diff --git a/AnyOption.h b/AnyOption.h deleted file mode 100644 index adf649f..0000000 --- a/AnyOption.h +++ /dev/null @@ -1,271 +0,0 @@ -#ifndef _ANYOPTION_H -#define _ANYOPTION_H - -#include -#include -#include -#include -#include - -#define COMMON_OPT 1 -#define COMMAND_OPT 2 -#define FILE_OPT 3 -#define COMMON_FLAG 4 -#define COMMAND_FLAG 5 -#define FILE_FLAG 6 - -#define COMMAND_OPTION_TYPE 1 -#define COMMAND_FLAG_TYPE 2 -#define FILE_OPTION_TYPE 3 -#define FILE_FLAG_TYPE 4 -#define UNKNOWN_TYPE 5 - -#define DEFAULT_MAXOPTS 10 -#define MAX_LONG_PREFIX_LENGTH 2 - -#define DEFAULT_MAXUSAGE 3 -#define DEFAULT_MAXHELP 10 - -#define TRUE_FLAG "true" - -using namespace std; - -class AnyOption -{ - -public: /* the public interface */ - AnyOption(); - AnyOption(int maxoptions ); - AnyOption(int maxoptions , int maxcharoptions); - ~AnyOption(); - - /* - * following set methods specifies the - * special characters and delimiters - * if not set traditional defaults will be used - */ - - void setCommandPrefixChar( char _prefix ); /* '-' in "-w" */ - void setCommandLongPrefix( char *_prefix ); /* '--' in "--width" */ - void setFileCommentChar( char _comment ); /* '#' in shellscripts */ - void setFileDelimiterChar( char _delimiter );/* ':' in "width : 100" */ - - /* - * provide the input for the options - * like argv[] for commndline and the - * option file name to use; - */ - - void useCommandArgs( int _argc, char **_argv ); - void useFiileName( const char *_filename ); - - /* - * turn off the POSIX style options - * this means anything starting with a '-' or "--" - * will be considered a valid option - * which alo means you cannot add a bunch of - * POIX options chars together like "-lr" for "-l -r" - * - */ - - void noPOSIX(); - - /* - * prints warning verbose if you set anything wrong - */ - void setVerbose(); - - - /* - * there are two types of options - * - * Option - has an associated value ( -w 100 ) - * Flag - no value, just a boolean flag ( -nogui ) - * - * the options can be either a string ( GNU style ) - * or a character ( traditional POSIX style ) - * or both ( --width, -w ) - * - * the options can be common to the commandline and - * the optionfile, or can belong only to either of - * commandline and optionfile - * - * following set methods, handle all the aboove - * cases of options. - */ - - /* options comman to command line and option file */ - void setOption( const char *opt_string ); - void setOption( char opt_char ); - void setOption( const char *opt_string , char opt_char ); - void setFlag( const char *opt_string ); - void setFlag( char opt_char ); - void setFlag( const char *opt_string , char opt_char ); - - /* options read from commandline only */ - void setCommandOption( const char *opt_string ); - void setCommandOption( char opt_char ); - void setCommandOption( const char *opt_string , char opt_char ); - void setCommandFlag( const char *opt_string ); - void setCommandFlag( char opt_char ); - void setCommandFlag( const char *opt_string , char opt_char ); - - /* options read from an option file only */ - void setFileOption( const char *opt_string ); - void setFileOption( char opt_char ); - void setFileOption( const char *opt_string , char opt_char ); - void setFileFlag( const char *opt_string ); - void setFileFlag( char opt_char ); - void setFileFlag( const char *opt_string , char opt_char ); - - /* - * process the options, registerd using - * useCommandArgs() and useFileName(); - */ - void processOptions(); - void processCommandArgs(); - void processCommandArgs( int max_args ); - bool processFile(); - - /* - * process the specified options - */ - void processCommandArgs( int _argc, char **_argv ); - void processCommandArgs( int _argc, char **_argv, int max_args ); - bool processFile( const char *_filename ); - - /* - * get the value of the options - * will return NULL if no value is set - */ - char *getValue( const char *_option ); - bool getFlag( const char *_option ); - char *getValue( char _optchar ); - bool getFlag( char _optchar ); - - /* - * Print Usage - */ - void printUsage(); - void printAutoUsage(); - void addUsage( const char *line ); - void printHelp(); - /* print auto usage printing for unknown options or flag */ - void autoUsagePrint(bool flag); - - /* - * get the argument count and arguments sans the options - */ - int getArgc(); - char* getArgv( int index ); - bool hasOptions(); - -private: /* the hidden data structure */ - int argc; /* commandline arg count */ - char **argv; /* commndline args */ - const char* filename; /* the option file */ - char* appname; /* the application name from argv[0] */ - - int *new_argv; /* arguments sans options (index to argv) */ - int new_argc; /* argument count sans the options */ - int max_legal_args; /* ignore extra arguments */ - - - /* option strings storage + indexing */ - int max_options; /* maximum number of options */ - const char **options; /* storage */ - int *optiontype; /* type - common, command, file */ - int *optionindex; /* index into value storage */ - int option_counter; /* counter for added options */ - - /* option chars storage + indexing */ - int max_char_options; /* maximum number options */ - char *optionchars; /* storage */ - int *optchartype; /* type - common, command, file */ - int *optcharindex; /* index into value storage */ - int optchar_counter; /* counter for added options */ - - /* values */ - char **values; /* common value storage */ - int g_value_counter; /* globally updated value index LAME! */ - - /* help and usage */ - const char **usage; /* usage */ - int max_usage_lines; /* max usage lines reseverd */ - int usage_lines; /* number of usage lines */ - - bool command_set; /* if argc/argv were provided */ - bool file_set; /* if a filename was provided */ - bool mem_allocated; /* if memory allocated in init() */ - bool posix_style; /* enables to turn off POSIX style options */ - bool verbose; /* silent|verbose */ - bool print_usage; /* usage verbose */ - bool print_help; /* help verbose */ - - char opt_prefix_char; /* '-' in "-w" */ - char long_opt_prefix[MAX_LONG_PREFIX_LENGTH]; /* '--' in "--width" */ - char file_delimiter_char; /* ':' in width : 100 */ - char file_comment_char; /* '#' in "#this is a comment" */ - char equalsign; - char comment; - char delimiter; - char endofline; - char whitespace; - char nullterminate; - - bool set; //was static member - bool once; //was static member - - bool hasoptions; - bool autousage; - -private: /* the hidden utils */ - void init(); - void init(int maxopt, int maxcharopt ); - bool alloc(); - void cleanup(); - bool valueStoreOK(); - - /* grow storage arrays as required */ - bool doubleOptStorage(); - bool doubleCharStorage(); - bool doubleUsageStorage(); - - bool setValue( const char *option , char *value ); - bool setFlagOn( const char *option ); - bool setValue( char optchar , char *value); - bool setFlagOn( char optchar ); - - void addOption( const char* option , int type ); - void addOption( char optchar , int type ); - void addOptionError( const char *opt); - void addOptionError( char opt); - bool findFlag( char* value ); - void addUsageError( const char *line ); - bool CommandSet(); - bool FileSet(); - bool POSIX(); - - char parsePOSIX( char* arg ); - int parseGNU( char *arg ); - bool matchChar( char c ); - int matchOpt( char *opt ); - - /* dot file methods */ - char *readFile(); - char *readFile( const char* fname ); - bool consumeFile( char *buffer ); - void processLine( char *theline, int length ); - char *chomp( char *str ); - void valuePairs( char *type, char *value ); - void justValue( char *value ); - - void printVerbose( const char *msg ); - void printVerbose( char *msg ); - void printVerbose( char ch ); - void printVerbose( ); - - -}; - -#endif /* ! _ANYOPTION_H */ diff --git a/DASHEncoder.config b/DASHEncoder.config deleted file mode 100644 index c192928..0000000 --- a/DASHEncoder.config +++ /dev/null @@ -1,95 +0,0 @@ -#======================================== -# Config File for DASH Encoder -#======================================== - -#======================================== -# General Options -#======================================== - -dest-directory : /opt/lampp/htdocs/tests_updates/ - - -video-encoder : x264 -audio-encoder : ffmpegAAC -multiplexer : mp4box - -#store-psnr -sql-host : localhost -sql-user : root -sql-pw : -sql-database : dash - -add-non-segmented - -#use-ffmpeg-pipe -ffmpeg-opt : -f rawvideo -#input-res : 384x208 -#input-res : 352x288 -input-res : 854x480 -#======================================== -# x264 Options -#======================================== - -bitrate : 300 - -#bitrate : 250@480x360|500@480x360|1000 -#bitrate : 200|400|600|1000 -statistics : stat.temp -gop : 48 -scenecut : 0 -profile : baseline -preset : slow -input : /home/stefan/sintel_trailer_2k_480p24.y4m -#input : /home/stefan/foreman_cif.y4m -#input : /home/stefan/kingkong.mp4 -#input : /media/Volume/MI200802010028-video_newsroom_hd_1080_p29_97-channelSelectionT0C0_T0C1.mp4 -passes : 1 -const-filesize : 0 - -#Additional Options for Encoding - -#pass1 : --frames 500 --fps 29.970029 -pass1 : --verbose --fps 24 -pass2 : --verbose --psnr - -#======================================== -# FFMPEG AAC Options -#======================================== - -# [channels, samplerate, bitrate] -#audio-quality : 2,44100,48|2,44000,128 -#audio-quality : 2,44100,48 -audio-quality : - -audio-input : /home/stefan/sintel_trailer-audio.flac -audio-codec : libfaac - -#======================================== -# MP4Box Options -#======================================== - -#AV Muxing -#mux-combi : 300@48|600@128 -mux-combi : - -fragment-size : 2000 -segment-size : 2000 -rap-aligned -segment-name : sintel -folder-prefix : sintel - - -#======================================== -# MPD Options -#======================================== -mpd-name : sintel.mpd -url-root : http://localhost/tests_updates/ -#set-base-url -mpdActStandardPostfix : _actVersion.mpd -duration : 9M4S -transform-mpd -minBufferTime : 2.0S -segDuration : 2 -#======================================== -# Other Options -#======================================== diff --git a/DASHEncoder.cpp b/DASHEncoder.cpp deleted file mode 100644 index 9f24886..0000000 --- a/DASHEncoder.cpp +++ /dev/null @@ -1,772 +0,0 @@ -#include "AnyOption.h" -#include "multiplexer/MP4BoxMultiplexer.h" -#include "encoder/IEncoder.h" -#include "encoder/AbstractAudioEncoder.h" -#include "encoder/AbstractVideoEncoder.h" -#include "encoder/EncoderFactory.h" -#include "mpdgenerator/MPDGenerator.h" - -#include -#include -#include -#include -//#include "mysql/mysql.h" - -void parse(int argc, char* argv[]); -void setHelp(AnyOption*); -void setOptions(AnyOption*); -IEncoder::EncoderType getEncoder(std::string); -int convertMPD(std::string input, std::string output, std::string duration, std::string baseurl, std::string minbuffer, std::string segduration); - -AnyOption *opt; - -int main(int argc, char* argv[]) -{ - parse(argc, argv); - return 0; -} - -void parse(int argc, char* argv[]) -{ - std::cout << "==========DASH ENCODER===============\n"; - AnyOption *opt = new AnyOption(); - - /* COMMAND LINE PREFERENCES */ - opt->setVerbose(); /* print warnings about unknown options */ - opt->autoUsagePrint(true); /* print usage for bad options */ - - /* SET THE USAGE/HELP */ - setHelp(opt); - - /* SET THE OPTION STRINGS/CHARACTERS */ - - setOptions(opt); - - /* PROCESS THE RESOURCE FILE */ - opt->processFile("./DASHEncoder.config"); - /* PROCESS THE COMMANDLINE */ - opt->processCommandArgs(argc, argv); - - /* Run DASH Encoding */ - - EncoderFactory* encoder_factory= new EncoderFactory(); - std::cout << "current encoder " << opt->getValue("video-encoder") << "\n"; - if(getEncoder(opt->getValue("video-encoder")) == IEncoder::x264) - std::cout << "YES\n"; - - AbstractVideoEncoder* e = (AbstractVideoEncoder*)encoder_factory->getEncoder(opt, getEncoder(opt->getValue("video-encoder"))); - AbstractAudioEncoder* a = (AbstractAudioEncoder*)encoder_factory->getEncoder(opt, getEncoder(opt->getValue("audio-encoder"))); - - MPDGenerator* mpdgen = new MPDGenerator(); - MPDGenerator* mpdgenNonSeg = new MPDGenerator(); - MP4BoxMultiplexer* m = new MP4BoxMultiplexer(); - - std::map audio_files; - std::map av_mux_mapping; - - /* MySQL Support Disabled - - MYSQL_RES *result; - - MYSQL_ROW row; - - MYSQL *connection, mysql; - - */ - - int state; - - m->setFragSize(atoi(opt->getValue("fragment-size"))); - m->setRAPAligned(opt->getFlag("rap-aligned")); - m->setOutputDir(opt->getValue("dest-directory")); - m->setSegSize(atoi(opt->getValue("segment-size"))); - - std::string h264file; - vector mpds; - std::string folder; - std::string foldername; - std::string h264new; - ifstream infile; - std::string finalMPDhead = ""; - std::string finalMPDbody = ""; - std::string finalMPDfoot = ""; - std::string video_length = ""; - - std::string baseURL = ""; - - std::string exp_name = opt->getValue("dest-directory"); - exp_name.append(opt->getValue("mpd-name")); - - std::string exp_nameNonSeg = opt->getValue("dest-directory"); - exp_nameNonSeg.append("NonSeg"); - exp_nameNonSeg.append(opt->getValue("mpd-name")); - - ofstream mpdexportfile; - mpdexportfile.open(exp_name.c_str()); - - ofstream mpdexportfileNonSeg; - mpdexportfileNonSeg.open(exp_nameNonSeg.c_str()); - - - std::string act = ""; - std::string mpd_temp; - std::string act_line; - std::string act_rep; - - if(opt->getFlag("set-base-url")){ - baseURL = ""; - baseURL.append(opt->getValue("url-root")); - baseURL.append(""); - } - - /************* AUDIO/VIDEO MULTIPLEXING INFORMATION ******************************/ - - if(opt->getValue("mux-combi")!=NULL){ - std::string muxconfig = opt->getValue("mux-combi"); - std::string currentaudio; - std::string bitrates; - do{ - bitrates = muxconfig.substr(0,muxconfig.find('@')); - if(muxconfig.find('|') == std::string::npos){ - currentaudio = muxconfig.substr(muxconfig.find('@')+1); - muxconfig = ""; - } - else{ - currentaudio = muxconfig.substr(muxconfig.find('@')+1, muxconfig.find('|') ); - muxconfig = muxconfig.substr(muxconfig.find('|')+1); - } - do{ - if(bitrates.find(',') == std::string::npos){ - av_mux_mapping[atoi(bitrates.c_str())] = atoi(currentaudio.c_str()); - bitrates = ""; - } - else{ - av_mux_mapping[atoi(bitrates.substr(0,',').c_str())] = atoi(currentaudio.c_str()); - bitrates = bitrates.substr(bitrates.find(',')+1); - } - }while(bitrates.size()>0); - }while(muxconfig.size()>0); - } - - /************************ AUDIO PROCESSING ******************************/ - std::string audio_quality = opt->getValue("audio-quality"); - char*c2 = (char*) malloc(audio_quality.length() * sizeof(char)); - strcpy(c2, audio_quality.c_str()); - char* act_audio = strtok(c2, "|"); - - std::string act_quality = ""; - std::string act_audio_encoding; - std::string act_audio_seg; - - while (act_audio != NULL) - { - - act_quality = act_audio; - a->setChannels(atoi(act_quality.substr(0, act_quality.find(',')).c_str())); - - act_quality = act_quality.substr(act_quality.find(',') + 1); - a->setSamplingRate(atoi(act_quality.substr(0, act_quality.find(',')).c_str())); - - a->setBitrate(atoi(act_quality.substr(act_quality.find(',') + 1).c_str())); - - act_audio_encoding = a->encode(); - - audio_files[a->getBitrate()] = act_audio_encoding; - - if (opt->getValue("mux-combi") == NULL) - { - /************ FOLDER CREATION **********************/ - - foldername = opt->getValue("folder-prefix"); - foldername.append("_"); - foldername.append(DASHHelper::itos(a->getChannels())); - foldername.append("ch_audio_"); - foldername.append(DASHHelper::itos(a->getBitrate())); - foldername.append("kbit"); - - folder = "mkdir "; - folder.append(opt->getValue("dest-directory")); - folder.append(foldername); - system(folder.c_str()); - - folder = "mv "; - folder.append(opt->getValue("dest-directory")); - folder.append(act_audio_encoding); - folder.append(" "); - folder.append(opt->getValue("dest-directory")); - folder.append(foldername); - system(folder.c_str()); - - /************ MULTIPLEXING & SEGMENTATION **************/ - - act_audio_seg = opt->getValue("dest-directory"); - act_audio_seg.append(foldername); - act_audio_seg.append("/"); - act_audio_seg.append(opt->getValue("segment-name")); - - m->setSegName(act_audio_seg); - - act_audio_seg = opt->getValue("dest-directory"); - act_audio_seg.append(foldername); - act_audio_seg.append("/"); - act_audio_seg.append(act_audio_encoding); - - std::string mpd = m->multiplex(act_audio_seg); - - mpds.push_back(mpd); - - /************ MPD READ **********************/ - - mpd_temp = opt->getValue("dest-directory"); - mpd_temp.append(foldername); - mpd_temp.append("/"); - mpd_temp.append(h264file.substr(0, h264file.find_last_of('.'))); - mpd_temp.append("_dash.mpd"); - - infile.open(mpd_temp.c_str(), ifstream::in); - - act_rep = ""; - - if (infile.is_open()) - { - while (infile.good()) - { - getline(infile, act_line); - act_rep.append(act_line); - act_rep.append("\n"); - } - infile.close(); - } - else - cout << "Error: Unable to open MPD file!"; - - act_rep = act_rep.substr(act_rep.find("") - act_rep.find("getOutputDir()) != std::string::npos) - { - act_rep.replace(act_rep.find(m->getOutputDir()), m->getOutputDir().size(), opt->getValue("url-root")); - } - std::cout << "\nDone...\n"; - - mpdgen->appendMPDbody(act_rep); - mpdgen->appendMPDbody("\n"); - } - - act_audio = strtok(NULL, "|"); - } - - /************************ VIDEO PROCESSING ******************************/ - - string bitrates = opt->getValue('b'); - char*c1 = (char*) malloc(bitrates.length() * sizeof(char)); - strcpy(c1, bitrates.c_str()); - char* pch = strtok(c1, "|"); - - - - while (pch != NULL) - { - /************ ENCODING *****************************/ - act = pch; - - if (act.find('@') != std::string::npos) - { - std::cout << act << "\n"; - e->setWidth(atoi(act.substr(act.find('@') + 1, act.find('x') - act.find('@') - 1).c_str())); - e->setHeight(atoi(act.substr(act.find('x') + 1).c_str())); - e->setBitrate(atoi(act.substr(0, act.find('@')).c_str())); - } - else - { - e->setBitrate(atoi(pch)); - } - - h264file = e->encode(); - - - /************ FOLDER CREATION **********************/ - - foldername = opt->getValue("folder-prefix"); - foldername.append("_"); - foldername.append(DASHHelper::itos(e->getBitrate())); - foldername.append("kbit"); - - folder = "mkdir "; - folder.append(opt->getValue("dest-directory")); - folder.append(foldername); - system(folder.c_str()); - - folder = "mv "; - folder.append(opt->getValue("dest-directory")); - folder.append(h264file); - folder.append(" "); - folder.append(opt->getValue("dest-directory")); - folder.append(foldername); - system(folder.c_str()); - - if(opt->getValue("mux-combi")!=NULL){ - - folder = "cp "; - folder.append(opt->getValue("dest-directory")); - folder.append(audio_files[av_mux_mapping[e->getBitrate()]]); - folder.append(" "); - folder.append(opt->getValue("dest-directory")); - folder.append(foldername); - folder.append("/"); - folder.append(audio_files[av_mux_mapping[e->getBitrate()]]); - std::cout << "copy audio: " << folder; - system(folder.c_str()); - } - - /************ STORE STATISTICS *********************/ -/* MySQL Support Disabled - if(opt->getFlag("store-psnr")){ - - mysql_init(&mysql); - - mysql_options(&mysql, MYSQL_READ_DEFAULT_FILE, "/opt/lampp/etc/my.cnf"); - //mysql_options(&mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, "/etc/ssl/certs/ComodoIntermediate.pem"); - //mysql_ssl_set(&mysql, NULL, NULL, "/etc/ssl/certs/ComodoIntermediate.pem",NULL, NULL); - - connection = mysql_real_connect(&mysql,opt->getValue("sql-host"),opt->getValue("sql-user"),opt->getValue("sql-pw"),opt->getValue("sql-database"),0,0,0); - - if (connection == NULL) - { - std::cout << "MySQL Error: " << mysql_error(&mysql) << "\n"; - return ; - } - infile.open("out.txt", ifstream::in); - - act_rep = ""; - std::string query; - int posStart; - int posEnd; - - if (infile.is_open()) - { - while (infile.good()) - { - getline(infile, act_line); - if(act_line.find("x264 [debug]: frame=") != std::string::npos){ - //std::cout << act_line << "\n"; - query = "INSERT INTO frames (framenr, type, ypsnr,upsnr, vpsnr, representation) Values ("; - - posStart = act_line.find("frame=")+6; - query.append(act_line.substr(posStart, act_line.find("QP")-posStart)); - query.append(", \""); - - query.append(act_line.substr(act_line.find("Slice:")+6, 1)); - query.append("\", "); - - posStart = act_line.find("Y:")+2; - query.append(act_line.substr(posStart, act_line.find("U:")-posStart)); - query.append(", "); - - posStart = act_line.find("U:")+2; - query.append(act_line.substr(posStart, act_line.find("V:")-posStart)); - query.append(", "); - - query.append(act_line.substr(act_line.find("V:")+2)); - query.append(", \""); - - query.append(foldername); - query.append("\")"); - //std::cout << "\n" << query; - mysql_query(connection, query.c_str()); - } - } - std::cout << "PSNR data stored in MySQL database!"; - infile.close(); - } - else - cout << "Error: Unable to open Log file!"; - } - -*/ - /************ MULTIPLEXING & SEGMENTATION **************/ - - h264new = opt->getValue("dest-directory"); - h264new.append(foldername); - h264new.append("/"); - h264new.append(opt->getValue("segment-name")); - - m->setSegName(h264new); - - h264new = opt->getValue("dest-directory"); - h264new.append(foldername); - h264new.append("/"); - h264new.append(h264file); - - if(opt->getValue("mux-combi")!=NULL){ - - std::string af =opt->getValue("dest-directory"); - af.append(foldername); - af.append("/"); - af.append(audio_files[av_mux_mapping[e->getBitrate()]]); - - m->setAudioFile(af); - } - - std::string mpd = m->multiplex(h264new); - mpds.push_back(mpd); - - - - /************ MPD READ **********************/ - - mpd_temp = opt->getValue("dest-directory"); - mpd_temp.append(foldername); - mpd_temp.append("/"); - mpd_temp.append(h264file.substr(0, h264file.find_last_of('.'))); - mpd_temp.append("_dash.mpd"); - - infile.open(mpd_temp.c_str(), ifstream::in); - - act_rep = ""; - - if (infile.is_open()) - { - while (infile.good()) - { - getline(infile, act_line); - act_rep.append(act_line); - act_rep.append("\n"); - } - infile.close(); - } - else - cout << "Error: Unable to open MPD file!"; - - act_rep = act_rep.substr(act_rep.find("") - act_rep.find("getFlag("add-non-segmented")){ - /************ GENERATE UNSEGMENTED FILE *****/ - std::string tmp_rep = act_rep; - tmp_rep = m->unSegment(tmp_rep); - - while (tmp_rep.find(m->getOutputDir()) != std::string::npos) - { - if(opt->getFlag("set-base-url")) - tmp_rep.replace(tmp_rep.find(m->getOutputDir()), m->getOutputDir().size(), ""); - else - tmp_rep.replace(tmp_rep.find(m->getOutputDir()), m->getOutputDir().size(), opt->getValue("url-root")); - } - - if(opt->getFlag("set-base-url")){ - std::string tmp_base = baseURL; - tmp_base.append("\nappendMPDbody(tmp_rep); - mpdgenNonSeg->appendMPDbody("\n"); - } - - while (act_rep.find(m->getOutputDir()) != std::string::npos) - { - if(opt->getFlag("set-base-url")) - act_rep.replace(act_rep.find(m->getOutputDir()), m->getOutputDir().size(), ""); - else - act_rep.replace(act_rep.find(m->getOutputDir()), m->getOutputDir().size(), opt->getValue("url-root")); - } - - if(opt->getFlag("set-base-url")){ - std::string tmp_base = baseURL; - tmp_base.append("\nappendMPDbody(act_rep); - mpdgen->appendMPDbody("\n"); - - e->setWidth(0); - e->setHeight(0); - - pch = strtok(NULL, "|"); - } - - /* MPD Gneration */ - std::cout << "\nWriting final MPD...\n"; - - mpdexportfile << mpdgen->getMPD(); - mpdexportfile.close(); - - if(opt->getFlag("transform-mpd")){ - std::cout << "\nConverting MPDs to actual standard ..."; - convertMPD(exp_name.c_str(), opt->getValue("mpdActStandardPostfix"), opt->getValue("duration"), opt->getValue("url-root"), opt->getValue("minBufferTime"), opt->getValue("segDuration")); - } - - /* Non-Segmented MPD Gneration */ - if(opt->getFlag("add-non-segmented")){ - mpdexportfileNonSeg << mpdgenNonSeg->getMPD(); - mpdexportfileNonSeg.close(); - - /* Run MPD Converion */ - if(opt->getFlag("transform-mpd")){ - std::cout << "\nConverting MPDs to actual standard ..."; - convertMPD(exp_nameNonSeg.c_str(), opt->getValue("mpdActStandardPostfix"), opt->getValue("duration"), opt->getValue("url-root"),opt->getValue("minBufferTime"), opt->getValue("segDuration")); - } - } - std::cout << "\nFINISHED\n"; - delete opt; -} - -void setHelp(AnyOption* opt) -{ - opt->addUsage(""); - opt->addUsage("Usage: "); - opt->addUsage(""); - opt->addUsage(" -h --help Print help "); - opt->addUsage(" -i --input Input file"); - opt->addUsage(" -x --pass1 Additional Options: 1st pass video encoding"); - opt->addUsage(" -X --pass2 Additional Options: 2nd pass video encoding"); - opt->addUsage(" -b --bitrate Video bitrates (exmaple: see config file)"); - opt->addUsage(" -s --statistics Statistic file for multi pass video encoding"); - opt->addUsage(" -g --gop GOP Size"); - opt->addUsage(" -c --scenecut Scenecut sensitivity"); - opt->addUsage(" -p --profile h.264 profile"); - opt->addUsage(" -P --preset x264 preset"); - opt->addUsage(" -f --fragment-size Fragment size in seconds"); - opt->addUsage(" -r --rap-aligned Muliplexing at GOP boundaries"); - opt->addUsage(" -o --store-psnr Store PSNR statistics to database"); - opt->addUsage(" -y --sql-host MySQL host"); - opt->addUsage(" -z --sql-user MySQL user"); - opt->addUsage(" -Z --sql-pw MySQL password"); - opt->addUsage(" -Y --sql-database MySQL database"); - opt->addUsage(" -N --segment-name DASH segment name"); - opt->addUsage(" -S --segment-size DASH segment size in seconds"); - opt->addUsage(" -F --folder-prefix Represenation folder prefix"); - opt->addUsage(" -d --dest-directory Destination directory"); - opt->addUsage(" -m --mpd-name MPD name"); - opt->addUsage(" -u --url-root Base url"); - opt->addUsage(" -a --audio-quality Audio qualities (see config file)"); - opt->addUsage(" -I --audio-input Audio source"); - opt->addUsage(" -C --audio-codec Audio codec"); - opt->addUsage(" -M --mux-combi A/V muxing combinations"); - opt->addUsage(" -V --video-encoder Video encoder"); - opt->addUsage(" -A --audio-encoder Audio encoder"); - opt->addUsage(" -R --multiplexer Multiplexing tool"); - opt->addUsage(" -K --const-filesize Encode using constant filesize"); - opt->addUsage(" -k --passes Encoding passes"); - opt->addUsage(" -D --add-non-segmented Generate also non-segmented version"); - opt->addUsage(" -J --set-base-url Use the base url"); - opt->addUsage(" -G --use-ffmpeg-pipe FFMPEG input conversion pipe"); - opt->addUsage(" -g --ffmpeg-opt Additional FFMPEG options"); - opt->addUsage(" -I --input-res Resolution of input video"); - opt->addUsage(" -t --transform-mpd Transform MPD to act standard"); - opt->addUsage(" -T --duration Content duration for MPD"); - opt->addUsage(" -a --mpdActStandardPostfix "); - opt->addUsage(" -B --minBufferTime Minimum Buffer in MPD"); - opt->addUsage(" -e --segDuration Segment Duration for MPD"); - opt->addUsage(""); -} -void setOptions(AnyOption* opt) -{ - opt->setFlag("help", 'h'); - opt->setOption("input", 'i'); - opt->setOption("pass1", 'x'); - opt->setOption("pass2", 'X'); - opt->setOption("bitrate", 'b'); - opt->setOption("statistics", 's'); - opt->setOption("gop", 'g'); - opt->setOption("scenecut", 'c'); - opt->setOption("profile", 'p'); - opt->setOption("preset", 'P'); - opt->setOption("fragment-size", 'f'); - opt->setFlag("rap-aligned", 'r'); - opt->setFlag("store-psnr", 'o'); - opt->setOption("segment-name", 'N'); - opt->setOption("segment-size", 'S'); - opt->setOption("folder-prefix", 'F'); - opt->setOption("dest-directory", 'd'); - opt->setOption("mpd-name", 'm'); - opt->setOption("url-root", 'u'); - opt->setOption("audio-quality", 'a'); - opt->setOption("audio-input", 'I'); - opt->setOption("audio-codec", 'C'); - opt->setOption("mux-combi", 'M'); - opt->setOption("video-encoder", 'V'); - opt->setOption("audio-encoder", 'A'); - opt->setOption("multiplexer", 'R'); - opt->setOption("const-filesize", 'K'); - opt->setOption("passes", 'k'); - opt->setOption("sql-host", 'y'); - opt->setOption("sql-user", 'z'); - opt->setOption("sql-pw", 'Z'); - opt->setOption("sql-database", 'Y'); - opt->setFlag("add-non-segmented", 'D'); - opt->setFlag("set-base-url", 'J'); - opt->setFlag("use-ffmpeg-pipe", 'G'); - opt->setOption("ffmpeg-opt", 'g'); - opt->setOption("input-res", 'I'); - opt->setFlag("transform-mpd", 't'); - opt->setOption("duration", 'T'); - opt->setOption("mpdActStandardPostfix", 'a'); - opt->setOption("minBufferTime", 'B'); - opt->setOption("segDuration", 'e'); -} - -IEncoder::EncoderType getEncoder(std::string e){ - if(e.compare("vp8")==0) - return IEncoder::vp8; - else if(e.compare("ffmpegAAC")==0) - return IEncoder::ffmpegAAC; - else if(e.compare("x264")==0) - return IEncoder::x264; - - return IEncoder::x264; -} -int convertMPD(std::string input, std::string output, std::string duration, std::string baseurl, std::string minbuffer, std::string segduration){ - std::cout << "\nConvert the to act DASH standard: " << input << "\nto: " << output << "\n"; - - string mpd_temp = "", act_line = "", temp; - string filename = input; - - temp = ".mpd"; - filename.replace(filename.find(temp), temp.length(),output); - - ofstream mpdexportfile; - mpdexportfile.open(filename.c_str()); - - - ifstream infile; - - infile.open(input.c_str(), ifstream::in); - - - - if (infile.is_open()) - { - while (infile.good()) - { - getline(infile, act_line); - mpd_temp.append(act_line); - mpd_temp.append("\n"); - } - infile.close(); - } - else - cout << "Error: Unable to open MPD file!"; - - string finalMPDhead, finalMPDfoot, finalMPDbody; - int pos; - - finalMPDhead.append("\n"); - finalMPDhead.append(" \n"); -/* pos = mpd_temp.find("minBufferTime"); - if(pos != std::string::npos){ - pos = pos + 15; - temp = mpd_temp.substr(pos,mpd_temp.find("\"", pos)- pos ); - pos = temp.length(); //1000 - string millisec, sec; - millisec = temp.substr(pos-3,1); - sec = temp.substr(0,pos-3); - finalMPDhead.append(sec); - finalMPDhead.append("."); - finalMPDhead.append(millisec); - finalMPDhead.append("\"> \n"); - } - else{ - std::cout << "ERROR: Could not find buffer time!\n"; - std::cout << mpd_temp; - return 1; - }*/ - - //adding base URL - finalMPDhead.append(" "); - finalMPDhead.append(baseurl); - finalMPDhead.append("\n"); - finalMPDhead.append(" \n"); - finalMPDhead.append(" \n"); - mpdexportfile << finalMPDhead; - - - finalMPDfoot.append(" \n"); - finalMPDfoot.append(" \n"); - finalMPDfoot.append("\n"); - - - finalMPDbody = ""; - - int lastRep = 0, id = 0; - string act_rep, finalRep, temp2; - - - while(mpd_temp.find("", lastRep)+ 17 - mpd_temp.find("", lastRep)+ 17; - - finalRep = ""; - - string addID = "")); - temp.append(">\n"); - finalRep.append(temp); - - - //add init segment - pos = act_rep.find("", pos)+2 - pos); - temp2 = "InitialisationSegmentURL"; - temp.replace(temp.find(temp2), temp2.length(), "Initialisation"); - pos = act_rep.find("/>", pos)+2; - - finalRep.append("\n "); - finalRep.append(temp); - finalRep.append("\n\n"); - - //add segments - finalRep.append(""); - temp = act_rep.substr(pos, act_rep.find("",pos) -pos); - temp2 = "\n"); - finalRep.append("\n"); - - mpdexportfile << finalRep; - id++; - } - - - mpdexportfile << finalMPDfoot; - mpdexportfile.close(); - - return 0; -} diff --git a/DASHEncoder_howto_compile.txt b/DASHEncoder_howto_compile.txt deleted file mode 100755 index 10d7831..0000000 --- a/DASHEncoder_howto_compile.txt +++ /dev/null @@ -1,25 +0,0 @@ -DASHEncoder - How to Install: -============================== - -Dependencies: - - * x264: use a version with scaling enabled. To be sure, get the latest version from the x264 git repository and compile it by your own. - - * MP4Box: ATTENTION: use revision 3744 of the gpac code! - Command: svn co https://gpac.svn.sourceforge.net/svnroot/gpac/trunk/gpac@3744 gpac - use the actual version from the SVN repository of GPAC (this will support dash multiplexing) - http://gpac.wp.institut-telecom.fr/2011/04/20/compiling-gpac-on-ubuntu/ - - * ffmepg (optional): if you use other input source formats than YUV, use ffmpeg for the pipe to x264 - - * MySQL: No need any more, it's disabled in this version - -Installation: - * Get the actual version from the git repository - * run: make - * Finished! - -Run: - * Edit the paramters of the example config file - * run: ./DASHEncoder - diff --git a/DASHHelper.h b/DASHHelper.h deleted file mode 100644 index bf6a4bc..0000000 --- a/DASHHelper.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * DASHHelper.h - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ -#ifndef DASHHELPER_H_ -#define DASHHELPER_H_ - -#include -#include -#include -#include - -class DASHHelper -{ - public: - static std::string itos (int i){ - std::stringstream out; - out << i; - return out.str(); - } -}; - -#endif /* DASHHELPER_H_ */ diff --git a/README.md b/README.md deleted file mode 100644 index c3c4c2b..0000000 --- a/README.md +++ /dev/null @@ -1,51 +0,0 @@ -### Welcome to DASHEncoder -We (http://dash.itec.aau.at and http://www.bitmovin.com) have developed a new content generation tool – on top of GPAC’s MP4Box and x264 – for MPEG-DASH content generation, called DASHEncoder. - -Alternatively, it is possible to generate MPEG-DASH and Apple HLS content with the cloud based transcoding service [Bitmovin](http://www.bitmovin.com). Visit [www.bitmovin.com](http://www.bitmovin.com) and experience easy access to MPEG-DASH and Apple HLS video transcoding with $ 25 of transcoding credits for free. - -[![Bitmovin](https://bitmovin.com/wp-content/uploads/2016/07/Encoder-signup.jpg)](http://www.bitmovin.com) - -### How does it work? -The DASHEncoder steps are depicted here: -DASHEncoder generates the desired representations (quality/bitrate levels), fragmented MP4 files, and a MPD file based on a given config file or by command line parameters respectively. Given the set of parameters the user has a wide range of possibilities for the content generation, including the variation of the segment size, bitrate, resolution, encoding settings, URL , etc., which is shown by the example of a DASHEncoder config file in the git repository of DASHEncoder. - -The DASHEncoder is available as open source with the aim that other developers will join this project. The content generated by DASHEncoder is compatible with our DASH VLC plugin which can be used as a decoder and player respectively. - -### Current features and restrictions -* Generation of video only, audio only or audio+video DASH content -* H.264 encoding based on x264: Constant and variable bitrate encoding -* PSNR logging and MySQL interface for storing in a database (only for common resolution representations) -* There are currently problems with the playback of the content containing Audio with the DASH VLC plugin - -### Compilation and installation - -You can find the git repository here: https://github.com/slederer/DASHEncoder - -For compilation just read the “DASHEncoder-howto.txt” of the git repository. Alternatively follow this instructions: - -Installation: -* Get the actual version from the git repository -* run: make -* Finished! - -Run: -* Edit the parameters of the example config file -* run: ./DASHEncoder - -If you're using the GitHub for Mac, simply sync your repository and you'll see the new branch. - -### Dependencies -* x264: use a version with scaling enabled. To be sure, get the latest version from the x264 git repository and compile it on your own. -* MP4Box: use the actual version from the SVN repository of GPAC (this will support dash multiplexing) -http://gpac.wp.institut-telecom.fr/2011/04/20/compiling-gpac-on-ubuntu/ -* FFmpeg (optional): if you use other input source formats than YUV, may use FFmpeg for the pipe to x264 -* MySQL (optional) client libraries (may needs some changes in the make file of DASHEncoder because of the paths) - -### Authors and Contributors -We kindly ask you to refer the following paper in any publication mentioning DASHEncoder: - -Stefan Lederer, Christopher Müller and Christian Timmerer, “Dynamic Adaptive Streaming over HTTP Dataset”, In Proceedings of the ACM Multimedia Systems Conference 2012, Chapel Hill, North Carolina, February 22-24, 2012. [[PDF]](http://www-itec.uni-klu.ac.at/bib/files/p89-lederer.pdf) - -### Support or Contact -Having trouble? Check out the documentation at [http://dash.itec.aau.at](http://www-itec.uni-klu.ac.at/dash/?page_id=282). We also offer professional services via [www.bitmovin.com/support](https://bitmovin.com/support/), so you are warmly invited to contact sales@bitmovin.com and we’ll get in touch with you. - diff --git a/encoder/AbstractAudioEncoder.cpp b/encoder/AbstractAudioEncoder.cpp deleted file mode 100644 index d8c8d97..0000000 --- a/encoder/AbstractAudioEncoder.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * AbstractAudioEncoder.cpp - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#include "AbstractAudioEncoder.h" - -AbstractAudioEncoder::AbstractAudioEncoder() -{ - // TODO Auto-generated constructor stub - -} - -AbstractAudioEncoder::~AbstractAudioEncoder() -{ - // TODO Auto-generated destructor stub -} -void AbstractAudioEncoder::setChannels(int c){ - this->channels = c; -} -int AbstractAudioEncoder::getChannels(){ - return this->channels; -} -void AbstractAudioEncoder::setSamplingRate(int r){ - this->srate = r; -} -int AbstractAudioEncoder::getSamplingRate(){ - return this->srate; -} - diff --git a/encoder/AbstractAudioEncoder.h b/encoder/AbstractAudioEncoder.h deleted file mode 100644 index cca9e66..0000000 --- a/encoder/AbstractAudioEncoder.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * AbstractAudioEncoder.h - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#ifndef ABSTRACTAUDIOENCODER_H_ -#define ABSTRACTAUDIOENCODER_H_ - -#include "AbstractEncoder.h" - -class AbstractAudioEncoder: public AbstractEncoder -{ - protected: - - int channels; - int srate; - - - public: - AbstractAudioEncoder(); - virtual ~AbstractAudioEncoder(); - - virtual std::string encode(std::string) =0; - virtual std::string encode() =0; - - void setChannels(int c); - int getChannels(); - void setSamplingRate(int srate); - int getSamplingRate(); - -}; - -#endif /* ABSTRACTAUDIOENCODER_H_ */ diff --git a/encoder/AbstractEncoder.cpp b/encoder/AbstractEncoder.cpp deleted file mode 100644 index 3bea9b9..0000000 --- a/encoder/AbstractEncoder.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * AbstractEncoder.cpp - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#include "AbstractEncoder.h" - -AbstractEncoder::AbstractEncoder() -{ - // TODO Auto-generated constructor stub - -} - -AbstractEncoder::~AbstractEncoder() -{ - // TODO Auto-generated destructor stub -} -void AbstractEncoder::setBitrate (int br){ - this->bitrate = br; -} -int AbstractEncoder::getBitrate (){ - return this->bitrate; -} -void AbstractEncoder::setOutputDir (std::string out){ - this->outputDir = out; -} -std::string AbstractEncoder::getOutputDir (){ - return this->outputDir; -} -void AbstractEncoder::setInput (std::string in){ - this->input = in; -} -std::string AbstractEncoder::getInput (){ - return this->input; -} diff --git a/encoder/AbstractEncoder.h b/encoder/AbstractEncoder.h deleted file mode 100644 index 2b0bd1a..0000000 --- a/encoder/AbstractEncoder.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * AbstractEncoder.h - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#ifndef ABSTRACTENCODER_H_ -#define ABSTRACTENCODER_H_ - -#include "IEncoder.h" -#include "../DASHHelper.h" -#include -#include -#include -#include - -class AbstractEncoder: public IEncoder -{ - protected: - int bitrate; - std::string outputDir; - std::string input; - - public: - AbstractEncoder(); - virtual ~AbstractEncoder(); - - virtual std::string encode(std::string) =0; - virtual std::string encode() =0; - - void setBitrate (int br); - int getBitrate (); - void setOutputDir (std::string out); - std::string getOutputDir (); - void setInput (std::string in); - std::string getInput (); -}; - -#endif /* ABSTRACTENCODER_H_ */ diff --git a/encoder/AbstractVideoEncoder.cpp b/encoder/AbstractVideoEncoder.cpp deleted file mode 100644 index 7b57456..0000000 --- a/encoder/AbstractVideoEncoder.cpp +++ /dev/null @@ -1,69 +0,0 @@ - -#include "AbstractVideoEncoder.h" - -AbstractVideoEncoder::AbstractVideoEncoder() -{ - this->width = 0; - this->height = 0; - this->passes = 1; - this->isConstFS = false; -} - -AbstractVideoEncoder::~AbstractVideoEncoder() -{ -} - -void AbstractVideoEncoder::setStatisticFile (std::string stat){ - this->statfile = stat; -} -std::string AbstractVideoEncoder::getStatisticFile (){ - return this->statfile; -} -void AbstractVideoEncoder::setGOPSize (int gop){ - this->gopsize = gop; -} -int AbstractVideoEncoder::getGOPSize (){ - return this->gopsize; -} -void AbstractVideoEncoder::setSceneCut (int scene){ - this->scenecut = scene; -} -int AbstractVideoEncoder::getSceneCut (){ - return this->scenecut; -} -void AbstractVideoEncoder::setSpecFirstPassOpt (std::string opt){ - this->firstPassOpt = opt; -} -std::string AbstractVideoEncoder::getSpecFirstPassOpt (){ - return this->firstPassOpt; -} -void AbstractVideoEncoder::setSpecSecPassOpt (std::string opt){ - this->secondPassOpt = opt; -} -std::string AbstractVideoEncoder::getSpecSecPassOpt (){ - return this->secondPassOpt; -} -void AbstractVideoEncoder::setWidth (int w){ - this->width = w; -} -int AbstractVideoEncoder::getWidth (){ - return this->width; -} -void AbstractVideoEncoder::setHeight (int h){ - this->height = h; -} -int AbstractVideoEncoder::getHeight (){ - return this->height; -} -void AbstractVideoEncoder::setConstFileSize (bool c){ - isConstFS = c; -} -bool AbstractVideoEncoder::isConstFileSize (){ - return isConstFS; -} -void AbstractVideoEncoder::setPasses (int p){ - this->passes = p; -} -int AbstractVideoEncoder::getPasses (){ - return this->passes; -} diff --git a/encoder/AbstractVideoEncoder.h b/encoder/AbstractVideoEncoder.h deleted file mode 100644 index 52e5110..0000000 --- a/encoder/AbstractVideoEncoder.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * AbstractEncoder.h - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#ifndef ABSTRACTVIDEOENCODER_H_ -#define ABSTRACTVIDEOENCODER_H_ - -#include "AbstractEncoder.h" - - -class AbstractVideoEncoder : public AbstractEncoder -{ - - protected: - - std::string statfile; - int gopsize; - int scenecut; - std::string firstPassOpt; - std::string secondPassOpt; - int width; - int height; - bool isConstFS; - int passes; - - public: - AbstractVideoEncoder(); - virtual ~AbstractVideoEncoder(); - - virtual std::string encode(std::string) =0; - virtual std::string encode() =0; - - - void setStatisticFile (std::string stat); - std::string getStatisticFile (); - void setGOPSize (int gop); - int getGOPSize (); - void setSceneCut (int scene); - int getSceneCut (); - void setSpecFirstPassOpt (std::string opt); - std::string getSpecFirstPassOpt (); - void setSpecSecPassOpt (std::string opt); - std::string getSpecSecPassOpt (); - void setWidth (int w); - int getWidth (); - void setHeight (int h); - int getHeight (); - void setConstFileSize (bool c); - bool isConstFileSize (); - void setPasses (int p); - int getPasses (); - -}; -#endif /* ABSTRACTVIDEOENCODER_H_ */ diff --git a/encoder/EncoderFactory.cpp b/encoder/EncoderFactory.cpp deleted file mode 100644 index 033e97a..0000000 --- a/encoder/EncoderFactory.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * EncoderFactory.cpp - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#include "EncoderFactory.h" - -EncoderFactory::EncoderFactory() -{ - // TODO Auto-generated constructor stub - -} - -EncoderFactory::~EncoderFactory() -{ - // TODO Auto-generated destructor stub -} - -IEncoder* EncoderFactory::getEncoder (AnyOption* opt, IEncoder::EncoderType type){ - IEncoder* retval = NULL; - if(type == IEncoder::x264){ - x264Encoder* e = new x264Encoder(); - e->setProfile(opt->getValue("profile")); - e->setPreset(opt->getValue("preset")); - e->setSceneCut(atoi(opt->getValue("scenecut"))); - e->setGOPSize(atoi(opt->getValue("gop"))); - e->setPasses(atoi(opt->getValue("passes"))); - e->setStatisticFile(opt->getValue("statistics")); - e->setInput(opt->getValue("input")); - e->setInputRes(opt->getValue("input-res")); - e->setOutputDir(opt->getValue("dest-directory")); - e->setSpecFirstPassOpt(opt->getValue("pass1")); - e->setSpecSecPassOpt(opt->getValue("pass2")); - if(atoi(opt->getValue("const-filesize")) ==1) - e->setConstFileSize(true); - else - e->setConstFileSize(false); - - if(opt->getFlag("use-ffmpeg-pipe")){ - e->setFFMpegOpt(opt->getValue("ffmpeg-opt")); - e->usePipe(true); - } - else - e->usePipe(false); - - retval = e; - - } - else if(type == IEncoder::vp8){ - - } - else if(type == IEncoder::ffmpegAAC){ - ffmpegAACEncoder* a = new ffmpegAACEncoder(); - a->setInput(opt->getValue("audio-input")); - a->setOutputDir(opt->getValue("dest-directory")); - a->setCodec(opt->getValue("audio-codec")); - retval = a; - } - - return retval; -} diff --git a/encoder/EncoderFactory.h b/encoder/EncoderFactory.h deleted file mode 100644 index d1e8ec6..0000000 --- a/encoder/EncoderFactory.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * EncoderFactory.h - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#ifndef ENCODERFACTORY_H_ -#define ENCODERFACTORY_H_ - -#include "../AnyOption.h" -#include "IEncoder.h" -#include "vp8Encoder.h" -#include "x264Encoder.h" -#include "ffmpegAACEncoder.h" - -class EncoderFactory -{ - public: - EncoderFactory(); - virtual ~EncoderFactory(); - - IEncoder* getEncoder (AnyOption* opt, IEncoder::EncoderType type); -}; - -#endif /* ENCODERFACTORY_H_ */ diff --git a/encoder/IEncoder.h b/encoder/IEncoder.h deleted file mode 100644 index e535d04..0000000 --- a/encoder/IEncoder.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * IEncoder.h - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - - -#ifndef IENCODER_H_ -#define IENCODER_H_ - -#include - -class IEncoder -{ - public: - enum EncoderType - { - x264, - vp8, - ffmpegAAC - }; - - virtual std::string encode (std::string input) = 0; - virtual std::string encode () = 0; -}; - -#endif /* IENCODER_H_ */ diff --git a/encoder/ffmpegAACEncoder.cpp b/encoder/ffmpegAACEncoder.cpp deleted file mode 100644 index 10925cf..0000000 --- a/encoder/ffmpegAACEncoder.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * ffmpegAACEncoder.cpp - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#include "ffmpegAACEncoder.h" - - -std::string ffmpegAACEncoder::encode (std::string input){ - this->setInput(input); - return this->encode(); -} -std::string ffmpegAACEncoder::encode (){ - std::cout << "AUDIO FFMPEG AAC Encoding: " << this->input << " \n"; - - std::string out = ""; - - std::string aac = "ffmpeg "; - - aac.append("-i "); - aac.append(this->input); - aac.append(" "); - - aac.append("-acodec "); - aac.append(this->codec); - aac.append(" "); - - aac.append("-ac "); - aac.append(DASHHelper::itos(this->channels)); - aac.append(" "); - - aac.append("-ar "); - aac.append(DASHHelper::itos(this->srate)); - aac.append(" "); - - aac.append("-ab "); - aac.append(DASHHelper::itos(this->bitrate)); - aac.append("k "); - - out.append(this->outputDir); - out.append(this->input.substr(this->input.find_last_of("/")+1,this->input.find_last_of(".")-this->input.find_last_of("/")-1)); - out.append("_"); - out.append(DASHHelper::itos(this->channels)); - out.append("ch_"); - out.append(DASHHelper::itos(this->bitrate)); - out.append("kbit.aac "); - - aac.append(out); - - std::cout <codec = c; -} -std::string ffmpegAACEncoder::getCodec (){ - return this->codec; -} diff --git a/encoder/ffmpegAACEncoder.h b/encoder/ffmpegAACEncoder.h deleted file mode 100644 index 2939fc8..0000000 --- a/encoder/ffmpegAACEncoder.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * ffmpegAACEncoder.h - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#ifndef FFMPEGAACENCODER_H_ -#define FFMPEGAACENCODER_H_ - -#include "AbstractAudioEncoder.h" - -class ffmpegAACEncoder: public AbstractAudioEncoder -{ - private: - std::string codec; - - public: - - std::string encode (std::string input); - std::string encode (); - - void setCodec (std::string c); - std::string getCodec (); -}; - -#endif /* FFMPEGAACENCODER_H_ */ diff --git a/encoder/subdir.mk b/encoder/subdir.mk deleted file mode 100644 index 4fac170..0000000 --- a/encoder/subdir.mk +++ /dev/null @@ -1,42 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -# Add inputs and outputs from these tool invocations to the build variables -CPP_SRCS += \ -./encoder/AbstractAudioEncoder.cpp \ -./encoder/AbstractEncoder.cpp \ -./encoder/AbstractVideoEncoder.cpp \ -./encoder/EncoderFactory.cpp \ -./encoder/ffmpegAACEncoder.cpp \ -./encoder/vp8Encoder.cpp \ -./encoder/x264Encoder.cpp - -OBJS += \ -./encoder/AbstractAudioEncoder.o \ -./encoder/AbstractEncoder.o \ -./encoder/AbstractVideoEncoder.o \ -./encoder/EncoderFactory.o \ -./encoder/ffmpegAACEncoder.o \ -./encoder/vp8Encoder.o \ -./encoder/x264Encoder.o - -CPP_DEPS += \ -./encoder/AbstractAudioEncoder.d \ -./encoder/AbstractEncoder.d \ -./encoder/AbstractVideoEncoder.d \ -./encoder/EncoderFactory.d \ -./encoder/ffmpegAACEncoder.d \ -./encoder/vp8Encoder.d \ -./encoder/x264Encoder.d - - -# Each subdirectory must supply rules for building sources it contributes -encoder/%.o: ./encoder/%.cpp - @echo 'Building file: $<' - @echo 'Invoking: GCC C++ Compiler' - g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" - @echo 'Finished building: $<' - @echo ' ' - - diff --git a/encoder/vp8Encoder.cpp b/encoder/vp8Encoder.cpp deleted file mode 100644 index 271c911..0000000 --- a/encoder/vp8Encoder.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/* - * vp8Encoder.cpp - * - * Created on: May 5, 2011 - * Author: stefan - */ - -#include "vp8Encoder.h" - - diff --git a/encoder/vp8Encoder.h b/encoder/vp8Encoder.h deleted file mode 100644 index eb1882a..0000000 --- a/encoder/vp8Encoder.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * vp8Encoder.h - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ -#ifndef VP8ENCODER_H_ -#define VP8ENCODER_H_ - -#include "AbstractVideoEncoder.h" - -class vp8Encoder: public AbstractVideoEncoder -{ - public: - - std::string encode (std::string input); - std::string encode (); -}; - -#endif diff --git a/encoder/x264Encoder.cpp b/encoder/x264Encoder.cpp deleted file mode 100644 index 693a001..0000000 --- a/encoder/x264Encoder.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * x264Encoder.cpp - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#include "x264Encoder.h" - - - - -std::string x264Encoder::encode (std::string in){ - this->input = in; - return this->encode(); -} -std::string x264Encoder::encode (){ - std::cout << "x264 encoding @ " << this->bitrate << " kbps: Pass 1 \n"; - - std::string x264 = "x264 "; - x264.append("--profile "); - x264.append(this->profile); - x264.append(" "); - x264.append("--preset "); - x264.append(this->preset); - x264.append(" "); - - if(this->passes > 1) - x264.append("--pass 1 "); - - x264.append(this->getSpecFirstPassOpt()); - x264.append(" "); - - if(this->isConstFileSize()){ - x264.append("--bitrate "); - x264.append(DASHHelper::itos(this->bitrate)); - x264.append(" "); - } - else{ - x264.append("--vbv-maxrate "); - x264.append(DASHHelper::itos(this->bitrate)); - x264.append(" "); - - x264.append("--vbv-bufsize "); - x264.append(DASHHelper::itos(this->bitrate*2)); - x264.append(" "); - } - - x264.append("--scenecut "); - x264.append(DASHHelper::itos(this->scenecut)); - x264.append(" "); - - if(this->width>0 && this->height>0){ - x264.append("--video-filter resize:width="); - x264.append(DASHHelper::itos(this->width)); - x264.append(",height="); - x264.append(DASHHelper::itos(this->height)); - x264.append(" "); - } - - x264.append("--keyint "); - x264.append(DASHHelper::itos(this->gopsize)); - x264.append(" "); - - if(this->passes > 1){ - x264.append("--stat "); - x264.append(this->outputDir); - x264.append(this->statfile); - x264.append(" "); - x264.append("--output NUL "); - } - else { - x264.append("--output "); - x264.append(this->outputDir); - x264.append(this->input.substr(this->input.find_last_of("/")+1,this->input.find_last_of(".")-this->input.find_last_of("/")-1)); - x264.append("_"); - x264.append(DASHHelper::itos(this->bitrate)); - x264.append("kbit.h264 "); - } - - - if(pipe) - { - std::string ffmpeg = "ffmpeg -i "; - ffmpeg.append(this->input); - ffmpeg.append(" "); - ffmpeg.append(ffmpegopt); - ffmpeg.append(" - | "); - ffmpeg.append(x264); - x264 = ffmpeg; - x264.append("--input-res "); - x264.append(inputres); - x264.append(" -"); - } - else - x264.append(this->input); - - x264.append(" >out.txt 2>&1 "); - std::cout << "x264: " <passes > 1){ - std::cout << "x264 encoding @ " << this->bitrate << " kbps: Pass 2 \n"; - - x264 = "x264 "; - - x264.append("--profile "); - x264.append(this->profile); - x264.append(" "); - - x264.append("--preset "); - x264.append(this->preset); - x264.append(" "); - - x264.append("--pass 2 "); - - x264.append(this->getSpecSecPassOpt()); - x264.append(" "); - - if(this->isConstFileSize()){ - x264.append("--bitrate "); - x264.append(DASHHelper::itos(this->bitrate)); - x264.append(" "); - } - else{ - x264.append("--vbv-maxrate "); - x264.append(DASHHelper::itos(this->bitrate)); - x264.append(" "); - - x264.append("--vbv-bufsize "); - x264.append(DASHHelper::itos(this->bitrate*2)); - x264.append(" "); - } - - x264.append("--scenecut "); - x264.append(DASHHelper::itos(this->scenecut)); - x264.append(" "); - - x264.append("--keyint "); - x264.append(DASHHelper::itos(this->gopsize)); - x264.append(" "); - - if(this->width>0 && this->height>0){ - x264.append("--video-filter resize:width="); - x264.append(DASHHelper::itos(this->width)); - x264.append(",height="); - x264.append(DASHHelper::itos(this->height)); - x264.append(" "); - } - - x264.append("--stat "); - x264.append(this->outputDir); - x264.append(this->statfile); - x264.append(" "); - - x264.append("--output "); - x264.append(this->outputDir); - x264.append(this->input.substr(this->input.find_last_of("/")+1,this->input.find_last_of(".")-this->input.find_last_of("/")-1)); - x264.append("_"); - x264.append(DASHHelper::itos(this->bitrate)); - x264.append("kbit.h264 "); - - x264.append(this->input); - x264.append(" >out.txt 2>&1 "); - - std::cout <input.substr(this->input.find_last_of("/")+1,this->input.find_last_of(".")-this->input.find_last_of("/")-1)); - out.append("_"); - out.append(DASHHelper::itos(this->bitrate)); - out.append("kbit.h264 "); - - return out; -} - - -void x264Encoder::setPreset (std::string pre){ - this->preset = pre; -} -std::string x264Encoder::getPreset (){ - return this->preset; -} -void x264Encoder::setProfile (std::string pro){ - this->profile = pro; -} -std::string x264Encoder::getProfile (){ - return this->profile; -} -void x264Encoder::setFFMpegOpt (std::string opt){ - this->ffmpegopt = opt; -} -std::string x264Encoder::getFFMpegOpt (){ - return this->ffmpegopt; -} -void x264Encoder::usePipe (bool b){ - this->pipe = b; -} -void x264Encoder::setInputRes (std::string opt){ - this->inputres = opt; -} -std::string x264Encoder::getInputRes (){ - return this->inputres; -} - diff --git a/encoder/x264Encoder.h b/encoder/x264Encoder.h deleted file mode 100644 index f9f41bd..0000000 --- a/encoder/x264Encoder.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * x264Encoder.h - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#ifndef X264ENCODER_H_ -#define X264ENCODER_H_ - -#include "AbstractVideoEncoder.h" - -class x264Encoder : public AbstractVideoEncoder -{ - protected: - - std::string preset; - std::string profile; - bool pipe; - std::string ffmpegopt; - std::string inputres; - public: - - std::string encode (std::string input); - std::string encode (); - - void setPreset (std::string pre); - std::string getPreset (); - void setProfile (std::string pro); - std::string getProfile (); - void setFFMpegOpt (std::string opt); - std::string getFFMpegOpt (); - void setInputRes (std::string opt); - std::string getInputRes (); - void usePipe (bool b); - - -}; - -#endif /* X264ENCODER_H_ */ diff --git a/images/bg_hr.png b/images/bg_hr.png new file mode 100644 index 0000000..7973bd6 Binary files /dev/null and b/images/bg_hr.png differ diff --git a/images/blacktocat.png b/images/blacktocat.png new file mode 100644 index 0000000..6e264fe Binary files /dev/null and b/images/blacktocat.png differ diff --git a/images/icon_download.png b/images/icon_download.png new file mode 100644 index 0000000..a2a287f Binary files /dev/null and b/images/icon_download.png differ diff --git a/images/sprite_download.png b/images/sprite_download.png new file mode 100644 index 0000000..f2babd5 Binary files /dev/null and b/images/sprite_download.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..94e4135 --- /dev/null +++ b/index.html @@ -0,0 +1,104 @@ + + + + + + + + + + + DASHEncoder + + + + + +
+
+ View on GitHub + +

DASHEncoder

+

Tool to generated MPEG-DASH content

+ +
+ Download this project as a .zip file + Download this project as a tar.gz file +
+
+
+ + +
+
+

Welcome to GitHub Pages.

+ +

We (http://dash.itec.aau.at and http://www.bitmovin.net) developed a new content generation tool – on top of GPAC’s MP4Box and x264 – for MPEG-DASH content generation, called DASHEncoder.

+ +

How it works?

+ +

The DASHEncoder steps are depicted here: +Structure +DASHEncoder generates the desired representations (quality/bitrate levels), fragmented MP4 files, and MPD file based on a given config file or by command line parameters respectively. Given the set of parameters the user has a wide range of possibilities for the content generation, including the variation of the segment size, bitrate, resolution, encoding settings, URL , etc., which is shown by the example of a DASHEncoder config file in the git repository of DASHEncoder.

+ +

The DASHEncoder is available as open source with the aim that other developers will join this project. The content generated by DASHEncoder is compatible with our DASH VLC plugin which can be used as a decoder and player respectively.

+ +

Current features and restrictions

+ +
    +
  • Generation of video only, audio only or audio+video DASH content
  • +
  • h.264 encoding based on x264: Constant and variable bitrate encoding
  • +
  • PSNR logging and MySQL interface for storing in a database(only for common resoltution representations)
  • +
  • There are currently problems with the playback of the content containing Audio with the DASH VLC plugin
  • +

Compilation and installation

+ +

You can find the git repository here: https://github.com/slederer/DASHEncoder

+ +

For compilation just read the “DASHEncoder-howto.txt” of the git repository. Alternatively follow this instructions:

+ +

Installation:

+ +
    +
  • Get the actual version from the git repository
  • +
  • run: make
  • +
  • Finished!
  • +

Run:

+ +
    +
  • Edit the paramters of the example config file
  • +
  • run: ./DASHEncoder
  • +

If you're using the GitHub for Mac, simply sync your repository and you'll see the new branch.

+ +

Dependencies

+ +
    +
  • x264: use a version with scaling enabled. To be sure, get the latest version from the x264 git repository and compile it by your own.
  • +
  • MP4Box: use the actual version from the SVN repository of GPAC (this will support dash multiplexing) +http://gpac.wp.institut-telecom.fr/2011/04/20/compiling-gpac-on-ubuntu/ +
  • +
  • ffmepg (optional): if you use other input source formats than YUV, may use ffmpeg for the pipe to x264
  • +
  • mysql (optional) client libraries (may needs some changes in the make file of DASHEncoder because of the paths)
  • +

Authors and Contributors

+ +

We kindly ask you to refer the following paper in any publication mentioning DASHEncoder:

+ +

Stefan Lederer, Christopher Müller and Christian Timmerer, “Dynamic Adaptive Streaming over HTTP Dataset”, In Proceedings of the ACM Multimedia Systems Conference 2012, Chapel Hill, North Carolina, February 22-24, 2012. [PDF]

+ +

Support or Contact

+ +

Having trouble with Pages? Check out the documentation at http://dash.itec.aau.at. We also offer professional services via www.bitmovin.net, so you are welcome to contact sales@bitmovin.net and we’ll get in touch with you.

+
+
+ + + + + + + + diff --git a/javascripts/main.js b/javascripts/main.js new file mode 100644 index 0000000..d8135d3 --- /dev/null +++ b/javascripts/main.js @@ -0,0 +1 @@ +console.log('This would be the main JS file.'); diff --git a/makefile b/makefile deleted file mode 100644 index b73a6b8..0000000 --- a/makefile +++ /dev/null @@ -1,36 +0,0 @@ - - -RM := rm -rf - -USER_OBJS := - -LIBS := - -SUBDIRS := \ -multiplexer \ -mpdgenerator \ -encoder \ - --include subdir.mk --include multiplexer/subdir.mk --include mpdgenerator/subdir.mk --include encoder/subdir.mk - - -# Add inputs and outputs from these tool invocations to the build variables - -# All Target -all: DASHEncoder - -# Tool invocations -DASHEncoder: $(OBJS) $(USER_OBJS) - @echo 'Building target: $@' - @echo 'Invoking: GCC C++ Linker' - g++ -o"DASHEncoder" $(OBJS) $(USER_OBJS) $(LIBS) - @echo 'Finished building target: $@' - @echo ' ' - -# Other Targets -clean: - -$(RM) $(OBJS)$(C++_DEPS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) DASHEncoder - -@echo ' ' diff --git a/mpdgenerator/MPDGenerator.cpp b/mpdgenerator/MPDGenerator.cpp deleted file mode 100644 index 134ee17..0000000 --- a/mpdgenerator/MPDGenerator.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * MPDGnerator.cpp - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#include "MPDGenerator.h" - -MPDGenerator::MPDGenerator() -{ - finalMPDhead.append("\n"); - finalMPDhead.append(" \n"); - finalMPDhead.append(" \n"); - finalMPDhead.append(" \n"); - - finalMPDfoot.append(" \n"); - finalMPDfoot.append(" \n"); - finalMPDfoot.append("\n"); -} - -MPDGenerator::~MPDGenerator() -{ - // TODO Auto-generated destructor stub -} - -void MPDGenerator::appendMPDbody(std::string s){ - this->finalMPDbody.append(s); -} -std::string MPDGenerator::getMPD(){ - std::string str = ""; - - str.append(this->finalMPDhead); - str.append(this->finalMPDbody); - str.append(this->finalMPDfoot); - - return str; -} diff --git a/mpdgenerator/MPDGenerator.h b/mpdgenerator/MPDGenerator.h deleted file mode 100644 index c8b70bd..0000000 --- a/mpdgenerator/MPDGenerator.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * MPDGnerator.h - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ -#ifndef MPDGENERATOR_H_ -#define MPDGENERATOR_H_ - -#include -#include -#include -#include - -class MPDGenerator -{ - std::string finalMPDhead; - std::string finalMPDbody; - std::string finalMPDfoot; - std::string version; - - public: - MPDGenerator(); - virtual ~MPDGenerator(); - - void appendMPDbody(std::string s); - std::string getMPD(); -}; - -#endif /* MPDGENERATOR_H_ */ diff --git a/mpdgenerator/subdir.mk b/mpdgenerator/subdir.mk deleted file mode 100644 index f5231fa..0000000 --- a/mpdgenerator/subdir.mk +++ /dev/null @@ -1,24 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -# Add inputs and outputs from these tool invocations to the build variables -CPP_SRCS += \ -./mpdgenerator/MPDGenerator.cpp - -OBJS += \ -./mpdgenerator/MPDGenerator.o - -CPP_DEPS += \ -./mpdgenerator/MPDGenerator.d - - -# Each subdirectory must supply rules for building sources it contributes -mpdgenerator/%.o: ./mpdgenerator/%.cpp - @echo 'Building file: $<' - @echo 'Invoking: GCC C++ Compiler' - g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" - @echo 'Finished building: $<' - @echo ' ' - - diff --git a/multiplexer/AbstractMultiplexer.cpp b/multiplexer/AbstractMultiplexer.cpp deleted file mode 100644 index 72cbea2..0000000 --- a/multiplexer/AbstractMultiplexer.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * AbstractMultiplexer.cpp - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#include "AbstractMultiplexer.h" - -AbstractMultiplexer::AbstractMultiplexer() -{ - this->audioFile = ""; -} - -AbstractMultiplexer::~AbstractMultiplexer() -{ - // TODO Auto-generated destructor stub -} -void AbstractMultiplexer::setInput(std::string in) -{ - this->input = in; -} -std::string AbstractMultiplexer::getInput() -{ - return this->input; -} -void AbstractMultiplexer::setFragSize(int frag) -{ - this->fragSize = frag; -} -int AbstractMultiplexer::getFragSize() -{ - return this->fragSize; -} -void AbstractMultiplexer::setSegSize(int seg) -{ - this->segSize = seg; -} -int AbstractMultiplexer::getSegSize() -{ - return this->segSize; -} -void AbstractMultiplexer::setRAPAligned(bool rap) -{ - this->rapAligned = rap; -} -bool AbstractMultiplexer::isRAPAligned() -{ - return this->rapAligned; -} -void AbstractMultiplexer::setSegName(std::string name) -{ - this->segName = name; -} -std::string AbstractMultiplexer::getSegName() -{ - return this->segName; -} -void AbstractMultiplexer::setOutputDir (std::string out){ - this->outputDir = out; -} -std::string AbstractMultiplexer::getOutputDir (){ - return this->outputDir; -} -void AbstractMultiplexer::setAudioFile (std::string file){ - this->audioFile = file; -} -std::string AbstractMultiplexer::getAudioFile (){ - return this->audioFile; -} - diff --git a/multiplexer/AbstractMultiplexer.h b/multiplexer/AbstractMultiplexer.h deleted file mode 100644 index 6886f09..0000000 --- a/multiplexer/AbstractMultiplexer.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * AbstractMultiplexer.h - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#ifndef ABSTRACTMULTIPLEXER_H_ -#define ABSTRACTMULTIPLEXER_H_ - -#include "IMultiplexer.h" -#include "../DASHHelper.h" - -class AbstractMultiplexer : public IMultiplexer -{ - protected: - std::string input; - int fragSize; - int segSize; - bool rapAligned; - std::string segName; - std::string outputDir; - std::string audioFile; - - public: - AbstractMultiplexer(); - virtual ~AbstractMultiplexer(); - - virtual std::string multiplex (std::string input) = 0; - virtual std::string multiplex () = 0; - virtual std::string unSegment (std::string input) = 0; - - void setInput (std::string in); - std::string getInput (); - void setFragSize (int frag); - int getFragSize (); - void setSegSize (int seg); - int getSegSize (); - void setRAPAligned (bool rap); - bool isRAPAligned (); - void setSegName (std::string name); - std::string getSegName (); - void setOutputDir (std::string out); - std::string getOutputDir (); - void setAudioFile (std::string file); - std::string getAudioFile (); - - -}; -#endif /* ABSTRACTMULTIPLEXER_H_ */ diff --git a/multiplexer/IMultiplexer.h b/multiplexer/IMultiplexer.h deleted file mode 100644 index e581811..0000000 --- a/multiplexer/IMultiplexer.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * IMultiplexer.h - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#ifndef IMULTIPLEXER_H_ -#define IMULTIPLEXER_H_ - - - -#include - -class IMultiplexer -{ - public: - virtual std::string multiplex (std::string input) = 0; - virtual std::string multiplex () = 0; -}; - -#endif /* IMULTIPLEXER_H_ */ diff --git a/multiplexer/MP4BoxMultiplexer.cpp b/multiplexer/MP4BoxMultiplexer.cpp deleted file mode 100644 index 0b6074f..0000000 --- a/multiplexer/MP4BoxMultiplexer.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/* - * MP4BoxMultiplexer.cpp - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#include "MP4BoxMultiplexer.h" - - -MP4BoxMultiplexer::MP4BoxMultiplexer() -{ - // TODO Auto-generated constructor stub - -} - -MP4BoxMultiplexer::~MP4BoxMultiplexer() -{ - // TODO Auto-generated destructor stub -} - -std::string MP4BoxMultiplexer::multiplex (std::string in) -{ - this->input = in; - return this->multiplex(); -} -std::string MP4BoxMultiplexer::multiplex (){ - - std::cout << "MP4Box multiplexing Video: " << this->input << " \n"; - - std::string mp4box = "MP4Box "; - mp4box.append("-add "); - mp4box.append(this->input); - mp4box.append(" "); - mp4box.append(this->input.substr(0,this->input.find_last_of("."))); - mp4box.append(".mp4"); - - std::cout << "mp4box: " <audioFile.size()>0){ - std::cout << "MP4Box multiplexing Audio:" << this->audioFile << " \n"; - - std::string mp4box = "MP4Box "; - mp4box.append("-add "); - mp4box.append(this->audioFile); - mp4box.append(" "); - mp4box.append(this->input.substr(0,this->input.find_last_of("."))); - mp4box.append(".mp4"); - - std::cout << "mp4box: " <input.substr(0,this->input.find_last_of("."))); - mp4box.append(".mp4"); - - std::cout << "mp4box: " <input << " \n"; - - mp4box = "MP4Box "; - - mp4box.append("-frag "); - mp4box.append(DASHHelper::itos(this->fragSize)); - mp4box.append(" "); - - mp4box.append("-dash "); - mp4box.append(DASHHelper::itos(this->segSize)); - mp4box.append(" "); - - if(this->isRAPAligned()){ - mp4box.append("-rap "); - } - - mp4box.append("-segment-name "); - mp4box.append(this->segName); - mp4box.append(" "); - - mp4box.append(this->input.substr(0,this->input.find_last_of("."))); - mp4box.append(".mp4"); - - std::cout << "mp4box: " <input.substr(0,this->input.find_last_of(".")); - mpd.append("_dash.mpd"); - return mpd; -} - -std::string MP4BoxMultiplexer::unSegment (std::string act_rep){ - std::string mpd = ""; - std::string byterange = ""; - int actpos = 0; - int size = 0; - std::string path = ""; - std::string mainfile = ""; - std::string catcmd = ""; - - int s_pos = act_rep.find("fileSize(path.c_str()); - - mainfile = path; - mainfile.replace(mainfile.find_last_of("."), 1, "NonSeg."); - - byterange = " range=\""; - byterange.append(DASHHelper::itos(actpos)); - byterange.append("-"); - byterange.append(DASHHelper::itos(actpos+size)); - byterange.append("\" />"); - actpos += size+1; - - act_rep.replace(act_rep.find("/>", s_pos),2,byterange); - act_rep.replace(act_rep.find(path), path.length(), mainfile); - - s_pos +=26; - - catcmd = "cat "; - catcmd.append(path); - catcmd.append(" > "); - catcmd.append(mainfile); - - system(catcmd.c_str()); - - while (act_rep.find("fileSize(path.c_str()); - - byterange = " range=\""; - byterange.append(DASHHelper::itos(actpos)); - byterange.append("-"); - byterange.append(DASHHelper::itos(actpos+size)); - byterange.append("\" />"); - actpos += size+1; - - catcmd = "cat "; - catcmd.append(path); - catcmd.append(" >> "); - catcmd.append(mainfile); - - system(catcmd.c_str()); - - act_rep.replace(act_rep.find("/>", s_pos),2,byterange); - act_rep.replace(act_rep.find(path), path.length(), mainfile); - s_pos +=5; - } - return act_rep; -} - - -int MP4BoxMultiplexer::fileSize(const char* sFileName) -{ - std::ifstream f; - f.open(sFileName, std::ios_base::binary | std::ios_base::in); - if (!f.good() || f.eof() || !f.is_open()) { return 0; } - f.seekg(0, std::ios_base::beg); - std::ifstream::pos_type begin_pos = f.tellg(); - f.seekg(0, std::ios_base::end); - return static_cast(f.tellg() - begin_pos); -} diff --git a/multiplexer/MP4BoxMultiplexer.h b/multiplexer/MP4BoxMultiplexer.h deleted file mode 100644 index 1e989d5..0000000 --- a/multiplexer/MP4BoxMultiplexer.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * MP4BoxMultiplexer.h - ***************************************************************************** - * Copyright (C) 2011 Klagenfurt University - * - * Created on: Jun 01, 2011 - * Authors: Stefan Lederer - * Christian Timmerer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#ifndef MP4BOXMULTIPLEXER_H_ -#define MP4BOXMULTIPLEXER_H_ - -#include - -#include "AbstractMultiplexer.h" - - -class MP4BoxMultiplexer : public AbstractMultiplexer -{ - public: - MP4BoxMultiplexer(); - ~MP4BoxMultiplexer(); - - std::string multiplex (std::string input); - std::string multiplex (); - std::string unSegment (std::string input); - int fileSize (const char* sFileName); -}; - -#endif /* MP4BOXMULTIPLEXER_H_ */ diff --git a/multiplexer/subdir.mk b/multiplexer/subdir.mk deleted file mode 100644 index 23477be..0000000 --- a/multiplexer/subdir.mk +++ /dev/null @@ -1,27 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -# Add inputs and outputs from these tool invocations to the build variables -CPP_SRCS += \ -./multiplexer/AbstractMultiplexer.cpp \ -./multiplexer/MP4BoxMultiplexer.cpp - -OBJS += \ -./multiplexer/AbstractMultiplexer.o \ -./multiplexer/MP4BoxMultiplexer.o - -CPP_DEPS += \ -./multiplexer/AbstractMultiplexer.d \ -./multiplexer/MP4BoxMultiplexer.d - - -# Each subdirectory must supply rules for building sources it contributes -multiplexer/%.o: ./multiplexer/%.cpp - @echo 'Building file: $<' - @echo 'Invoking: GCC C++ Compiler' - g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" - @echo 'Finished building: $<' - @echo ' ' - - diff --git a/params.json b/params.json new file mode 100644 index 0000000..2303d26 --- /dev/null +++ b/params.json @@ -0,0 +1 @@ +{"name":"DASHEncoder","tagline":"Tool to generated MPEG-DASH content","body":"### Welcome to GitHub Pages.\r\nWe (http://dash.itec.aau.at and http://www.bitmovin.net) developed a new content generation tool – on top of GPAC’s MP4Box and x264 – for MPEG-DASH content generation, called DASHEncoder.\r\n\r\n### How it works?\r\nThe DASHEncoder steps are depicted here:\r\n![Structure](http://www.bitmovin.net/wp-content/uploads/2013/03/DASHEncoder.png)\r\nDASHEncoder generates the desired representations (quality/bitrate levels), fragmented MP4 files, and MPD file based on a given config file or by command line parameters respectively. Given the set of parameters the user has a wide range of possibilities for the content generation, including the variation of the segment size, bitrate, resolution, encoding settings, URL , etc., which is shown by the example of a DASHEncoder config file in the git repository of DASHEncoder.\r\n\r\nThe DASHEncoder is available as open source with the aim that other developers will join this project. The content generated by DASHEncoder is compatible with our DASH VLC plugin which can be used as a decoder and player respectively.\r\n\r\n### Current features and restrictions\r\n* Generation of video only, audio only or audio+video DASH content\r\n* h.264 encoding based on x264: Constant and variable bitrate encoding\r\n* PSNR logging and MySQL interface for storing in a database(only for common resoltution representations)\r\n* There are currently problems with the playback of the content containing Audio with the DASH VLC plugin\r\n\r\n### Compilation and installation\r\n\r\nYou can find the git repository here: https://github.com/slederer/DASHEncoder\r\n\r\nFor compilation just read the “DASHEncoder-howto.txt” of the git repository. Alternatively follow this instructions:\r\n\r\nInstallation:\r\n* Get the actual version from the git repository\r\n* run: make\r\n* Finished!\r\n\r\nRun:\r\n* Edit the paramters of the example config file\r\n* run: ./DASHEncoder\r\n\r\nIf you're using the GitHub for Mac, simply sync your repository and you'll see the new branch.\r\n\r\n### Dependencies\r\n* x264: use a version with scaling enabled. To be sure, get the latest version from the x264 git repository and compile it by your own.\r\n* MP4Box: use the actual version from the SVN repository of GPAC (this will support dash multiplexing)\r\nhttp://gpac.wp.institut-telecom.fr/2011/04/20/compiling-gpac-on-ubuntu/\r\n* ffmepg (optional): if you use other input source formats than YUV, may use ffmpeg for the pipe to x264\r\n* mysql (optional) client libraries (may needs some changes in the make file of DASHEncoder because of the paths)\r\n\r\n### Authors and Contributors\r\nWe kindly ask you to refer the following paper in any publication mentioning DASHEncoder:\r\n\r\nStefan Lederer, Christopher Müller and Christian Timmerer, “Dynamic Adaptive Streaming over HTTP Dataset”, In Proceedings of the ACM Multimedia Systems Conference 2012, Chapel Hill, North Carolina, February 22-24, 2012. [[PDF]](http://www-itec.uni-klu.ac.at/bib/files/p89-lederer.pdf)\r\n\r\n### Support or Contact\r\nHaving trouble with Pages? Check out the documentation at [http://dash.itec.aau.at](http://www-itec.uni-klu.ac.at/dash/?page_id=282). We also offer professional services via [www.bitmovin.net](http://www.bitmovin.net), so you are welcome to contact sales@bitmovin.net and we’ll get in touch with you. ","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file diff --git a/stylesheets/pygment_trac.css b/stylesheets/pygment_trac.css new file mode 100644 index 0000000..e65cedf --- /dev/null +++ b/stylesheets/pygment_trac.css @@ -0,0 +1,70 @@ +.highlight .hll { background-color: #ffffcc } +.highlight { background: #f0f3f3; } +.highlight .c { color: #0099FF; font-style: italic } /* Comment */ +.highlight .err { color: #AA0000; background-color: #FFAAAA } /* Error */ +.highlight .k { color: #006699; font-weight: bold } /* Keyword */ +.highlight .o { color: #555555 } /* Operator */ +.highlight .cm { color: #0099FF; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #009999 } /* Comment.Preproc */ +.highlight .c1 { color: #0099FF; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #0099FF; font-weight: bold; font-style: italic } /* Comment.Special */ +.highlight .gd { background-color: #FFCCCC; border: 1px solid #CC0000 } /* Generic.Deleted */ +.highlight .ge { font-style: italic } /* Generic.Emph */ +.highlight .gr { color: #FF0000 } /* Generic.Error */ +.highlight .gh { color: #003300; font-weight: bold } /* Generic.Heading */ +.highlight .gi { background-color: #CCFFCC; border: 1px solid #00CC00 } /* Generic.Inserted */ +.highlight .go { color: #AAAAAA } /* Generic.Output */ +.highlight .gp { color: #000099; font-weight: bold } /* Generic.Prompt */ +.highlight .gs { font-weight: bold } /* Generic.Strong */ +.highlight .gu { color: #003300; font-weight: bold } /* Generic.Subheading */ +.highlight .gt { color: #99CC66 } /* Generic.Traceback */ +.highlight .kc { color: #006699; font-weight: bold } /* Keyword.Constant */ +.highlight .kd { color: #006699; font-weight: bold } /* Keyword.Declaration */ +.highlight .kn { color: #006699; font-weight: bold } /* Keyword.Namespace */ +.highlight .kp { color: #006699 } /* Keyword.Pseudo */ +.highlight .kr { color: #006699; font-weight: bold } /* Keyword.Reserved */ +.highlight .kt { color: #007788; font-weight: bold } /* Keyword.Type */ +.highlight .m { color: #FF6600 } /* Literal.Number */ +.highlight .s { color: #CC3300 } /* Literal.String */ +.highlight .na { color: #330099 } /* Name.Attribute */ +.highlight .nb { color: #336666 } /* Name.Builtin */ +.highlight .nc { color: #00AA88; font-weight: bold } /* Name.Class */ +.highlight .no { color: #336600 } /* Name.Constant */ +.highlight .nd { color: #9999FF } /* Name.Decorator */ +.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */ +.highlight .ne { color: #CC0000; font-weight: bold } /* Name.Exception */ +.highlight .nf { color: #CC00FF } /* Name.Function */ +.highlight .nl { color: #9999FF } /* Name.Label */ +.highlight .nn { color: #00CCFF; font-weight: bold } /* Name.Namespace */ +.highlight .nt { color: #330099; font-weight: bold } /* Name.Tag */ +.highlight .nv { color: #003333 } /* Name.Variable */ +.highlight .ow { color: #000000; font-weight: bold } /* Operator.Word */ +.highlight .w { color: #bbbbbb } /* Text.Whitespace */ +.highlight .mf { color: #FF6600 } /* Literal.Number.Float */ +.highlight .mh { color: #FF6600 } /* Literal.Number.Hex */ +.highlight .mi { color: #FF6600 } /* Literal.Number.Integer */ +.highlight .mo { color: #FF6600 } /* Literal.Number.Oct */ +.highlight .sb { color: #CC3300 } /* Literal.String.Backtick */ +.highlight .sc { color: #CC3300 } /* Literal.String.Char */ +.highlight .sd { color: #CC3300; font-style: italic } /* Literal.String.Doc */ +.highlight .s2 { color: #CC3300 } /* Literal.String.Double */ +.highlight .se { color: #CC3300; font-weight: bold } /* Literal.String.Escape */ +.highlight .sh { color: #CC3300 } /* Literal.String.Heredoc */ +.highlight .si { color: #AA0000 } /* Literal.String.Interpol */ +.highlight .sx { color: #CC3300 } /* Literal.String.Other */ +.highlight .sr { color: #33AAAA } /* Literal.String.Regex */ +.highlight .s1 { color: #CC3300 } /* Literal.String.Single */ +.highlight .ss { color: #FFCC33 } /* Literal.String.Symbol */ +.highlight .bp { color: #336666 } /* Name.Builtin.Pseudo */ +.highlight .vc { color: #003333 } /* Name.Variable.Class */ +.highlight .vg { color: #003333 } /* Name.Variable.Global */ +.highlight .vi { color: #003333 } /* Name.Variable.Instance */ +.highlight .il { color: #FF6600 } /* Literal.Number.Integer.Long */ + +.type-csharp .highlight .k { color: #0000FF } +.type-csharp .highlight .kt { color: #0000FF } +.type-csharp .highlight .nf { color: #000000; font-weight: normal } +.type-csharp .highlight .nc { color: #2B91AF } +.type-csharp .highlight .nn { color: #000000 } +.type-csharp .highlight .s { color: #A31515 } +.type-csharp .highlight .sc { color: #A31515 } diff --git a/stylesheets/stylesheet.css b/stylesheets/stylesheet.css new file mode 100644 index 0000000..2bd468a --- /dev/null +++ b/stylesheets/stylesheet.css @@ -0,0 +1,431 @@ +/******************************************************************************* +Slate Theme for GitHub Pages +by Jason Costello, @jsncostello +*******************************************************************************/ + +@import url(pygment_trac.css); + +/******************************************************************************* +MeyerWeb Reset +*******************************************************************************/ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font: inherit; + vertical-align: baseline; +} + +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} + +ol, ul { + list-style: none; +} + +blockquote, q { +} + +table { + border-collapse: collapse; + border-spacing: 0; +} + +a:focus { + outline: none; +} + +/******************************************************************************* +Theme Styles +*******************************************************************************/ + +body { + box-sizing: border-box; + color:#373737; + background: #212121; + font-size: 16px; + font-family: 'Myriad Pro', Calibri, Helvetica, Arial, sans-serif; + line-height: 1.5; + -webkit-font-smoothing: antialiased; +} + +h1, h2, h3, h4, h5, h6 { + margin: 10px 0; + font-weight: 700; + color:#222222; + font-family: 'Lucida Grande', 'Calibri', Helvetica, Arial, sans-serif; + letter-spacing: -1px; +} + +h1 { + font-size: 36px; + font-weight: 700; +} + +h2 { + padding-bottom: 10px; + font-size: 32px; + background: url('../images/bg_hr.png') repeat-x bottom; +} + +h3 { + font-size: 24px; +} + +h4 { + font-size: 21px; +} + +h5 { + font-size: 18px; +} + +h6 { + font-size: 16px; +} + +p { + margin: 10px 0 15px 0; +} + +footer p { + color: #f2f2f2; +} + +a { + text-decoration: none; + color: #007edf; + text-shadow: none; + + transition: color 0.5s ease; + transition: text-shadow 0.5s ease; + -webkit-transition: color 0.5s ease; + -webkit-transition: text-shadow 0.5s ease; + -moz-transition: color 0.5s ease; + -moz-transition: text-shadow 0.5s ease; + -o-transition: color 0.5s ease; + -o-transition: text-shadow 0.5s ease; + -ms-transition: color 0.5s ease; + -ms-transition: text-shadow 0.5s ease; +} + +#main_content a:hover { + color: #0069ba; + text-shadow: #0090ff 0px 0px 2px; +} + +footer a:hover { + color: #43adff; + text-shadow: #0090ff 0px 0px 2px; +} + +em { + font-style: italic; +} + +strong { + font-weight: bold; +} + +img { + position: relative; + margin: 0 auto; + max-width: 739px; + padding: 5px; + margin: 10px 0 10px 0; + border: 1px solid #ebebeb; + + box-shadow: 0 0 5px #ebebeb; + -webkit-box-shadow: 0 0 5px #ebebeb; + -moz-box-shadow: 0 0 5px #ebebeb; + -o-box-shadow: 0 0 5px #ebebeb; + -ms-box-shadow: 0 0 5px #ebebeb; +} + +pre, code { + width: 100%; + color: #222; + background-color: #fff; + + font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; + font-size: 14px; + + border-radius: 2px; + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + + + +} + +pre { + width: 100%; + padding: 10px; + box-shadow: 0 0 10px rgba(0,0,0,.1); + overflow: auto; +} + +code { + padding: 3px; + margin: 0 3px; + box-shadow: 0 0 10px rgba(0,0,0,.1); +} + +pre code { + display: block; + box-shadow: none; +} + +blockquote { + color: #666; + margin-bottom: 20px; + padding: 0 0 0 20px; + border-left: 3px solid #bbb; +} + +ul, ol, dl { + margin-bottom: 15px +} + +ul li { + list-style: inside; + padding-left: 20px; +} + +ol li { + list-style: decimal inside; + padding-left: 20px; +} + +dl dt { + font-weight: bold; +} + +dl dd { + padding-left: 20px; + font-style: italic; +} + +dl p { + padding-left: 20px; + font-style: italic; +} + +hr { + height: 1px; + margin-bottom: 5px; + border: none; + background: url('../images/bg_hr.png') repeat-x center; +} + +table { + border: 1px solid #373737; + margin-bottom: 20px; + text-align: left; + } + +th { + font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif; + padding: 10px; + background: #373737; + color: #fff; + } + +td { + padding: 10px; + border: 1px solid #373737; + } + +form { + background: #f2f2f2; + padding: 20px; +} + +img { + width: 100%; + max-width: 100%; +} + +/******************************************************************************* +Full-Width Styles +*******************************************************************************/ + +.outer { + width: 100%; +} + +.inner { + position: relative; + max-width: 640px; + padding: 20px 10px; + margin: 0 auto; +} + +#forkme_banner { + display: block; + position: absolute; + top:0; + right: 10px; + z-index: 10; + padding: 10px 50px 10px 10px; + color: #fff; + background: url('../images/blacktocat.png') #0090ff no-repeat 95% 50%; + font-weight: 700; + box-shadow: 0 0 10px rgba(0,0,0,.5); + border-bottom-left-radius: 2px; + border-bottom-right-radius: 2px; +} + +#header_wrap { + background: #212121; + background: -moz-linear-gradient(top, #373737, #212121); + background: -webkit-linear-gradient(top, #373737, #212121); + background: -ms-linear-gradient(top, #373737, #212121); + background: -o-linear-gradient(top, #373737, #212121); + background: linear-gradient(top, #373737, #212121); +} + +#header_wrap .inner { + padding: 50px 10px 30px 10px; +} + +#project_title { + margin: 0; + color: #fff; + font-size: 42px; + font-weight: 700; + text-shadow: #111 0px 0px 10px; +} + +#project_tagline { + color: #fff; + font-size: 24px; + font-weight: 300; + background: none; + text-shadow: #111 0px 0px 10px; +} + +#downloads { + position: absolute; + width: 210px; + z-index: 10; + bottom: -40px; + right: 0; + height: 70px; + background: url('../images/icon_download.png') no-repeat 0% 90%; +} + +.zip_download_link { + display: block; + float: right; + width: 90px; + height:70px; + text-indent: -5000px; + overflow: hidden; + background: url(../images/sprite_download.png) no-repeat bottom left; +} + +.tar_download_link { + display: block; + float: right; + width: 90px; + height:70px; + text-indent: -5000px; + overflow: hidden; + background: url(../images/sprite_download.png) no-repeat bottom right; + margin-left: 10px; +} + +.zip_download_link:hover { + background: url(../images/sprite_download.png) no-repeat top left; +} + +.tar_download_link:hover { + background: url(../images/sprite_download.png) no-repeat top right; +} + +#main_content_wrap { + background: #f2f2f2; + border-top: 1px solid #111; + border-bottom: 1px solid #111; +} + +#main_content { + padding-top: 40px; +} + +#footer_wrap { + background: #212121; +} + + + +/******************************************************************************* +Small Device Styles +*******************************************************************************/ + +@media screen and (max-width: 480px) { + body { + font-size:14px; + } + + #downloads { + display: none; + } + + .inner { + min-width: 320px; + max-width: 480px; + } + + #project_title { + font-size: 32px; + } + + h1 { + font-size: 28px; + } + + h2 { + font-size: 24px; + } + + h3 { + font-size: 21px; + } + + h4 { + font-size: 18px; + } + + h5 { + font-size: 14px; + } + + h6 { + font-size: 12px; + } + + code, pre { + min-width: 320px; + max-width: 480px; + font-size: 11px; + } + +} diff --git a/subdir.mk b/subdir.mk deleted file mode 100644 index 5ecd9f7..0000000 --- a/subdir.mk +++ /dev/null @@ -1,27 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -# Add inputs and outputs from these tool invocations to the build variables -CPP_SRCS += \ -./AnyOption.cpp \ -./DASHEncoder.cpp - -OBJS += \ -./AnyOption.o \ -./DASHEncoder.o - -CPP_DEPS += \ -./AnyOption.d \ -./DASHEncoder.d - - -# Each subdirectory must supply rules for building sources it contributes -%.o: ./%.cpp - @echo 'Building file: $<' - @echo 'Invoking: GCC C++ Compiler' - g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" - @echo 'Finished building: $<' - @echo ' ' - -