From: Steinar H. Gunderson Date: Thu, 31 Mar 2016 18:57:35 +0000 (+0200) Subject: Fix issues with newer ffmpeg. X-Git-Tag: 1.2.0~40 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=72d1b1cd96eacf39732a8fc9791c7fcf4d7bf1c6;p=nageru Fix issues with newer ffmpeg. --- diff --git a/h264encode.cpp b/h264encode.cpp index a478c2a..913c888 100644 --- a/h264encode.cpp +++ b/h264encode.cpp @@ -1538,7 +1538,7 @@ void H264EncoderImpl::save_codeddata(storage_task task) pending_audio_frames.erase(it); } - AVFrame *frame = avcodec_alloc_frame(); + AVFrame *frame = av_frame_alloc(); frame->nb_samples = audio.size() / 2; frame->format = AV_SAMPLE_FMT_S32; frame->channel_layout = AV_CH_LAYOUT_STEREO; @@ -1570,7 +1570,7 @@ void H264EncoderImpl::save_codeddata(storage_task task) httpd->add_packet(pkt, audio_pts + global_delay, audio_pts + global_delay); } // TODO: Delayed frames. - avcodec_free_frame(&frame); + av_frame_unref(frame); av_free_packet(&pkt); if (audio_pts == task.pts) break; } diff --git a/httpd.cpp b/httpd.cpp index 3eda2a1..4b24890 100644 --- a/httpd.cpp +++ b/httpd.cpp @@ -115,6 +115,8 @@ HTTPD::Mux::Mux(AVFormatContext *avctx, int width, int height) exit(1); } avstream_video->time_base = AVRational{1, TIMEBASE}; + avstream_video->codec->codec_type = AVMEDIA_TYPE_VIDEO; + avstream_video->codec->codec_id = AV_CODEC_ID_H264; avstream_video->codec->width = width; avstream_video->codec->height = height; avstream_video->codec->time_base = AVRational{1, TIMEBASE}; diff --git a/image_input.cpp b/image_input.cpp index 2bd147d..ab1af28 100644 --- a/image_input.cpp +++ b/image_input.cpp @@ -85,10 +85,10 @@ const uint8_t *ImageInput::load_image(const string &filename) // TODO: Scale down if needed! AVPicture pic; - avpicture_alloc(&pic, PIX_FMT_RGBA, frame->width, frame->height); + avpicture_alloc(&pic, AV_PIX_FMT_RGBA, frame->width, frame->height); SwsContext *sws_ctx = sws_getContext(frame->width, frame->height, - (PixelFormat)frame->format, frame->width, frame->height, - PIX_FMT_RGBA, SWS_BICUBIC, nullptr, nullptr, nullptr); + (AVPixelFormat)frame->format, frame->width, frame->height, + AV_PIX_FMT_RGBA, SWS_BICUBIC, nullptr, nullptr, nullptr); if (sws_ctx == nullptr) { fprintf(stderr, "%s: Could not create scaler context\n", filename.c_str()); exit(1); @@ -98,7 +98,7 @@ const uint8_t *ImageInput::load_image(const string &filename) size_t len = frame->width * frame->height * 4; unique_ptr image_data(new uint8_t[len]); - av_image_copy_to_buffer(image_data.get(), len, pic.data, pic.linesize, PIX_FMT_RGBA, frame->width, frame->height, 1); + av_image_copy_to_buffer(image_data.get(), len, pic.data, pic.linesize, AV_PIX_FMT_RGBA, frame->width, frame->height, 1); avpicture_free(&pic); av_frame_free(&frame);