-
-
Save klaxa/7f26c2e5137e99ff5883aaeb52d7a248 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (i = 0; i < fmt->nb_streams; i++) { | |
in_stream = fmt->streams[i]; | |
out_stream = avformat_new_stream(seg->fmt_ctx, NULL); | |
if (!out_stream) { | |
av_log(seg->fmt_ctx, AV_LOG_WARNING, "Failed allocating output stream\n"); | |
continue; | |
} | |
ret = avcodec_parameters_copy(out_stream->codecpar, in_stream->codecpar); | |
if (ret < 0) { | |
av_log(seg->fmt_ctx, AV_LOG_WARNING, "Failed to copy context from input to output stream codec context\n"); | |
continue; | |
} | |
if (out_stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { | |
if (in_stream->sample_aspect_ratio.num) | |
out_stream->sample_aspect_ratio = in_stream->sample_aspect_ratio; | |
out_stream->avg_frame_rate = in_stream->avg_frame_rate; | |
out_stream->r_frame_rate = in_stream->r_frame_rate; | |
} | |
av_dict_copy(&out_stream->metadata, in_stream->metadata, 0); | |
} | |
av_dict_copy(&seg->fmt_ctx->metadata, fmt->metadata, 0); | |
seg->fmt_ctx->pb = seg->io_ctx; | |
ret = avformat_write_header(seg->fmt_ctx, NULL); | |
avio_flush(seg->io_ctx); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment