Files
Obsidian-Main/00.01. 資料收集/FFMPEG.canvas
Awin Huang 5d4e261181 vault backup: 2025-07-22 22:14:08
Affected files:
Too many files to list
2025-07-22 22:14:08 +08:00

49 lines
6.8 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"nodes":[
{"id":"d805f3dd80f785e6","type":"group","x":-1640,"y":-580,"width":1822,"height":1268,"label":"Encoding setting"},
{"id":"a2ee86873d432396","type":"group","x":-352,"y":338,"width":514,"height":333,"label":"Create SwrContext"},
{"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":"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":-155,"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,"color":"3"},
{"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,"color":"3"},
{"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,"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,"color":"3"},
{"id":"47e7b62d1a0bfa79","type":"text","text":"`avcodec_parameters_from_context(stream->codecpar, codecContext)`","x":-1040,"y":-160,"width":507,"height":50,"color":"3"},
{"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,"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,"color":"3"},
{"id":"e4fc1011aa51d648","type":"text","text":"`AVPacket* packet`","x":-997,"y":405,"width":250,"height":50,"color":"4"},
{"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":"5a46ad2c03434ac2","type":"text","text":"```cpp\navformat_write_header(formatContext, nullptr);\n```","x":-1605,"y":-560,"width":608,"height":50,"color":"3"},
{"id":"3338d0ae0a5d52e8","type":"text","text":"`AVCodec* codec`","x":-193,"y":-135,"width":250,"height":50,"color":"4"},
{"id":"eed8fddf0e282c05","type":"text","text":"`codec = avcodec_find_encoder(AV_CODEC_ID_MP3)`","x":-260,"y":-75,"width":402,"height":50,"color":"3"},
{"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":[
{"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"},
{"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"}
]
}