{ "nodes":[ {"id":"2a931b85411c091e","x":-1592,"y":960,"width":506,"height":260,"type":"group","label":"Create InputFormat"}, {"id":"657749e452ae22a2","type":"group","x":-280,"y":-230,"width":425,"height":270,"label":"Create CodecContext by CODEC"}, {"id":"45483f8465f79ab6","type":"group","x":-1592,"y":385,"width":419,"height":240,"label":"Create Frame"}, {"id":"cc5b50aaf9428ed5","x":-1080,"y":385,"width":415,"height":190,"type":"group","label":"Create Packet"}, {"id":"a8a281b03160720c","type":"group","x":-1620,"y":-230,"width":475,"height":150,"label":"Create AVStream by AVFormatContext"}, {"id":"dadd55c0e82a0f75","type":"group","x":-280,"y":110,"width":442,"height":150,"label":"Create CODEC"}, {"id":"ba45f40b19ea44d3","type":"group","x":-1596,"y":110,"width":426,"height":150,"label":"Create AVFormatContext"}, {"id":"7e6ff8d4cb0730ad","type":"text","text":"`stream = avformat_new_stream(formatContext, nullptr);`","x":-1600,"y":-150,"width":435,"height":50}, {"id":"8197b443d5d2a0ee","type":"text","text":"`AVStream* stream`","x":-1507,"y":-210,"width":250,"height":50,"color":"4"}, {"id":"ffb5250ae3d92551","type":"text","text":"`avformat_alloc_output_context2(&formatContext`)","x":-1576,"y":190,"width":386,"height":50}, {"id":"4692d58b834eee84","type":"text","text":"`AVFormatContext* formatContext`","x":-1520,"y":130,"width":274,"height":50,"color":"4"}, {"id":"47e7b62d1a0bfa79","type":"text","text":"`avcodec_parameters_from_context(stream->codecpar, codecContext)`","x":-1040,"y":-160,"width":507,"height":50}, {"id":"3e5e2eb286b66064","type":"text","text":"`AVFrame* frame`","x":-1507,"y":405,"width":250,"height":50,"color":"4"}, {"id":"bffaa80a186d9b54","type":"text","text":"`frame = av_frame_alloc();`","x":-1507,"y":465,"width":250,"height":50}, {"id":"f3140664e1295662","type":"text","text":"```cpp\n// Allocate the data buffers\nret = av_frame_get_buffer(frame, 0);\n```","x":-1572,"y":525,"width":379,"height":80}, {"id":"30b0024f3331c50d","x":-1060,"y":475,"width":375,"height":80,"type":"text","text":"```cpp\n// Initialize packet\npacket = av_packet_alloc();\n```"}, {"id":"e4fc1011aa51d648","type":"text","text":"`AVPacket* packet`","x":-997,"y":405,"width":250,"height":60,"color":"4"}, {"id":"4e2180f848416962","x":-2440,"y":20,"width":513,"height":270,"type":"text","text":"# Parametes\n\n```cpp\nstruct EncoderConfig {\nint sampleRate = 44100;\nint channels = 2;\nint bitRate = 128000;\nint bitsPerSample = 16;\nint bufferFrames = 1024; // Number of frames per buffer\n};\n```"}, {"id":"49c0e52749200a34","x":-1572,"y":1047,"width":466,"height":153,"type":"text","text":"```cpp\nswitch (bitsPerSample) {\ncase 8: inputFormat = AV_SAMPLE_FMT_U8; break;\ncase 16: inputFormat = AV_SAMPLE_FMT_S16; break;\ncase 24:\ncase 32: inputFormat = AV_SAMPLE_FMT_S32; break;\ndefault: inputFormat = AV_SAMPLE_FMT_S16; break;\n}\n```"}, {"id":"ea1c0844ef8f1cfa","x":-1473,"y":980,"width":269,"height":50,"type":"text","text":"`AVSampleFormat inputFormat;`"}, {"id":"5f8636c9725a3ffe","type":"text","text":"```cpp\n// Set codec parameters\ncodecContext->bit_rate = bitRate;\ncodecContext->sample_rate = sampleRate;\ncodecContext->channels = channels;\ncodecContext->channel_layout = av_get_default_channel_layout(channels);\ncodecContext->sample_fmt = AV_SAMPLE_FMT_S16P; // MP3 encoder usually requires planar s16\n// Some formats need stream headers\nif (formatContext->oformat->flags & AVFMT_GLOBALHEADER) {\n codecContext->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;\n}\n```","x":-1106,"y":-30,"width":734,"height":298}, {"id":"b9f9abb339e512d2","type":"text","text":"`avcodec_open2(codecContext, codec, nullptr);`","x":-255,"y":-80,"width":375,"height":50}, {"id":"3338d0ae0a5d52e8","type":"text","text":"`AVCodec* codec`","x":-193,"y":130,"width":250,"height":50,"color":"4"}, {"id":"eed8fddf0e282c05","type":"text","text":"`codec = avcodec_find_encoder(AV_CODEC_ID_MP3)`","x":-260,"y":190,"width":402,"height":50}, {"id":"b083af0a802c90b1","type":"text","text":"`codecContext = avcodec_alloc_context3(codec);`","x":-260,"y":-150,"width":385,"height":50}, {"id":"bf7f90f77714e446","type":"text","text":"`AVCodecContext* codecContext`","x":-214,"y":-210,"width":274,"height":50,"color":"4"} ], "edges":[ {"id":"1473a901cc2657ec","fromNode":"dadd55c0e82a0f75","fromSide":"top","toNode":"657749e452ae22a2","toSide":"bottom"}, {"id":"2b3cdd328f451c81","fromNode":"ba45f40b19ea44d3","fromSide":"top","toNode":"a8a281b03160720c","toSide":"bottom"}, {"id":"b69dc1ba45835fbe","fromNode":"8197b443d5d2a0ee","fromSide":"right","toNode":"47e7b62d1a0bfa79","toSide":"left"}, {"id":"3e9fa7e107bf252c","fromNode":"b083af0a802c90b1","fromSide":"left","toNode":"47e7b62d1a0bfa79","toSide":"right"}, {"id":"5b43e072f1f0bf66","fromNode":"4e2180f848416962","fromSide":"right","toNode":"49c0e52749200a34","toSide":"left","toEnd":"none"}, {"id":"195888a93cc014b7","fromNode":"4e2180f848416962","fromSide":"right","toNode":"5f8636c9725a3ffe","toSide":"top","toEnd":"none"}, {"id":"dcdd7e303f3e2074","fromNode":"b083af0a802c90b1","fromSide":"left","toNode":"5f8636c9725a3ffe","toSide":"right"} ] }