Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // search video stream
- video_stream_index = av_find_best_stream(format_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
- if (video_stream_index == -1) {
- log(LL_ERR, "No video stream in rstp feed");
- goto fail;
- }
- av_init_packet(&packet);
- output_ctx = avformat_alloc_context();
- av_read_play(format_ctx);
- ///////
- // Get the codec
- codec = avcodec_find_decoder(format_ctx->streams[video_stream_index]->codecpar->codec_id);
- if (!codec) {
- log(LL_ERR, "Decoder not found (rtsp)");
- goto fail;
- }
- // Add this to allocate the context by codec
- codec_ctx = avcodec_alloc_context3(codec);
- avcodec_get_context_defaults3(codec_ctx, codec);
- avcodec_parameters_to_context(codec_ctx, format_ctx->streams[video_stream_index]->codecpar);
- if (avcodec_open2(codec_ctx, codec, NULL) < 0) {
- log(LL_ERR, "avcodec_open2 failed");
- goto fail;
- }
- ///////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement