MCPcopy Create free account
hub / github.com/byhook/ffmpeg4android / read_ffserver_streams

Function read_ffserver_streams

ffmpeg-single-cmd/src/main/cpp/ffmpeg_opt.c:1911–1960  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1909}
1910
1911static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const char *filename)
1912{
1913 int i, err;
1914 AVFormatContext *ic = avformat_alloc_context();
1915
1916 ic->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
1917 ic->interrupt_callback = int_cb;
1918 err = avformat_open_input(&ic, filename, NULL, NULL);
1919 if (err < 0)
1920 return err;
1921 /* copy stream format */
1922 for(i=0;i<ic->nb_streams;i++) {
1923 AVStream *st;
1924 OutputStream *ost;
1925 AVCodec *codec;
1926 const char *enc_config;
1927
1928 codec = avcodec_find_encoder(ic->streams[i]->codecpar->codec_id);
1929 if (!codec) {
1930 av_log(s, AV_LOG_ERROR, "no encoder found for codec id %i\n", ic->streams[i]->codecpar->codec_id);
1931 return AVERROR(EINVAL);
1932 }
1933 if (codec->type == AVMEDIA_TYPE_AUDIO)
1934 opt_audio_codec(o, "c:a", codec->name);
1935 else if (codec->type == AVMEDIA_TYPE_VIDEO)
1936 opt_video_codec(o, "c:v", codec->name);
1937 ost = new_output_stream(o, s, codec->type, -1);
1938 st = ost->st;
1939
1940 avcodec_get_context_defaults3(st->codec, codec);
1941 enc_config = av_stream_get_recommended_encoder_configuration(ic->streams[i]);
1942 if (enc_config) {
1943 AVDictionary *opts = NULL;
1944 av_dict_parse_string(&opts, enc_config, "=", ",", 0);
1945 av_opt_set_dict2(st->codec, &opts, AV_OPT_SEARCH_CHILDREN);
1946 av_dict_free(&opts);
1947 }
1948
1949 if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && !ost->stream_copy)
1950 choose_sample_fmt(st, codec);
1951 else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && !ost->stream_copy)
1952 choose_pixel_fmt(st, st->codec, codec, st->codecpar->format);
1953 avcodec_copy_context(ost->enc_ctx, st->codec);
1954 if (enc_config)
1955 av_dict_parse_string(&ost->encoder_opts, enc_config, "=", ",", 0);
1956 }
1957
1958 avformat_close_input(&ic);
1959 return err;
1960}
1961
1962static void init_output_filter(OutputFilter *ofilter, OptionsContext *o,
1963 AVFormatContext *oc)

Callers 1

open_output_fileFunction · 0.85

Calls 5

opt_audio_codecFunction · 0.85
opt_video_codecFunction · 0.85
new_output_streamFunction · 0.85
choose_sample_fmtFunction · 0.85
choose_pixel_fmtFunction · 0.85

Tested by

no test coverage detected