Skip to content

Commit 3d92212

Browse files
improve mediameta with option and multi-files analysis
1 parent b8902ac commit 3d92212

File tree

1 file changed

+66
-8
lines changed

1 file changed

+66
-8
lines changed

app/mediaMeta/mediaMeta.cpp

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
#include <mediaCore/Library.hpp>
23
#include <mediaCore/progress/NoDisplayProgress.hpp>
34

45
#include <mediaIO/file/InputFile.hpp>
@@ -8,19 +9,76 @@
89

910
int main( int argc, char** argv )
1011
{
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 )
1218
{
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;
1528
}
1629

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+
}
1859

1960
mediacore::NoDisplayProgress p;
2061

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+
2382

24-
// a simply metadata display
25-
std::cout << input;
83+
return 0;
2684
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy