File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ extern "C" {
7
7
#include < libavutil/opt.h>
8
8
#include < libavutil/pixfmt.h>
9
9
#include < libavutil/pixdesc.h>
10
+ #include < libavutil/samplefmt.h>
10
11
}
11
12
12
13
#ifndef AV_OPT_FLAG_FILTERING_PARAM
@@ -322,4 +323,34 @@ std::vector<std::string> OptionLoader::getPixelFormats( const std::string& video
322
323
return pixelFormats;
323
324
}
324
325
326
+ std::vector<std::string> OptionLoader::getSampleFormats ( const std::string& audioCodecName ) const
327
+ {
328
+ std::vector<std::string> sampleFormats;
329
+
330
+ if ( audioCodecName.empty () )
331
+ {
332
+ for ( size_t sampleFormat = 0 ; sampleFormat < AV_SAMPLE_FMT_NB; ++sampleFormat)
333
+ {
334
+ sampleFormats.push_back ( av_get_sample_fmt_name ( static_cast <AVSampleFormat>( sampleFormat ) ) );
335
+ }
336
+ }
337
+ else
338
+ {
339
+ const AVCodec* audioCodec = avcodec_find_encoder_by_name ( audioCodecName.c_str () );
340
+ if ( audioCodec && audioCodec->sample_fmts != NULL )
341
+ {
342
+ size_t sample_fmt = 0 ;
343
+ while ( audioCodec->sample_fmts [sample_fmt] != -1 )
344
+ {
345
+ const char * sampleFormatName = av_get_sample_fmt_name ( audioCodec->sample_fmts [sample_fmt] );
346
+ if ( sampleFormatName )
347
+ sampleFormats.push_back ( std::string ( sampleFormatName ) );
348
+ sample_fmt++;
349
+ }
350
+ }
351
+ }
352
+
353
+ return sampleFormats;
354
+ }
355
+
325
356
}
Original file line number Diff line number Diff line change @@ -67,6 +67,12 @@ class OptionLoader
67
67
*/
68
68
std::vector<std::string> getPixelFormats ( const std::string& videoCodecName = " " ) const ;
69
69
70
+ /* *
71
+ * Get array of sample format supported by an audio codec.
72
+ * @param audioCodecName: the audio codec name (empty if not indicated, and so get all sample formats supported by all audio codecs).
73
+ */
74
+ std::vector<std::string> getSampleFormats ( const std::string& audioCodecName = " " ) const ;
75
+
70
76
private:
71
77
/* *
72
78
* @brief: load array of Option depending on the flags.
You can’t perform that action at this time.
0 commit comments