Lines Matching refs:seg
146 SegmentContext *seg = s->priv_data; in segment_mux_init() local
151 ret = avformat_alloc_output_context2(&seg->avf, seg->oformat, NULL, NULL); in segment_mux_init()
154 oc = seg->avf; in segment_mux_init()
197 SegmentContext *seg = s->priv_data; in set_segment_filename() local
198 AVFormatContext *oc = seg->avf; in set_segment_filename()
204 if (seg->segment_idx_wrap) in set_segment_filename()
205 seg->segment_idx %= seg->segment_idx_wrap; in set_segment_filename()
206 if (seg->use_strftime) { in set_segment_filename()
216 s->url, seg->segment_idx) < 0) { in set_segment_filename()
227 if (seg->entry_prefix) in set_segment_filename()
228 size += strlen(seg->entry_prefix); in set_segment_filename()
230 if ((ret = av_reallocp(&seg->cur_entry.filename, size)) < 0) in set_segment_filename()
232 snprintf(seg->cur_entry.filename, size, "%s%s", in set_segment_filename()
233 seg->entry_prefix ? seg->entry_prefix : "", in set_segment_filename()
241 SegmentContext *seg = s->priv_data; in segment_start() local
242 AVFormatContext *oc = seg->avf; in segment_start()
247 seg->avf = NULL; in segment_start()
250 oc = seg->avf; in segment_start()
253 seg->segment_idx++; in segment_start()
254 if ((seg->segment_idx_wrap) && (seg->segment_idx % seg->segment_idx_wrap == 0)) in segment_start()
255 seg->segment_idx_wrap_nb++; in segment_start()
264 if (!seg->individual_header_trailer) in segment_start()
272 av_dict_copy(&options, seg->format_options, 0); in segment_start()
280 seg->segment_frame_count = 0; in segment_start()
286 SegmentContext *seg = s->priv_data; in segment_list_open() local
289 …snprintf(seg->temp_list_filename, sizeof(seg->temp_list_filename), seg->use_rename ? "%s.tmp" : "%… in segment_list_open()
290 ret = s->io_open(s, &seg->list_pb, seg->temp_list_filename, AVIO_FLAG_WRITE, NULL); in segment_list_open()
292 av_log(s, AV_LOG_ERROR, "Failed to open segment list '%s'\n", seg->list); in segment_list_open()
296 if (seg->list_type == LIST_TYPE_M3U8 && seg->segment_list_entries) { in segment_list_open()
300 avio_printf(seg->list_pb, "#EXTM3U\n"); in segment_list_open()
301 avio_printf(seg->list_pb, "#EXT-X-VERSION:3\n"); in segment_list_open()
302 avio_printf(seg->list_pb, "#EXT-X-MEDIA-SEQUENCE:%d\n", seg->segment_list_entries->index); in segment_list_open()
303 avio_printf(seg->list_pb, "#EXT-X-ALLOW-CACHE:%s\n", in segment_list_open()
304 seg->list_flags & SEGMENT_LIST_FLAG_CACHE ? "YES" : "NO"); in segment_list_open()
307 seg->segment_list_entries->index); in segment_list_open()
309 for (entry = seg->segment_list_entries; entry; entry = entry->next) in segment_list_open()
311 avio_printf(seg->list_pb, "#EXT-X-TARGETDURATION:%"PRId64"\n", (int64_t)ceil(max_duration)); in segment_list_open()
312 } else if (seg->list_type == LIST_TYPE_FFCONCAT) { in segment_list_open()
313 avio_printf(seg->list_pb, "ffconcat version 1.0\n"); in segment_list_open()
356 SegmentContext *seg = s->priv_data; in segment_end() local
357 AVFormatContext *oc = seg->avf; in segment_end()
377 if (seg->list) { in segment_end()
378 if (seg->list_size || seg->list_type == LIST_TYPE_M3U8) { in segment_end()
386 memcpy(entry, &seg->cur_entry, sizeof(*entry)); in segment_end()
388 if (!seg->segment_list_entries) in segment_end()
389 seg->segment_list_entries = seg->segment_list_entries_end = entry; in segment_end()
391 seg->segment_list_entries_end->next = entry; in segment_end()
392 seg->segment_list_entries_end = entry; in segment_end()
395 if (seg->list_size && seg->segment_count >= seg->list_size) { in segment_end()
396 entry = seg->segment_list_entries; in segment_end()
397 seg->segment_list_entries = seg->segment_list_entries->next; in segment_end()
404 for (entry = seg->segment_list_entries; entry; entry = entry->next) in segment_end()
405 segment_list_print_entry(seg->list_pb, seg->list_type, entry, s); in segment_end()
406 if (seg->list_type == LIST_TYPE_M3U8 && is_last) in segment_end()
407 avio_printf(seg->list_pb, "#EXT-X-ENDLIST\n"); in segment_end()
408 ff_format_io_close(s, &seg->list_pb); in segment_end()
409 if (seg->use_rename) in segment_end()
410 ff_rename(seg->temp_list_filename, seg->list, s); in segment_end()
412 segment_list_print_entry(seg->list_pb, seg->list_type, &seg->cur_entry, s); in segment_end()
413 avio_flush(seg->list_pb); in segment_end()
418 seg->avf->url, seg->segment_count); in segment_end()
419 seg->segment_count++; in segment_end()
421 if (seg->increment_tc) { in segment_end()
433 …tc.start += (int)((seg->cur_entry.end_time - seg->cur_entry.start_time) * av_q2d(rate));/* increme… in segment_end()
453 …st_tc.start += (int)((seg->cur_entry.end_time - seg->cur_entry.start_time) * av_q2d(st_rate)); … in segment_end()
597 SegmentContext *seg = s->priv_data; in select_reference_stream() local
600 seg->reference_stream_index = -1; in select_reference_stream()
601 if (!strcmp(seg->reference_stream_specifier, "auto")) { in select_reference_stream()
627 if ((seg->reference_stream_index = type_index_map[type]) >= 0) in select_reference_stream()
633 seg->reference_stream_specifier); in select_reference_stream()
637 seg->reference_stream_index = i; in select_reference_stream()
643 if (seg->reference_stream_index < 0) { in select_reference_stream()
645 seg->reference_stream_specifier); in select_reference_stream()
654 SegmentContext *seg = s->priv_data; in seg_free() local
657 ff_format_io_close(s, &seg->list_pb); in seg_free()
658 if (seg->avf) { in seg_free()
659 if (seg->is_nullctx) in seg_free()
660 close_null_ctxp(&seg->avf->pb); in seg_free()
662 ff_format_io_close(s, &seg->avf->pb); in seg_free()
663 avformat_free_context(seg->avf); in seg_free()
664 seg->avf = NULL; in seg_free()
666 av_freep(&seg->times); in seg_free()
667 av_freep(&seg->frames); in seg_free()
668 av_freep(&seg->cur_entry.filename); in seg_free()
670 cur = seg->segment_list_entries; in seg_free()
681 SegmentContext *seg = s->priv_data; in seg_init() local
682 AVFormatContext *oc = seg->avf; in seg_init()
687 seg->segment_count = 0; in seg_init()
688 if (!seg->write_header_trailer) in seg_init()
689 seg->individual_header_trailer = 0; in seg_init()
691 if (seg->header_filename) { in seg_init()
692 seg->write_header_trailer = 1; in seg_init()
693 seg->individual_header_trailer = 0; in seg_init()
696 if (seg->initial_offset > 0) { in seg_init()
701 if ((seg->time != 2000000) + !!seg->times_str + !!seg->frames_str > 1) { in seg_init()
708 if (seg->times_str) { in seg_init()
709 if ((ret = parse_times(s, &seg->times, &seg->nb_times, seg->times_str)) < 0) in seg_init()
711 } else if (seg->frames_str) { in seg_init()
712 if ((ret = parse_frames(s, &seg->frames, &seg->nb_frames, seg->frames_str)) < 0) in seg_init()
715 if (seg->use_clocktime) { in seg_init()
716 if (seg->time <= 0) { in seg_init()
720 seg->clocktime_offset = seg->time - (seg->clocktime_offset % seg->time); in seg_init()
724 if (seg->list) { in seg_init()
725 if (seg->list_type == LIST_TYPE_UNDEFINED) { in seg_init()
726 if (av_match_ext(seg->list, "csv" )) seg->list_type = LIST_TYPE_CSV; in seg_init()
727 else if (av_match_ext(seg->list, "ext" )) seg->list_type = LIST_TYPE_EXT; in seg_init()
728 else if (av_match_ext(seg->list, "m3u8")) seg->list_type = LIST_TYPE_M3U8; in seg_init()
729 else if (av_match_ext(seg->list, "ffcat,ffconcat")) seg->list_type = LIST_TYPE_FFCONCAT; in seg_init()
730 else seg->list_type = LIST_TYPE_FLAT; in seg_init()
732 if (!seg->list_size && seg->list_type != LIST_TYPE_M3U8) { in seg_init()
736 const char *proto = avio_find_protocol_name(seg->list); in seg_init()
737 seg->use_rename = proto && !strcmp(proto, "file"); in seg_init()
741 if (seg->list_type == LIST_TYPE_EXT) in seg_init()
747 seg->reference_stream_index, in seg_init()
748 av_get_media_type_string(s->streams[seg->reference_stream_index]->codecpar->codec_type)); in seg_init()
750 seg->oformat = av_guess_format(seg->format, s->url, NULL); in seg_init()
752 if (!seg->oformat) in seg_init()
754 if (seg->oformat->flags & AVFMT_NOFILE) { in seg_init()
756 seg->oformat->name); in seg_init()
765 oc = seg->avf; in seg_init()
767 if (seg->write_header_trailer) { in seg_init()
769 seg->header_filename ? seg->header_filename : oc->url, in seg_init()
774 if (!seg->individual_header_trailer) in seg_init()
779 seg->is_nullctx = 1; in seg_init()
782 av_dict_copy(&options, seg->format_options, 0); in seg_init()
796 seg->segment_frame_count = 0; in seg_init()
803 seg->header_written = 1; in seg_init()
820 SegmentContext *seg = s->priv_data; in seg_write_header() local
821 AVFormatContext *oc = seg->avf; in seg_write_header()
824 if (!seg->header_written) { in seg_write_header()
830 if (!seg->write_header_trailer || seg->header_filename) { in seg_write_header()
831 if (seg->header_filename) { in seg_write_header()
836 seg->is_nullctx = 0; in seg_write_header()
840 if (!seg->individual_header_trailer) in seg_write_header()
849 SegmentContext *seg = s->priv_data; in seg_write_packet() local
858 if (!seg->avf || !seg->avf->pb) in seg_write_packet()
875 if (seg->times) { in seg_write_packet()
876 end_pts = seg->segment_count < seg->nb_times ? in seg_write_packet()
877 seg->times[seg->segment_count] : INT64_MAX; in seg_write_packet()
878 } else if (seg->frames) { in seg_write_packet()
879 start_frame = seg->segment_count < seg->nb_frames ? in seg_write_packet()
880 seg->frames[seg->segment_count] : INT_MAX; in seg_write_packet()
882 if (seg->use_clocktime) { in seg_write_packet()
887 wrapped_val = (usecs + seg->clocktime_offset) % seg->time; in seg_write_packet()
888 if (wrapped_val < seg->last_val && wrapped_val < seg->clocktime_wrap_duration) in seg_write_packet()
889 seg->cut_pending = 1; in seg_write_packet()
890 seg->last_val = wrapped_val; in seg_write_packet()
892 end_pts = seg->time * (seg->segment_count + 1); in seg_write_packet()
900 pkt->stream_index == seg->reference_stream_index ? seg->frame_count : -1); in seg_write_packet()
902 if (pkt->stream_index == seg->reference_stream_index && in seg_write_packet()
903 (pkt->flags & AV_PKT_FLAG_KEY || seg->break_non_keyframes) && in seg_write_packet()
904 (seg->segment_frame_count > 0 || seg->write_empty) && in seg_write_packet()
905 (seg->cut_pending || seg->frame_count >= start_frame || in seg_write_packet()
908 end_pts - seg->time_delta, AV_TIME_BASE_Q) >= 0))) { in seg_write_packet()
910 if (seg->cur_entry.last_duration == 0) in seg_write_packet()
911 seg->cur_entry.end_time = (double)pkt->pts * av_q2d(st->time_base); in seg_write_packet()
913 if ((ret = segment_end(s, seg->individual_header_trailer, 0)) < 0) in seg_write_packet()
916 if ((ret = segment_start(s, seg->individual_header_trailer)) < 0) in seg_write_packet()
919 seg->cut_pending = 0; in seg_write_packet()
920 seg->cur_entry.index = seg->segment_idx + seg->segment_idx_wrap * seg->segment_idx_wrap_nb; in seg_write_packet()
921 seg->cur_entry.start_time = (double)pkt->pts * av_q2d(st->time_base); in seg_write_packet()
922 seg->cur_entry.start_pts = av_rescale_q(pkt->pts, st->time_base, AV_TIME_BASE_Q); in seg_write_packet()
923 seg->cur_entry.end_time = seg->cur_entry.start_time; in seg_write_packet()
925 if (seg->times || (!seg->frames && !seg->use_clocktime) && seg->write_empty) in seg_write_packet()
929 if (pkt->stream_index == seg->reference_stream_index) { in seg_write_packet()
931 seg->cur_entry.end_time = in seg_write_packet()
932 … FFMAX(seg->cur_entry.end_time, (double)(pkt->pts + pkt->duration) * av_q2d(st->time_base)); in seg_write_packet()
933 seg->cur_entry.last_duration = pkt->duration; in seg_write_packet()
936 if (seg->segment_frame_count == 0) { in seg_write_packet()
938 seg->avf->url, pkt->stream_index, in seg_write_packet()
939 av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base), seg->frame_count); in seg_write_packet()
944 av_ts2timestr(seg->cur_entry.start_pts, &AV_TIME_BASE_Q), in seg_write_packet()
949 …offset = av_rescale_q(seg->initial_offset - (seg->reset_timestamps ? seg->cur_entry.start_pts : 0), in seg_write_packet()
960 ret = ff_write_chained(seg->avf, pkt->stream_index, pkt, s, in seg_write_packet()
961 … seg->initial_offset || seg->reset_timestamps || seg->avf->oformat->interleave_packet); in seg_write_packet()
964 if (pkt->stream_index == seg->reference_stream_index) { in seg_write_packet()
965 seg->frame_count++; in seg_write_packet()
966 seg->segment_frame_count++; in seg_write_packet()
974 SegmentContext *seg = s->priv_data; in seg_write_trailer() local
975 AVFormatContext *oc = seg->avf; in seg_write_trailer()
981 if (!seg->write_header_trailer) { in seg_write_trailer()
986 seg->is_nullctx = 1; in seg_write_trailer()
996 SegmentContext *seg = s->priv_data; in seg_check_bitstream() local
997 AVFormatContext *oc = seg->avf; in seg_check_bitstream()