Skip to content

Commit c74164f

Browse files
author
Clement Champetier
committed
avthumbnail app: add option --output to indicate the output filename
1 parent c86c4e1 commit c74164f

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

app/avThumbnail/avThumbnail.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ int main( int argc, char** argv )
88
{
99
std::string help;
1010
help += "Usage\n";
11-
help += "\tavthumbnail INPUT_FILE_NAME TIME [OUTPUT_FILE_NAME] [--frame] [--help]\n";
11+
help += "\tavthumbnail INPUT_FILE_NAME TIME [--output OUTPUT_FILE_NAME] [--frame] [--help]\n";
1212
help += "Command line options\n";
13-
help += "\tOUTPUT_FILE_NAME: name of the output file (thumbnail.jpg by default)\n";
13+
help += "\t--output OUTPUT_FILE_NAME: name of the output file (thumbnail.jpg by default)\n";
1414
help += "\t--frame: express TIME of where to seek in frame (in seconds by default)\n";
1515
help += "\t--help: display this help\n";
1616

@@ -31,10 +31,19 @@ int main( int argc, char** argv )
3131
{
3232
seekInFrame = true;
3333
}
34-
}
35-
if( argc > 3 )
36-
{
37-
outputFileName = arguments.at( 2 );
34+
if( arguments.at( argument ) == "--output" )
35+
{
36+
try
37+
{
38+
outputFileName = arguments.at( argument + 1 );
39+
}
40+
catch( const std::exception& e )
41+
{
42+
std::cout << "Error: need to indicate an output filename if you use option --output" << std::endl << std::endl;
43+
std::cout << help << std::endl;
44+
return 0;
45+
}
46+
}
3847
}
3948

4049
// Check required arguments
@@ -49,12 +58,12 @@ int main( int argc, char** argv )
4958
avtranscoder::preloadCodecsAndFormats();
5059

5160
// input file
52-
std::string inputFileName( argv[1] );
61+
std::string inputFileName( arguments.at( 0 ) );
5362
avtranscoder::InputFile intputFile( inputFileName );
5463
if( seekInFrame )
55-
intputFile.seekAtFrame( atoi( argv[2] ) );
64+
intputFile.seekAtFrame( atoi( arguments.at( 1 ).c_str() ) );
5665
else
57-
intputFile.seekAtTime( atof( argv[2] ) );
66+
intputFile.seekAtTime( atof( arguments.at( 1 ).c_str() ) );
5867

5968
// output file
6069
avtranscoder::ProfileLoader::Profile formatProfile;

0 commit comments

Comments
 (0)