MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / seg_init

Function seg_init

libavformat/segment.c:682–828  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

680}
681
682static int seg_init(AVFormatContext *s)
683{
684 SegmentContext *seg = s->priv_data;
685 AVFormatContext *oc = seg->avf;
686 AVDictionary *options = NULL;
687 int ret;
688 int i;
689
690 seg->segment_count = 0;
691 if (!seg->write_header_trailer)
692 seg->individual_header_trailer = 0;
693
694 if (seg->header_filename) {
695 seg->write_header_trailer = 1;
696 seg->individual_header_trailer = 0;
697 }
698
699 if (seg->initial_offset > 0) {
700 av_log(s, AV_LOG_WARNING, "NOTE: the option initial_offset is deprecated,"
701 "you can use output_ts_offset instead of it\n");
702 }
703
704 if ((seg->time != 2000000) + !!seg->times_str + !!seg->frames_str > 1) {
705 av_log(s, AV_LOG_ERROR,
706 "segment_time, segment_times, and segment_frames options "
707 "are mutually exclusive, select just one of them\n");
708 return AVERROR(EINVAL);
709 }
710
711 if (seg->times_str || seg->frames_str)
712 seg->min_seg_duration = 0;
713
714 if (seg->times_str) {
715 if ((ret = parse_times(s, &seg->times, &seg->nb_times, seg->times_str)) < 0)
716 return ret;
717 } else if (seg->frames_str) {
718 if ((ret = parse_frames(s, &seg->frames, &seg->nb_frames, seg->frames_str)) < 0)
719 return ret;
720 } else {
721 if (seg->use_clocktime) {
722 if (seg->time <= 0) {
723 av_log(s, AV_LOG_ERROR, "Invalid negative segment_time with segment_atclocktime option set\n");
724 return AVERROR(EINVAL);
725 }
726 seg->clocktime_offset = seg->time - (seg->clocktime_offset % seg->time);
727 }
728 if (seg->min_seg_duration > seg->time) {
729 av_log(s, AV_LOG_ERROR, "min_seg_duration cannot be greater than segment_time\n");
730 return AVERROR(EINVAL);
731 }
732 }
733
734 if (seg->list) {
735 if (seg->list_type == LIST_TYPE_UNDEFINED) {
736 if (av_match_ext(seg->list, "csv" )) seg->list_type = LIST_TYPE_CSV;
737 else if (av_match_ext(seg->list, "ext" )) seg->list_type = LIST_TYPE_EXT;
738 else if (av_match_ext(seg->list, "m3u8")) seg->list_type = LIST_TYPE_M3U8;
739 else if (av_match_ext(seg->list, "ffcat,ffconcat")) seg->list_type = LIST_TYPE_FFCONCAT;

Callers

nothing calls this directly

Calls 15

av_logFunction · 0.85
parse_timesFunction · 0.85
parse_framesFunction · 0.85
av_match_extFunction · 0.85
segment_list_openFunction · 0.85
avio_find_protocol_nameFunction · 0.85
select_reference_streamFunction · 0.85
av_get_media_type_stringFunction · 0.85
av_guess_formatFunction · 0.85
segment_mux_initFunction · 0.85
set_segment_filenameFunction · 0.85
open_null_ctxFunction · 0.85

Tested by

no test coverage detected