@@ -41,7 +41,6 @@ std::vector<std::string> getPixelFormats( const std::string& videoCodecName )
41
41
else
42
42
{
43
43
const AVCodec* videoCodec = avcodec_find_encoder_by_name ( videoCodecName.c_str () );
44
-
45
44
if ( videoCodec && videoCodec->pix_fmts != NULL )
46
45
{
47
46
size_t pix_fmt = 0 ;
@@ -52,7 +51,7 @@ std::vector<std::string> getPixelFormats( const std::string& videoCodecName )
52
51
#else
53
52
const AVPixFmtDescriptor* pix_desc = av_pix_fmt_desc_get ( videoCodec->pix_fmts [pix_fmt] );
54
53
#endif
55
- if ( ! pix_desc->name )
54
+ if ( ! pix_desc || ! pix_desc ->name )
56
55
continue ;
57
56
pixelFormats.push_back ( std::string ( pix_desc->name ) );
58
57
++pix_fmt;
@@ -66,13 +65,15 @@ std::vector<std::string> getSampleFormats( const std::string& audioCodecName )
66
65
{
67
66
std::vector<std::string> sampleFormats;
68
67
68
+ // all audio codec concerned
69
69
if ( audioCodecName.empty () )
70
70
{
71
71
for ( size_t sampleFormat = 0 ; sampleFormat < AV_SAMPLE_FMT_NB; ++sampleFormat)
72
72
{
73
73
sampleFormats.push_back ( av_get_sample_fmt_name ( static_cast <AVSampleFormat>( sampleFormat ) ) );
74
74
}
75
75
}
76
+ // specific audio codec
76
77
else
77
78
{
78
79
const AVCodec* audioCodec = avcodec_find_encoder_by_name ( audioCodecName.c_str () );
@@ -109,10 +110,6 @@ std::vector<std::string> getFormatsLongNames()
109
110
AVOutputFormat* fmt = NULL ;
110
111
while ( ( fmt = av_oformat_next ( fmt ) ) )
111
112
{
112
- // add only format with video track
113
- if ( fmt->video_codec == AV_CODEC_ID_NONE )
114
- continue ;
115
-
116
113
if ( ! fmt->long_name )
117
114
continue ;
118
115
@@ -127,10 +124,6 @@ std::vector<std::string> getFormatsShortNames()
127
124
AVOutputFormat* fmt = NULL ;
128
125
while ( ( fmt = av_oformat_next ( fmt ) ) )
129
126
{
130
- // add only format with video track
131
- if ( fmt->video_codec == AV_CODEC_ID_NONE )
132
- continue ;
133
-
134
127
if ( ! fmt->name )
135
128
continue ;
136
129
0 commit comments