|
1 | 1 |
|
| 2 | +#include <mediaCore/Library.hpp> |
2 | 3 | #include <mediaCore/progress/NoDisplayProgress.hpp>
|
3 | 4 |
|
4 | 5 | #include <mediaIO/file/InputFile.hpp>
|
|
8 | 9 |
|
9 | 10 | int main( int argc, char** argv )
|
10 | 11 | {
|
11 |
| - if( argc != 2 ) |
| 12 | + using namespace mediaengine; |
| 13 | + |
| 14 | + bool help = false; |
| 15 | + bool version = false; |
| 16 | + |
| 17 | + for( size_t argIndex = 1; argIndex < argc; ++argIndex ) |
12 | 18 | {
|
13 |
| - std::cout << "mediameta require a media filename" << std::endl; |
14 |
| - return( -1 ); |
| 19 | + std::string arg( argv[argIndex]); |
| 20 | + if( !strcmp( argv[argIndex], "-h") || |
| 21 | + !strcmp( argv[argIndex], "-H") || |
| 22 | + !strcmp( argv[argIndex], "--help") ) |
| 23 | + help = true; |
| 24 | + |
| 25 | + if( !strcmp( argv[argIndex], "-V") || |
| 26 | + !strcmp( argv[argIndex], "--version" ) ) |
| 27 | + version = true; |
15 | 28 | }
|
16 | 29 |
|
17 |
| - using namespace mediaengine; |
| 30 | + if( help ) |
| 31 | + { |
| 32 | + std::cout << "mediameta - " << MEDIA_ENGINE_VERSION_MAJOR << "." << MEDIA_ENGINE_VERSION_MINOR << "." << MEDIA_ENGINE_VERSION_MICRO << std::endl; |
| 33 | + std::cout << std::endl; |
| 34 | + std::cout << "display media metadatas for each input file" << std::endl; |
| 35 | + std::cout << std::endl; |
| 36 | + std::cout << "mediameta [OPTIONS] [FILENAMES]" << std::endl; |
| 37 | + std::cout << std::endl; |
| 38 | + std::cout << "OPTIONS:" << std::endl; |
| 39 | + std::cout << "-h, -H, --help: Display this help" << std::endl; |
| 40 | + std::cout << "-v, --version: Print library version and FFMpeg/Libav version." << std::endl; |
| 41 | + std::cout << " Also display license." << std::endl; |
| 42 | + return 0; |
| 43 | + } |
| 44 | + |
| 45 | + if( version ) |
| 46 | + { |
| 47 | + mediacore::Libraries libs( mediacore::getLibraries() ); |
| 48 | + |
| 49 | + for( mediacore::Libraries::iterator library = libs.begin(); library != libs.end(); ++library ) |
| 50 | + { |
| 51 | + std::cout << std::left; |
| 52 | + std::cout << std::setw( 15 ) << (*library).getName(); |
| 53 | + std::cout << std::setw( 10 ) << (*library).getStringVersion(); |
| 54 | + std::cout << std::setw( 30 ) << (*library).getLicense(); |
| 55 | + std::cout << std::endl; |
| 56 | + } |
| 57 | + return 0; |
| 58 | + } |
18 | 59 |
|
19 | 60 | mediacore::NoDisplayProgress p;
|
20 | 61 |
|
21 |
| - mediaio::InputFile input( argv[1] ); |
22 |
| - input.analyse( p, mediaio::InputFile::eAnalyseLevelFull ); |
| 62 | + for( size_t argIndex = 1; argIndex < argc; ++argIndex ) |
| 63 | + { |
| 64 | + try |
| 65 | + { |
| 66 | + mediaio::InputFile input( argv[argIndex] ); |
| 67 | + input.analyse( p, mediaio::InputFile::eAnalyseLevelFull ); |
| 68 | + |
| 69 | + // a simply metadata display |
| 70 | + std::cout << input; |
| 71 | + } |
| 72 | + catch( std::runtime_error& e ) |
| 73 | + { |
| 74 | + std::cerr << "ERROR: " << e.what() << std::endl; |
| 75 | + } |
| 76 | + catch( ... ) |
| 77 | + { |
| 78 | + std::cerr << "ERROR: unknown error" << std::endl; |
| 79 | + } |
| 80 | + } |
| 81 | + |
23 | 82 |
|
24 |
| - // a simply metadata display |
25 |
| - std::cout << input; |
| 83 | + return 0; |
26 | 84 | }
|
0 commit comments