Ret = avcodec_receive_packet(codec_ctx, pkt) Ret = avcodec_send_frame(codec_ctx, converted_frame) Encode the frame and write it to the output converted_frame->time_base.num = codec_ctx->time_base.num converted_frame->time_n = codec_ctx->time_n Std::cerr data, converted_frame->linesizeĬonverted_frame->pts = av_rescale_q(frame_count, stream->time_base, codec_ctx->time_base) If (ret width, codec_ctx->height, codec_ctx->pix_fmt,Ĭodec_ctx->width, codec_ctx->height, AV_PIX_FMT_YUV420P, ![]() Ret = av_frame_get_buffer(converted_frame, 0) Stream->codecpar->format = AV_PIX_FMT_YUV420P ĪVCodecContext* codec_ctx = avcodec_alloc_context3(codec) Ĭodec_ctx->time_base = stream->time_base Ĭodec_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER Ĭonverted_frame->width = codec_ctx->width Ĭonverted_frame->height = codec_ctx->height Stream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO If (ret codecpar->codec_id = AV_CODEC_ID_H264 If (ret pb, output_filename.c_str(), AVIO_FLAG_WRITE) Int ret = avformat_alloc_output_context2(&format_ctx, nullptr, nullptr, output_filename.c_str()) This is the function I used to saved the video: void SaveVideo(std::string& output_filename, std::vector video) I went through it with a debugger and everything seemed to work fine. ![]() The code runs without errors but both when I try to open the saved video file with the windows media and adobe Media Encoded they it says that it is in an unsupported format. I am trying to encode a vector of AVFrames to an MP4 file using the h264 codec.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |