| 2014 | } |
| 2015 | |
| 2016 | static int open_output_file(OptionsContext *o, const char *filename) |
| 2017 | { |
| 2018 | AVFormatContext *oc; |
| 2019 | int i, j, err; |
| 2020 | AVOutputFormat *file_oformat; |
| 2021 | OutputFile *of; |
| 2022 | OutputStream *ost; |
| 2023 | InputStream *ist; |
| 2024 | AVDictionary *unused_opts = NULL; |
| 2025 | AVDictionaryEntry *e = NULL; |
| 2026 | int format_flags = 0; |
| 2027 | |
| 2028 | if (o->stop_time != INT64_MAX && o->recording_time != INT64_MAX) { |
| 2029 | o->stop_time = INT64_MAX; |
| 2030 | av_log(NULL, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n"); |
| 2031 | } |
| 2032 | |
| 2033 | if (o->stop_time != INT64_MAX && o->recording_time == INT64_MAX) { |
| 2034 | int64_t start_time = o->start_time == AV_NOPTS_VALUE ? 0 : o->start_time; |
| 2035 | if (o->stop_time <= start_time) { |
| 2036 | av_log(NULL, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n"); |
| 2037 | exit_program(1); |
| 2038 | } else { |
| 2039 | o->recording_time = o->stop_time - start_time; |
| 2040 | } |
| 2041 | } |
| 2042 | |
| 2043 | GROW_ARRAY(output_files, nb_output_files); |
| 2044 | of = av_mallocz(sizeof(*of)); |
| 2045 | if (!of) |
| 2046 | exit_program(1); |
| 2047 | output_files[nb_output_files - 1] = of; |
| 2048 | |
| 2049 | of->ost_index = nb_output_streams; |
| 2050 | of->recording_time = o->recording_time; |
| 2051 | of->start_time = o->start_time; |
| 2052 | of->limit_filesize = o->limit_filesize; |
| 2053 | of->shortest = o->shortest; |
| 2054 | av_dict_copy(&of->opts, o->g->format_opts, 0); |
| 2055 | |
| 2056 | if (!strcmp(filename, "-")) |
| 2057 | filename = "pipe:"; |
| 2058 | |
| 2059 | err = avformat_alloc_output_context2(&oc, NULL, o->format, filename); |
| 2060 | if (!oc) { |
| 2061 | print_error(filename, err); |
| 2062 | exit_program(1); |
| 2063 | } |
| 2064 | |
| 2065 | of->ctx = oc; |
| 2066 | if (o->recording_time != INT64_MAX) |
| 2067 | oc->duration = o->recording_time; |
| 2068 | |
| 2069 | file_oformat= oc->oformat; |
| 2070 | oc->interrupt_callback = int_cb; |
| 2071 | |
| 2072 | e = av_dict_get(o->g->format_opts, "fflags", NULL, 0); |
| 2073 | if (e) { |
nothing calls this directly
no test coverage detected