Skip to content

Commit 96cdd4e

Browse files
adding metadata factoring, and easy clock
1 parent 4551567 commit 96cdd4e

File tree

3 files changed

+163
-132
lines changed

3 files changed

+163
-132
lines changed

app/avMeta/avMeta.cpp

Lines changed: 7 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,7 @@
1-
#include <iostream>
2-
#include <iomanip>
3-
4-
#include <AvTranscoder/InputStream.hpp>
5-
#include <AvTranscoder/InputStreamAudio.hpp>
6-
#include <AvTranscoder/InputStreamVideo.hpp>
7-
#include <AvTranscoder/OutputStream.hpp>
8-
#include <AvTranscoder/OutputStreamAudio.hpp>
9-
#include <AvTranscoder/OutputStreamVideo.hpp>
101
#include <AvTranscoder/InputFile.hpp>
11-
#include <AvTranscoder/OutputFile.hpp>
12-
13-
#include <AvTranscoder/ColorTransform.hpp>
14-
15-
#include <AvTranscoder/DatasStructures/VideoDesc.hpp>
16-
#include <AvTranscoder/DatasStructures/Image.hpp>
17-
18-
void displayMetadatas( const char* filename )
19-
{
20-
using namespace avtranscoder;
21-
22-
std::string separator( "====================" );
23-
size_t keyWidth = 32;
24-
25-
26-
InputFile input( filename );
27-
input.analyse();
28-
std::cout << std::left;
29-
std::cout << separator << " Wrapper " << separator << std::endl;
30-
std::cout << std::setw( keyWidth ) << "filename" << ": " << input.getProperties().filename << std::endl;
31-
std::cout << std::setw( keyWidth ) << "format name" << ": " << input.getProperties().formatName << std::endl;
32-
std::cout << std::setw( keyWidth ) << "format long name" << ": " << input.getProperties().formatLongName << std::endl;
33-
std::cout << std::setw( keyWidth ) << "start time" << ": " << input.getProperties().startTime << std::endl;
34-
std::cout << std::setw( keyWidth ) << "duration" << ": " << input.getProperties().duration << std::endl;
35-
std::cout << std::setw( keyWidth ) << "bitrate" << ": " << input.getProperties().bitRate << std::endl;
36-
std::cout << std::setw( keyWidth ) << "number of streams" << ": " << input.getProperties().streamsCount << std::endl;
37-
std::cout << std::setw( keyWidth ) << "number of programs" << ": " << input.getProperties().programsCount << std::endl;
38-
std::cout << std::setw( keyWidth ) << "number of video streams" << ": " << input.getProperties().videoStreams.size() << std::endl;
39-
std::cout << std::setw( keyWidth ) << "number of audio streams" << ": " << input.getProperties().audioStreams.size() << std::endl;
40-
std::cout << std::setw( keyWidth ) << "number of data streams" << ": " << input.getProperties().dataStreams.size() << std::endl;
41-
std::cout << std::setw( keyWidth ) << "number of subtitle streams" << ": " << input.getProperties().subtitleStreams.size() << std::endl;
42-
std::cout << std::setw( keyWidth ) << "number of attachement streams" << ": " << input.getProperties().attachementStreams.size() << std::endl;
43-
std::cout << std::setw( keyWidth ) << "number of unknown streams" << ": " << input.getProperties().unknownStreams.size() << std::endl;
44-
45-
46-
// std::vector< std::pair< std::string, std::string > > metadatas
47-
std::cout << separator << " Metadatas " << separator << std::endl;
48-
for( size_t metadataIndex = 0; metadataIndex < input.getProperties().metadatas.size(); ++metadataIndex )
49-
{
50-
std::cout << std::setw( keyWidth ) << input.getProperties().metadatas.at(metadataIndex).first << ": " << input.getProperties().metadatas.at(metadataIndex).second << std::endl;
51-
}
2+
#include <AvTranscoder/Metadatas/Print.hpp>
523

53-
for( size_t videoStreamIndex = 0; videoStreamIndex < input.getProperties().videoStreams.size(); ++videoStreamIndex )
54-
{
55-
std::cout << separator << " Video stream " << videoStreamIndex << " " << separator << std::endl;
56-
std::cout << std::setw( keyWidth ) << "codec name" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).codecName << std::endl;
57-
std::cout << std::setw( keyWidth ) << "codec long name" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).codecLongName << std::endl;
58-
std::cout << std::setw( keyWidth ) << "codec id" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).codecId << std::endl;
59-
std::cout << std::setw( keyWidth ) << "stream id" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).streamId << std::endl;
60-
std::cout << std::setw( keyWidth ) << "profile name" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).profileName << std::endl;
61-
std::cout << std::setw( keyWidth ) << "profile" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).profile << std::endl;
62-
std::cout << std::setw( keyWidth ) << "level" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).level << std::endl;
63-
std::cout << std::setw( keyWidth ) << "width" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).width << std::endl;
64-
std::cout << std::setw( keyWidth ) << "height" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).height << std::endl;
65-
std::cout << std::setw( keyWidth ) << "dtgActiveFormat" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).dtgActiveFormat << std::endl;
66-
67-
68-
std::cout << std::setw( keyWidth ) << "start timecode" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).startTimecode << std::endl;
69-
std::cout << std::setw( keyWidth ) << "timeBase" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).timeBase.num << "/" <<
70-
input.getProperties().videoStreams.at(videoStreamIndex).timeBase.den << std::endl;
71-
std::cout << std::setw( keyWidth ) << "fps" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).fps << std::endl;
72-
std::cout << std::setw( keyWidth ) << "ticksPerFrame" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).ticksPerFrame << std::endl;
73-
74-
std::cout << std::setw( keyWidth ) << "pixel aspect ratio" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).sar.num << "/" <<
75-
input.getProperties().videoStreams.at(videoStreamIndex).sar.den << std::endl;
76-
std::cout << std::setw( keyWidth ) << "display aspect ratio" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).dar.num << "/" <<
77-
input.getProperties().videoStreams.at(videoStreamIndex).dar.den << std::endl;
78-
std::cout << std::setw( keyWidth ) << "pixel type" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).pixelName << std::endl;
79-
std::cout << std::setw( keyWidth ) << "bit wise acked" << ": " << ( input.getProperties().videoStreams.at(videoStreamIndex).bitWisePacked ? "True" : "False" ) << std::endl;
80-
std::cout << std::setw( keyWidth ) << "rgb pixel" << ": " << ( input.getProperties().videoStreams.at(videoStreamIndex).rgbPixelData ? "True" : "False" ) << std::endl;
81-
std::cout << std::setw( keyWidth ) << "as alpha" << ": " << ( input.getProperties().videoStreams.at(videoStreamIndex).asAlpha ? "True" : "False" ) << std::endl;
82-
std::cout << std::setw( keyWidth ) << "endianess" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).endianess << std::endl;
83-
84-
std::cout << std::setw( keyWidth ) << "bit rate" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).bitRate << std::endl;
85-
std::cout << std::setw( keyWidth ) << "max bit rate" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).maxBitRate << std::endl;
86-
std::cout << std::setw( keyWidth ) << "min bit rate" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).minBitRate << std::endl;
87-
88-
std::cout << std::setw( keyWidth ) << "color transfert" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).colorTransfert << std::endl;
89-
std::cout << std::setw( keyWidth ) << "colorspace" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).colorspace << std::endl;
90-
std::cout << std::setw( keyWidth ) << "color range" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).colorRange << std::endl;
91-
std::cout << std::setw( keyWidth ) << "color primaries" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).colorPrimaries << std::endl;
92-
std::cout << std::setw( keyWidth ) << "indexed colors" << ": " << ( input.getProperties().videoStreams.at(videoStreamIndex).indexedColors ? "True" : "False" ) << std::endl;
93-
std::cout << std::setw( keyWidth ) << "pseudo paletted" << ": " << ( input.getProperties().videoStreams.at(videoStreamIndex).pseudoPaletted ? "True" : "False" ) << std::endl;
94-
std::cout << std::setw( keyWidth ) << "components count" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).componentsCount << std::endl;
95-
std::cout << std::setw( keyWidth ) << "chroma width" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).chromaWidth << std::endl;
96-
std::cout << std::setw( keyWidth ) << "chroma height" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).chromaHeight << std::endl;
97-
std::cout << std::setw( keyWidth ) << "chroma sample location" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).chromaSampleLocation << std::endl;
98-
std::cout << std::setw( keyWidth ) << "interlaced " << ": " << ( input.getProperties().videoStreams.at(videoStreamIndex).isInterlaced ? "True" : "False" ) << std::endl;
99-
std::cout << std::setw( keyWidth ) << "top field first" << ": " << ( input.getProperties().videoStreams.at(videoStreamIndex).topFieldFirst ? "True" : "False" ) << std::endl;
100-
std::cout << std::setw( keyWidth ) << "field order" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).fieldOrder << std::endl;
101-
std::cout << std::setw( keyWidth ) << "gop size" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).gopSize << std::endl;
102-
std::cout << std::setw( keyWidth ) << "has B frames" << ": " << ( input.getProperties().videoStreams.at(videoStreamIndex).hasBFrames ? "True" : "False" ) << std::endl;
103-
104-
std::cout << std::setw( keyWidth ) << "gop" << ": ";
105-
for( size_t frameIndex = 0; frameIndex < input.getProperties().videoStreams.at(videoStreamIndex).gopStructure.size(); ++frameIndex )
106-
{
107-
std::cout << input.getProperties().videoStreams.at(videoStreamIndex).gopStructure.at( frameIndex ).first;
108-
std::cout << ( input.getProperties().videoStreams.at(videoStreamIndex).gopStructure.at( frameIndex ).second ? "*" : " " );
109-
}
110-
std::cout << std::endl;
111-
std::cout << std::setw( keyWidth ) << "references frames" << ": " << input.getProperties().videoStreams.at(videoStreamIndex).referencesFrames << std::endl;
112-
113-
}
114-
for( size_t audioStreamIndex = 0; audioStreamIndex < input.getProperties().audioStreams.size(); ++audioStreamIndex )
115-
{
116-
std::cout << separator << " Audio stream " << audioStreamIndex << " " << separator << std::endl;
117-
std::cout << std::setw( keyWidth ) << "codec name" << ": " << input.getProperties().audioStreams.at(audioStreamIndex).codecName << std::endl;
118-
std::cout << std::setw( keyWidth ) << "codec long name" << ": " << input.getProperties().audioStreams.at(audioStreamIndex).codecLongName << std::endl;
119-
std::cout << std::setw( keyWidth ) << "sample format" << ": " << input.getProperties().audioStreams.at(audioStreamIndex).sampleFormat << std::endl;
120-
std::cout << std::setw( keyWidth ) << "codec id" << ": " << input.getProperties().audioStreams.at(audioStreamIndex).codecId << std::endl;
121-
std::cout << std::setw( keyWidth ) << "stream id" << ": " << input.getProperties().audioStreams.at(audioStreamIndex).streamId << std::endl;
122-
std::cout << std::setw( keyWidth ) << "sample rate" << ": " << input.getProperties().audioStreams.at(audioStreamIndex).sampleRate << std::endl;
123-
std::cout << std::setw( keyWidth ) << "channels" << ": " << input.getProperties().audioStreams.at(audioStreamIndex).channels << std::endl;
124-
std::cout << std::setw( keyWidth ) << "bit rate" << ": " << input.getProperties().audioStreams.at(audioStreamIndex).bit_rate << std::endl;
125-
}
126-
for( size_t dataStreamIndex = 0; dataStreamIndex < input.getProperties().dataStreams.size(); ++dataStreamIndex )
127-
{
128-
std::cout << separator << " Data stream " << dataStreamIndex << " " << separator << std::endl;
129-
std::cout << std::setw( keyWidth ) << "stream id" << ": " << input.getProperties().dataStreams.at(dataStreamIndex).streamId << std::endl;
130-
}
131-
}
4+
#include <iostream>
1325

