Skip to content

Commit febe4fb

Browse files
author
Clement Champetier
committed
avprocessor: can use arguments to generate silent / black
* --generate-black * --generate-silence
1 parent bd9d04d commit febe4fb

File tree

1 file changed

+43
-8
lines changed

1 file changed

+43
-8
lines changed

app/avProcessor/avProcessor.cpp

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@ static const size_t dummyWidth = 1920;
1212
static const size_t dummyHeight = 1080;
1313
static const std::string dummyPixelFormat = "yuv420p";
1414
static const std::string dummyVideoCodec = "mpeg2video";
15+
16+
static const size_t dummySampleRate = 48000;
17+
static const size_t dummyChannels = 1;
18+
static const std::string dummySampleFormat = "s16";
1519
static const std::string dummyAudioCodec = "pcm_s16le";
1620

21+
static bool useVideoGenerator = false;
22+
static bool useAudioGenerator = false;
23+
1724
bool verbose = false;
1825

1926
void parseConfigFile( const std::string& configFilename, avtranscoder::Transcoder& transcoder )
@@ -56,12 +63,24 @@ void parseConfigFile( const std::string& configFilename, avtranscoder::Transcode
5663
// dummy stream, need a ICodec (audio or video)
5764
if( ! filename.length() )
5865
{
59-
// video
60-
avtranscoder::VideoCodec inputVideoCodec( avtranscoder::eCodecTypeEncoder, dummyVideoCodec );
61-
avtranscoder::VideoFrameDesc imageDesc( dummyWidth, dummyHeight, dummyPixelFormat );
62-
inputVideoCodec.setImageParameters( imageDesc );
63-
64-
transcoder.add( filename, streamIndex, subStreamIndex, transcodeProfile, inputVideoCodec );
66+
if( useVideoGenerator )
67+
{
68+
// video
69+
avtranscoder::VideoCodec inputCodec( avtranscoder::eCodecTypeEncoder, dummyVideoCodec );
70+
avtranscoder::VideoFrameDesc imageDesc( dummyWidth, dummyHeight, dummyPixelFormat );
71+
inputCodec.setImageParameters( imageDesc );
72+
73+
transcoder.add( filename, streamIndex, subStreamIndex, transcodeProfile, inputCodec );
74+
}
75+
else
76+
{
77+
// audio
78+
avtranscoder::AudioCodec inputCodec( avtranscoder::eCodecTypeEncoder, dummyAudioCodec );
79+
avtranscoder::AudioFrameDesc audioDesc( dummySampleRate, dummyChannels, dummySampleFormat );
80+
inputCodec.setAudioParameters( audioDesc );
81+
82+
transcoder.add( filename, streamIndex, subStreamIndex, transcodeProfile, inputCodec );
83+
}
6584
}
6685
else
6786
{
@@ -76,14 +95,30 @@ void parseConfigFile( const std::string& configFilename, avtranscoder::Transcode
7695

7796
int main( int argc, char** argv )
7897
{
79-
if( argc != 3 )
98+
if( argc < 3 )
8099
{
81100
std::cout << "avprocessor require an input config file and an output media filename" << std::endl;
82101
return( -1 );
83102
}
84103

85-
av_log_set_level( AV_LOG_FATAL );
104+
std::vector< std::string > arguments;
105+
for( int argument = 1; argument < argc; ++argument )
106+
{
107+
arguments.push_back( argv[argument] );
108+
}
109+
for( size_t argument = 0; argument < arguments.size(); ++argument )
110+
{
111+
if( arguments.at( argument ) == "--generate-black" )
112+
{
113+
useVideoGenerator = true;
114+
}
115+
else if( arguments.at( argument ) == "--generate-silence" )
116+
{
117+
useAudioGenerator = true;
118+
}
119+
}
86120

121+
av_log_set_level( AV_LOG_FATAL );
87122
if( verbose )
88123
av_log_set_level( AV_LOG_DEBUG );
89124

0 commit comments

Comments
 (0)