Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ffmpeg video encode draft

Initialize

  1. AVCodec* avcodec_find_encoder(AVCodecID)
  2. AVCodecContext* avcodec_alloc_context3(AVCodec*)
    1. av_opt_set(...)
    2. avcodec_open2(AVCodecContext*, AVCodecID)

Initialize additional

  • AVPacket* av_packet_alloc()
  • AVFrame* av_frame_alloc()
    • av_frame_get_buffer(AVFrame*)
  • struct SwsContext* sws_getContext()

Work in loop

  1. FILL FRAME DATA
  2. sws_scale(struct SwsContext*, ...) IF NEEDED
  3. avcodec_send_frame(AVCodecContext*, AVFrame*)
    1. avcodec_receive_packet(AVCodecContext*, AVPacket*) IF READY
    2. SAVE PACKET DATA
    3. av_packet_unref(AVPacket*)

Finalize additional

  • av_packet_free(AVPacket**)
  • av_frame_free(AVFrame**)
  • sws_freeContext(struct SwsContext*)

Finalize

  • avcodec_free_context(AVCodecContext**)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.