Lines Matching refs:avf

66     AVFormatContext *avf;
113 static int add_file(AVFormatContext *avf, char *filename, ConcatFile **rfile,
116 ConcatContext *cat = avf->priv_data;
125 av_log(avf, AV_LOG_ERROR, "Unsafe file name '%s'\n", filename);
135 url_len = strlen(avf->url) + strlen(filename) + 16;
138 ff_make_absolute_url(url, url_len, avf->url, filename);
199 static int detect_stream_specific(AVFormatContext *avf, int idx)
201 ConcatContext *cat = avf->priv_data;
202 AVStream *st = cat->avf->streams[idx];
213 av_log(cat->avf, AV_LOG_INFO,
217 av_log(avf, AV_LOG_ERROR, "h264_mp4toannexb bitstream filter "
241 static int match_streams_one_to_one(AVFormatContext *avf)
243 ConcatContext *cat = avf->priv_data;
247 for (i = cat->cur_file->nb_streams; i < cat->avf->nb_streams; i++) {
248 if (i < avf->nb_streams) {
249 st = avf->streams[i];
251 if (!(st = avformat_new_stream(avf, NULL)))
254 if ((ret = copy_stream_props(st, cat->avf->streams[i])) < 0)
261 static int match_streams_exact_id(AVFormatContext *avf)
263 ConcatContext *cat = avf->priv_data;
267 for (i = cat->cur_file->nb_streams; i < cat->avf->nb_streams; i++) {
268 st = cat->avf->streams[i];
269 for (j = 0; j < avf->nb_streams; j++) {
270 if (avf->streams[j]->id == st->id) {
271 av_log(avf, AV_LOG_VERBOSE,
274 if ((ret = copy_stream_props(avf->streams[j], st)) < 0)
283 static int match_streams(AVFormatContext *avf)
285 ConcatContext *cat = avf->priv_data;
289 if (cat->cur_file->nb_streams >= cat->avf->nb_streams)
292 cat->avf->nb_streams * sizeof(*map));
297 (cat->avf->nb_streams - cat->cur_file->nb_streams) * sizeof(*map));
299 for (i = cat->cur_file->nb_streams; i < cat->avf->nb_streams; i++) {
301 if ((ret = detect_stream_specific(avf, i)) < 0)
306 ret = match_streams_one_to_one(avf);
309 ret = match_streams_exact_id(avf);
316 cat->cur_file->nb_streams = cat->avf->nb_streams;
320 static int64_t get_best_effort_duration(ConcatFile *file, AVFormatContext *avf)
326 if (avf->duration > 0)
327 return avf->duration - (file->file_inpoint - file->file_start_time);
333 static int open_file(AVFormatContext *avf, unsigned fileno)
335 ConcatContext *cat = avf->priv_data;
340 if (cat->avf)
341 avformat_close_input(&cat->avf);
343 cat->avf = avformat_alloc_context();
344 if (!cat->avf)
347 cat->avf->flags |= avf->flags & ~AVFMT_FLAG_CUSTOM_IO;
348 cat->avf->interrupt_callback = avf->interrupt_callback;
350 if ((ret = ff_copy_whiteblacklists(cat->avf, avf)) < 0)
357 if ((ret = avformat_open_input(&cat->avf, file->url, NULL, &options)) < 0 ||
358 (ret = avformat_find_stream_info(cat->avf, NULL)) < 0) {
359 av_log(avf, AV_LOG_ERROR, "Impossible to open '%s'\n", file->url);
361 avformat_close_input(&cat->avf);
365 av_log(avf, AV_LOG_WARNING, "Unused options for '%s'.\n", file->url);
373 file->file_start_time = (cat->avf->start_time == AV_NOPTS_VALUE) ? 0 : cat->avf->start_time;
375 file->duration = get_best_effort_duration(file, cat->avf);
383 if ((ret = match_streams(avf)) < 0)
386 if ((ret = avformat_seek_file(cat->avf, -1, INT64_MIN, file->inpoint, file->inpoint, 0)) < 0)
392 static int concat_read_close(AVFormatContext *avf)
394 ConcatContext *cat = avf->priv_data;
407 if (cat->avf)
408 avformat_close_input(&cat->avf);
458 static int concat_parse_script(AVFormatContext *avf)
460 ConcatContext *cat = avf->priv_data;
476 while ((ret = ff_read_line_to_bprint_overwrite(avf->pb, &bp)) >= 0) {
486 av_log(avf, AV_LOG_ERROR, "Line %d: unknown keyword '%s'\n",
493 av_log(avf, AV_LOG_ERROR, "Line %d: %s not allowed if safe\n", line, keyword);
497 av_log(avf, AV_LOG_ERROR, "Line %d: %s without file\n", line, keyword);
500 if ((dir->flags & NEEDS_STREAM) && !avf->nb_streams) {
501 av_log(avf, AV_LOG_ERROR, "Line %d: %s without stream\n", line, keyword);
512 av_log(avf, AV_LOG_ERROR, "Line %d: invalid duration '%s'\n",
529 av_log(avf, AV_LOG_ERROR, "Line %d: string required\n", line);
543 av_log(avf, AV_LOG_ERROR, "Line %d: invalid version\n", line);
549 ret = add_file(avf, arg_str[0], &file, &nb_files_alloc);
576 av_log(avf, AV_LOG_ERROR, "Line %d: failed to parse metadata string\n", line);
579 av_log(avf, AV_LOG_WARNING,
593 stream = avformat_new_stream(avf, NULL);
611 av_log(avf, AV_LOG_ERROR, "Line %d: codec '%s' not found\n", line, arg_kw[0]);
629 chapter = avpriv_new_chapter(avf, arg_int[0], AV_TIME_BASE_Q,
647 static int concat_read_header(AVFormatContext *avf)
649 ConcatContext *cat = avf->priv_data;
654 ret = concat_parse_script(avf);
658 av_log(avf, AV_LOG_ERROR, "No files to concat\n");
678 avf->duration = time;
682 cat->stream_match_mode = avf->nb_streams ? MATCH_EXACT_ID :
684 if ((ret = open_file(avf, 0)) < 0)
690 static int open_next_file(AVFormatContext *avf)
692 ConcatContext *cat = avf->priv_data;
695 cat->cur_file->duration = get_best_effort_duration(cat->cur_file, cat->avf);
701 return open_file(avf, fileno);
704 static int filter_packet(AVFormatContext *avf, ConcatStream *cs, AVPacket *pkt)
711 av_log(avf, AV_LOG_ERROR, "h264_mp4toannexb filter "
720 av_log(avf, AV_LOG_ERROR, "h264_mp4toannexb filter "
732 return av_compare_ts(pkt->dts, cat->avf->streams[pkt->stream_index]->time_base,
738 static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)
740 ConcatContext *cat = avf->priv_data;
750 if (!cat->avf)
754 ret = av_read_frame(cat->avf, pkt);
756 if ((ret = open_next_file(avf)) < 0)
762 if ((ret = match_streams(avf)) < 0) {
767 if ((ret = open_next_file(avf)) < 0)
778 if ((ret = filter_packet(avf, cs, pkt)) < 0)
781 st = cat->avf->streams[pkt->stream_index];
783 av_log(avf, AV_LOG_DEBUG, "file:%d stream:%d pts:%s pts_time:%s dts:%s dts_time:%s",
790 cat->avf->streams[pkt->stream_index]->time_base);
795 av_log(avf, AV_LOG_DEBUG, " -> pts:%s pts_time:%s dts:%s dts_time:%s\n",
822 static int try_seek(AVFormatContext *avf, int stream,
825 ConcatContext *cat = avf->priv_data;
832 if (stream >= cat->avf->nb_streams)
834 ff_rescale_interval(AV_TIME_BASE_Q, cat->avf->streams[stream]->time_base,
837 return avformat_seek_file(cat->avf, stream, min_ts, ts, max_ts, flags);
840 static int real_seek(AVFormatContext *avf, int stream,
843 ConcatContext *cat = avf->priv_data;
847 if (stream >= avf->nb_streams)
849 ff_rescale_interval(avf->streams[stream]->time_base, AV_TIME_BASE_Q,
871 if ((ret = open_file(avf, left)) < 0)
874 cat->avf = cur_avf;
877 ret = try_seek(avf, stream, min_ts, ts, max_ts, flags);
882 cat->avf = NULL;
883 if ((ret = open_file(avf, left + 1)) < 0)
885 ret = try_seek(avf, stream, min_ts, ts, max_ts, flags);
890 static int concat_seek(AVFormatContext *avf, int stream,
893 ConcatContext *cat = avf->priv_data;
895 AVFormatContext *cur_avf_saved = cat->avf;
900 cat->avf = NULL;
901 if ((ret = real_seek(avf, stream, min_ts, ts, max_ts, flags, cur_avf_saved)) < 0) {
903 if (cat->avf)
904 avformat_close_input(&cat->avf);
906 cat->avf = cur_avf_saved;