Fixes null pointer exception
Unified · Split
| @@ -116,6 +116,10 @@ static int open_output_file(const char *filename) · 115 unmodified lines | ||
| 116 | 116 | || dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) { |
| 117 | 117 | /* in this example, we choose transcoding to same codec */ |
| 118 | 118 | encoder = avcodec_find_encoder(dec_ctx->codec_id); |
| 119 | + if (!encoder) { | |
| 120 | + av_log(NULL, AV_LOG_FATAL, "Neccessary encoder not found\n"); | |
| 121 | + return AVERROR_INVALIDDATA; | |
| 122 | + } | |
| 119 | 123 | |
| 120 | 124 | /* In this example, we transcode to same properties (picture size, |
| 121 | 125 | * sample rate etc.). These properties can be changed for output |