| 3328 | } |
| 3329 | |
| 3330 | int of_open(const OptionsContext *o, const char *filename, Scheduler *sch) |
| 3331 | { |
| 3332 | Muxer *mux; |
| 3333 | AVFormatContext *oc; |
| 3334 | int err; |
| 3335 | OutputFile *of; |
| 3336 | |
| 3337 | int64_t recording_time = o->recording_time; |
| 3338 | int64_t stop_time = o->stop_time; |
| 3339 | |
| 3340 | mux = mux_alloc(); |
| 3341 | if (!mux) |
| 3342 | return AVERROR(ENOMEM); |
| 3343 | |
| 3344 | of = &mux->of; |
| 3345 | |
| 3346 | if (stop_time != INT64_MAX && recording_time != INT64_MAX) { |
| 3347 | stop_time = INT64_MAX; |
| 3348 | av_log(mux, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n"); |
| 3349 | } |
| 3350 | |
| 3351 | if (stop_time != INT64_MAX && recording_time == INT64_MAX) { |
| 3352 | int64_t start_time = o->start_time == AV_NOPTS_VALUE ? 0 : o->start_time; |
| 3353 | if (stop_time <= start_time) { |
| 3354 | av_log(mux, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n"); |
| 3355 | return AVERROR(EINVAL); |
| 3356 | } else { |
| 3357 | recording_time = stop_time - start_time; |
| 3358 | } |
| 3359 | } |
| 3360 | |
| 3361 | of->recording_time = recording_time; |
| 3362 | of->start_time = o->start_time; |
| 3363 | |
| 3364 | mux->limit_filesize = o->limit_filesize; |
| 3365 | av_dict_copy(&mux->opts, o->g->format_opts, 0); |
| 3366 | |
| 3367 | if (!strcmp(filename, "-")) |
| 3368 | filename = "pipe:"; |
| 3369 | |
| 3370 | err = avformat_alloc_output_context2(&oc, NULL, o->format, filename); |
| 3371 | if (!oc) { |
| 3372 | av_log(mux, AV_LOG_FATAL, "Error initializing the muxer for %s: %s\n", |
| 3373 | filename, av_err2str(err)); |
| 3374 | return err; |
| 3375 | } |
| 3376 | mux->fc = oc; |
| 3377 | |
| 3378 | av_strlcat(mux->log_name, "/", sizeof(mux->log_name)); |
| 3379 | av_strlcat(mux->log_name, oc->oformat->name, sizeof(mux->log_name)); |
| 3380 | |
| 3381 | |
| 3382 | if (recording_time != INT64_MAX) |
| 3383 | oc->duration = recording_time; |
| 3384 | |
| 3385 | oc->interrupt_callback = int_cb; |
| 3386 | |
| 3387 | if (o->bitexact) { |
nothing calls this directly
no test coverage detected