vault backup: 2025-03-21 15:49:08

Affected files:
00. Inbox/未命名.canvas
This commit is contained in:
2025-03-21 15:49:08 +08:00
parent d0ea732510
commit dc481e5799

View File

@@ -1,37 +1,38 @@
{ {
"nodes":[ "nodes":[
{"id":"a2ee86873d432396","x":-573,"y":540,"width":514,"height":333,"type":"group","label":"Create SwrContext"}, {"id":"d805f3dd80f785e6","type":"group","x":-1640,"y":-580,"width":1822,"height":1268,"label":"Encoding setting"},
{"id":"2a931b85411c091e","type":"group","x":-1592,"y":960,"width":506,"height":260,"label":"Create InputFormat"}, {"id":"a2ee86873d432396","type":"group","x":-352,"y":338,"width":514,"height":333,"label":"Create SwrContext"},
{"id":"657749e452ae22a2","type":"group","x":-280,"y":-230,"width":425,"height":250,"label":"Create CodecContext by CODEC"}, {"id":"2a931b85411c091e","type":"group","x":-1596,"y":1160,"width":506,"height":260,"label":"Create InputFormat"},
{"id":"657749e452ae22a2","type":"group","x":-280,"y":-495,"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":"45483f8465f79ab6","type":"group","x":-1592,"y":385,"width":419,"height":240,"label":"Create Frame"},
{"id":"cc5b50aaf9428ed5","type":"group","x":-1080,"y":385,"width":415,"height":190,"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":"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":"dadd55c0e82a0f75","type":"group","x":-280,"y":-155,"width":442,"height":150,"label":"Create CODEC"},
{"id":"ba45f40b19ea44d3","type":"group","x":-1596,"y":110,"width":426,"height":150,"label":"Create AVFormatContext"}, {"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":"7e6ff8d4cb0730ad","type":"text","text":"`stream = avformat_new_stream(formatContext, nullptr);`","x":-1600,"y":-150,"width":435,"height":50,"color":"3"},
{"id":"8197b443d5d2a0ee","type":"text","text":"`AVStream* stream`","x":-1507,"y":-210,"width":250,"height":50,"color":"4"}, {"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":"ffb5250ae3d92551","type":"text","text":"`avformat_alloc_output_context2(&formatContext`)","x":-1576,"y":190,"width":386,"height":50,"color":"3"},
{"id":"4692d58b834eee84","type":"text","text":"`AVFormatContext* formatContext`","x":-1520,"y":130,"width":274,"height":50,"color":"4"}, {"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":"30b0024f3331c50d","type":"text","text":"```cpp\n// Initialize packet\npacket = av_packet_alloc();\n```","x":-1060,"y":475,"width":375,"height":80,"color":"3"},
{"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,"color":"3"},
{"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,"color":"3"},
{"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":"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":"bffaa80a186d9b54","type":"text","text":"`frame = av_frame_alloc();`","x":-1507,"y":465,"width":250,"height":50,"color":"3"},
{"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":"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,"color":"3"},
{"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":"e4fc1011aa51d648","type":"text","text":"`AVPacket* packet`","x":-997,"y":405,"width":250,"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":"8b456592b19b1bfd","type":"text","text":"```cpp\n avio_open(&formatContext->pb, filename.c_str(), AVIO_FLAG_WRITE)\n```","x":-1605,"y":-400,"width":608,"height":50,"color":"3"},
{"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":"5a46ad2c03434ac2","type":"text","text":"```cpp\navformat_write_header(formatContext, nullptr);\n```","x":-1605,"y":-560,"width":608,"height":50,"color":"3"},
{"id":"874b741be7463df8","x":-441,"y":345,"width":250,"height":50,"type":"text","text":"`swr_init(swrContext)`"}, {"id":"3338d0ae0a5d52e8","type":"text","text":"`AVCodec* codec`","x":-193,"y":-135,"width":250,"height":50,"color":"4"},
{"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":"eed8fddf0e282c05","type":"text","text":"`codec = avcodec_find_encoder(AV_CODEC_ID_MP3)`","x":-260,"y":-75,"width":402,"height":50,"color":"3"},
{"id":"5a46ad2c03434ac2","x":-1605,"y":-560,"width":608,"height":50,"type":"text","text":"```cpp\navformat_write_header(formatContext, nullptr);\n```"} {"id":"b9f9abb339e512d2","type":"text","text":"`avcodec_open2(codecContext, codec, nullptr);`","x":-255,"y":-345,"width":375,"height":50,"color":"3"},
{"id":"b083af0a802c90b1","type":"text","text":"`codecContext = avcodec_alloc_context3(codec);`","x":-260,"y":-415,"width":385,"height":50,"color":"3"},
{"id":"bf7f90f77714e446","type":"text","text":"`AVCodecContext* codecContext`","x":-214,"y":-475,"width":274,"height":50,"color":"4"},
{"id":"8fb6f1a9be16335c","type":"text","text":"`SwrContext* swrContext`","x":-215,"y":358,"width":240,"height":50,"color":"4"},
{"id":"9133e5adf36a8d71","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```","x":-332,"y":428,"width":474,"height":223,"color":"3"},
{"id":"874b741be7463df8","type":"text","text":"`swr_init(swrContext)`","x":-220,"y":143,"width":250,"height":50,"color":"3"},
{"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":-1576,"y":1247,"width":466,"height":153,"color":"3"},
{"id":"ea1c0844ef8f1cfa","type":"text","text":"`AVSampleFormat inputFormat;`","x":-1477,"y":1180,"width":269,"height":50,"color":"4"},
{"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":-55,"width":513,"height":270}
], ],
"edges":[ "edges":[
{"id":"1473a901cc2657ec","fromNode":"dadd55c0e82a0f75","fromSide":"top","toNode":"657749e452ae22a2","toSide":"bottom"}, {"id":"1473a901cc2657ec","fromNode":"dadd55c0e82a0f75","fromSide":"top","toNode":"657749e452ae22a2","toSide":"bottom"},