2/16/2023 0 Comments Ffmpeg h264 mp4![]() ![]() Further there is a shifting packets from h264 stream to mp4 container. ![]() Ret = avformat_write_header(ofmt_ctx, &dict) Ifmt_ctx->streams->codec->height = ifmt_ctx->streams->codec->coded_height = height Ĭreate output format context, unsigned char* avio_output_buffer = reinterpret_cast(av_malloc(AVIO_BUFFER_SIZE)) ĪVIOContext* avio_output_ctx = avio_alloc_context(avio_output_buffer, AVIO_BUFFER_SIZE,Īvformat_alloc_output_context2(&ofmt_ctx, NULL, "mp4", NULL) Īv_dict_set(&dict, "movflags", "faststart", 0) Īv_dict_set(&dict, "movflags", "frag_keyframe+empty_moov", 0) ĪVStream* outVideoStream = avformat_new_stream(ofmt_ctx, nullptr) Īvcodec_copy_context(outVideoStream->codec, ifmt_ctx->streams->codec) Set image size, ifmt_ctx->streams->codec->width = ifmt_ctx->streams->codec->coded_width = width Int ret = avformat_open_input(&ifmt_ctx, NULL, inFormat, NULL) Next, i create input format context, unsigned char* avio_input_buffer = reinterpret_cast (av_malloc(AVIO_BUFFER_SIZE)) ĪVIOContext* avio_input_ctx = avio_alloc_context(avio_input_buffer, AVIO_BUFFER_SIZE,ĪVFormatContext* ifmt_ctx = avformat_alloc_context() AVProbeData probeData ĪVInputFormat* inFormat = av_probe_input_format(&probeData, 1) Since i don't control the source of stream, i can not make assumptions about stream structure. I want to capture h264 video stream and pack it to mp4 container without changes. For brevity, the code omits error handling and memory management.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |