From d0ea7325101e16e9dfe7b7e34ce96d288c44917d Mon Sep 17 00:00:00 2001 From: Awin Huang Date: Fri, 21 Mar 2025 15:38:45 +0800 Subject: [PATCH] vault backup: 2025-03-21 15:38:45 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Affected files: 00. Inbox/未命名.canvas --- 00. Inbox/未命名.canvas | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/00. Inbox/未命名.canvas b/00. Inbox/未命名.canvas index 4cd2d1a..d2c3b8e 100644 --- a/00. Inbox/未命名.canvas +++ b/00. Inbox/未命名.canvas @@ -1,9 +1,10 @@ { "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":"a2ee86873d432396","x":-573,"y":540,"width":514,"height":333,"type":"group","label":"Create SwrContext"}, + {"id":"2a931b85411c091e","type":"group","x":-1592,"y":960,"width":506,"height":260,"label":"Create InputFormat"}, + {"id":"657749e452ae22a2","type":"group","x":-280,"y":-230,"width":425,"height":250,"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":"cc5b50aaf9428ed5","type":"group","x":-1080,"y":385,"width":415,"height":190,"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"}, @@ -11,21 +12,26 @@ {"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":"30b0024f3331c50d","type":"text","text":"```cpp\n// Initialize packet\npacket = av_packet_alloc();\n```","x":-1060,"y":475,"width":375,"height":80}, + {"id":"4e2180f848416962","type":"text","text":"# Encoding 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```","x":-2440,"y":20,"width":513,"height":270}, + {"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":"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":"49c0e52749200a34","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```","x":-1572,"y":1047,"width":466,"height":153}, + {"id":"ea1c0844ef8f1cfa","type":"text","text":"`AVSampleFormat inputFormat;`","x":-1473,"y":980,"width":269,"height":50}, {"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"} + {"id":"bf7f90f77714e446","type":"text","text":"`AVCodecContext* codecContext`","x":-214,"y":-210,"width":274,"height":50,"color":"4"}, + {"id":"e4fc1011aa51d648","type":"text","text":"`AVPacket* packet`","x":-997,"y":405,"width":250,"height":50,"color":"4"}, + {"id":"8fb6f1a9be16335c","x":-436,"y":560,"width":240,"height":50,"type":"text","text":"`SwrContext* swrContext`"}, + {"id":"9133e5adf36a8d71","x":-553,"y":630,"width":474,"height":223,"type":"text","text":"```cpp\nswrContext = swr_alloc_set_opts(nullptr,\n codecContext->channel_layout, \n codecContext->sample_fmt, \n codecContext->sample_rate,\n codecContext->channel_layout, \n inputFormat, \n codecContext->sample_rate,\n 0, \n nullptr);\n```"}, + {"id":"874b741be7463df8","x":-441,"y":345,"width":250,"height":50,"type":"text","text":"`swr_init(swrContext)`"}, + {"id":"8b456592b19b1bfd","x":-1605,"y":-400,"width":608,"height":50,"type":"text","text":"```cpp\n avio_open(&formatContext->pb, filename.c_str(), AVIO_FLAG_WRITE)\n```"}, + {"id":"5a46ad2c03434ac2","x":-1605,"y":-560,"width":608,"height":50,"type":"text","text":"```cpp\navformat_write_header(formatContext, nullptr);\n```"} ], "edges":[ {"id":"1473a901cc2657ec","fromNode":"dadd55c0e82a0f75","fromSide":"top","toNode":"657749e452ae22a2","toSide":"bottom"}, @@ -34,6 +40,9 @@ {"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"} + {"id":"dcdd7e303f3e2074","fromNode":"b083af0a802c90b1","fromSide":"left","toNode":"5f8636c9725a3ffe","toSide":"right"}, + {"id":"53b5d223a9723660","fromNode":"a2ee86873d432396","fromSide":"top","toNode":"874b741be7463df8","toSide":"bottom"}, + {"id":"3fe3b152acfcd0fd","fromNode":"a8a281b03160720c","fromSide":"top","toNode":"8b456592b19b1bfd","toSide":"bottom"}, + {"id":"96808ae6e1387eb3","fromNode":"8b456592b19b1bfd","fromSide":"top","toNode":"5a46ad2c03434ac2","toSide":"bottom"} ] } \ No newline at end of file