1336
int main( int argc, char** argv )
1347
{
@@ -138,6 +11,9 @@ int main( int argc, char** argv )
13811
return( -1 );
13912
}
14013

141-
// a simply metadata getter
142-
displayMetadatas( argv[1] );
14+
avtranscoder::InputFile input( argv[1] );
15+
input.analyse();
16+
17+
// a simply metadata display
18+
displayMetadatas( input );
14319
}

app/avplay/main.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <AvTranscoder/InputStreamAudio.hpp>
44
#include <AvTranscoder/InputStreamVideo.hpp>
55
#include <AvTranscoder/InputFile.hpp>
6+
#include <AvTranscoder/Metadatas/Print.hpp>
67

78
#include <AvTranscoder/ColorTransform.hpp>
89

@@ -73,6 +74,7 @@ bool showAlphaChannel = false;
7374

7475
bool play = false;
7576

77+
avtranscoder::InputFile* pInputFile = NULL;
7678
avtranscoder::InputStreamVideo* pInputStreamVideo = NULL;
7779
avtranscoder::ColorTransform ct;
7880
avtranscoder::Image* pSourceImage = NULL;
@@ -282,10 +284,19 @@ void display()
282284
glutSwapBuffers();
283285
}
284286

287+
void loopPlaying( int value )
288+
{
289+
if( play )
290+
glutTimerFunc( 40, &loopPlaying, 0 );
291+
readAndLoadNextFrame();
292+
}
293+
285294
void idle()
286295
{
287296
if( play )
288-
readAndLoadNextFrame();
297+
{
298+
//loopPlaying(0);
299+
}
289300
}
290301

291302
void displayInformations()
@@ -397,6 +408,7 @@ void keyboard(unsigned char k, int x, int y)
397408
break;
398409
case SPACEBAR:
399410
play = !play;
411+
loopPlaying(0);
400412
break;
401413

402414
case 'r':
@@ -412,6 +424,10 @@ void keyboard(unsigned char k, int x, int y)
412424
showAlphaChannelTexture();
413425
break;
414426

427+
case 'm':
428+
avtranscoder::displayMetadatas( *pInputFile );
429+
break;
430+
415431
case 'H':
416432
if( shift )
417433
{
@@ -587,6 +603,7 @@ int main( int argc, char** argv )
587603

588604

589605
avtranscoder::InputFile inputFile( argv[1] );
606+
pInputFile = &inputFile;
590607

591608
inputFile.analyse();
592609
img.width = inputFile.getProperties().videoStreams.at(0).width;

0 commit comments

Comments
 (0)