MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / new_video_stream

Function new_video_stream

ffmpeg.c:3186–3322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3184}
3185
3186static void new_video_stream(AVFormatContext *oc)
3187{
3188 AVStream *st;
3189 AVCodecContext *video_enc;
3190 enum CodecID codec_id;
3191
3192 st = av_new_stream(oc, oc->nb_streams);
3193 if (!st) {
3194 fprintf(stderr, "Could not alloc stream\n");
3195 av_exit(1);
3196 }
3197 avcodec_get_context_defaults2(st->codec, AVMEDIA_TYPE_VIDEO);
3198 bitstream_filters[nb_output_files][oc->nb_streams - 1]= video_bitstream_filters;
3199 video_bitstream_filters= NULL;
3200
3201 avcodec_thread_init(st->codec, thread_count);
3202
3203 video_enc = st->codec;
3204
3205 if(video_codec_tag)
3206 video_enc->codec_tag= video_codec_tag;
3207
3208 if( (video_global_header&1)
3209 || (video_global_header==0 && (oc->oformat->flags & AVFMT_GLOBALHEADER))){
3210 video_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
3211 avcodec_opts[AVMEDIA_TYPE_VIDEO]->flags|= CODEC_FLAG_GLOBAL_HEADER;
3212 }
3213 if(video_global_header&2){
3214 video_enc->flags2 |= CODEC_FLAG2_LOCAL_HEADER;
3215 avcodec_opts[AVMEDIA_TYPE_VIDEO]->flags2|= CODEC_FLAG2_LOCAL_HEADER;
3216 }
3217
3218 if (video_stream_copy) {
3219 st->stream_copy = 1;
3220 video_enc->codec_type = AVMEDIA_TYPE_VIDEO;
3221 video_enc->sample_aspect_ratio =
3222 st->sample_aspect_ratio = av_d2q(frame_aspect_ratio*frame_height/frame_width, 255);
3223 } else {
3224 const char *p;
3225 int i;
3226 AVCodec *codec;
3227 AVRational fps= frame_rate.num ? frame_rate : (AVRational){25,1};
3228
3229 if (video_codec_name) {
3230 codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1,
3231 video_enc->strict_std_compliance);
3232 codec = avcodec_find_encoder_by_name(video_codec_name);
3233 output_codecs[nb_ocodecs] = codec;
3234 } else {
3235 codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_VIDEO);
3236 codec = avcodec_find_encoder(codec_id);
3237 }
3238
3239 video_enc->codec_id = codec_id;
3240
3241 set_context_opts(video_enc, avcodec_opts[AVMEDIA_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
3242
3243 if (codec && codec->supported_framerates && !force_fps)

Callers 2

opt_new_video_streamFunction · 0.85
opt_output_fileFunction · 0.85

Calls 15

av_new_streamFunction · 0.85
av_exitFunction · 0.85
av_d2qFunction · 0.85
find_codec_or_dieFunction · 0.85
av_guess_codecFunction · 0.85
avcodec_find_encoderFunction · 0.85
set_context_optsFunction · 0.85
av_find_nearest_q_idxFunction · 0.85
choose_pixel_fmtFunction · 0.85
av_reallocFunction · 0.85

Tested by

no test coverage detected