| 178 | #define check(value, ...) check_func(value, __LINE__, __VA_ARGS__) |
| 179 | |
| 180 | static void init_fps(int bf, int audio_preroll, int fps, int id3) |
| 181 | { |
| 182 | AVStream *st; |
| 183 | int iobuf_size = force_iobuf_size ? force_iobuf_size : sizeof(iobuf); |
| 184 | ctx = avformat_alloc_context(); |
| 185 | if (!ctx) |
| 186 | exit(1); |
| 187 | ctx->oformat = av_guess_format(format, NULL, NULL); |
| 188 | if (!ctx->oformat) |
| 189 | exit(1); |
| 190 | ctx->pb = avio_alloc_context(iobuf, iobuf_size, 1, NULL, NULL, io_write, NULL); |
| 191 | if (!ctx->pb) |
| 192 | exit(1); |
| 193 | ctx->pb->write_data_type = io_write_data_type; |
| 194 | ctx->flags |= AVFMT_FLAG_BITEXACT; |
| 195 | |
| 196 | st = avformat_new_stream(ctx, NULL); |
| 197 | if (!st) |
| 198 | exit(1); |
| 199 | st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; |
| 200 | st->codecpar->codec_id = AV_CODEC_ID_H264; |
| 201 | st->codecpar->width = 640; |
| 202 | st->codecpar->height = 480; |
| 203 | st->time_base.num = 1; |
| 204 | st->time_base.den = 30; |
| 205 | st->codecpar->extradata_size = sizeof(h264_extradata); |
| 206 | st->codecpar->extradata = av_mallocz(st->codecpar->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); |
| 207 | if (!st->codecpar->extradata) |
| 208 | exit(1); |
| 209 | memcpy(st->codecpar->extradata, h264_extradata, sizeof(h264_extradata)); |
| 210 | video_st = st; |
| 211 | |
| 212 | st = avformat_new_stream(ctx, NULL); |
| 213 | if (!st) |
| 214 | exit(1); |
| 215 | st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; |
| 216 | st->codecpar->codec_id = AV_CODEC_ID_AAC; |
| 217 | st->codecpar->sample_rate = 44100; |
| 218 | st->codecpar->frame_size = 1024; |
| 219 | st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; |
| 220 | st->time_base.num = 1; |
| 221 | st->time_base.den = 44100; |
| 222 | st->codecpar->extradata_size = sizeof(aac_extradata); |
| 223 | st->codecpar->extradata = av_mallocz(st->codecpar->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); |
| 224 | if (!st->codecpar->extradata) |
| 225 | exit(1); |
| 226 | memcpy(st->codecpar->extradata, aac_extradata, sizeof(aac_extradata)); |
| 227 | audio_st = st; |
| 228 | |
| 229 | if (id3) { |
| 230 | st = avformat_new_stream(ctx, NULL); |
| 231 | if (!st) |
| 232 | exit(1); |
| 233 | st->codecpar->codec_type = AVMEDIA_TYPE_DATA; |
| 234 | st->codecpar->codec_id = AV_CODEC_ID_TIMED_ID3; |
| 235 | st->time_base.num = 1; |
| 236 | st->time_base.den = 1000; |
| 237 | id3_st = st; |
no test coverage detected