diff --git a/tv/linux/miro-segmenter.c b/tv/linux/miro-segmenter.c index e519b91..f9cd0e2 100644 --- a/tv/linux/miro-segmenter.c +++ b/tv/linux/miro-segmenter.c @@ -65,7 +65,7 @@ static AVStream *add_output_stream(AVFormatContext *output_format_context, AVStr } switch (input_codec_context->codec_type) { - case CODEC_TYPE_AUDIO: + case AVMEDIA_TYPE_AUDIO: output_codec_context->channel_layout = input_codec_context->channel_layout; output_codec_context->sample_rate = input_codec_context->sample_rate; output_codec_context->channels = input_codec_context->channels; @@ -77,7 +77,7 @@ static AVStream *add_output_stream(AVFormatContext *output_format_context, AVStr output_codec_context->block_align = input_codec_context->block_align; } break; - case CODEC_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: output_codec_context->pix_fmt = input_codec_context->pix_fmt; output_codec_context->width = input_codec_context->width; output_codec_context->height = input_codec_context->height; @@ -148,7 +148,7 @@ int main(int argc, char **argv) exit(1); } - ret = av_open_input_file(&ic, input, ifmt, 0, NULL); + ret = avformat_open_input(&ic, input, ifmt, NULL); if (ret != 0) { fprintf(stderr, "Could not open input file, make sure it is an mpegts file: %d\n", ret); exit(1); @@ -159,7 +159,7 @@ int main(int argc, char **argv) exit(1); } - ofmt = guess_format("mpegts", NULL, NULL); + ofmt = av_guess_format("mpegts", NULL, NULL); if (!ofmt) { fprintf(stderr, "Could not find MPEG-TS muxer\n"); exit(1); @@ -179,12 +179,12 @@ int main(int argc, char **argv) for (i = 0; i < ic->nb_streams && (video_index < 0 || audio_index < 0); i++) { switch (ic->streams[i]->codec->codec_type) { - case CODEC_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: video_index = i; ic->streams[i]->discard = AVDISCARD_NONE; video_st = add_output_stream(oc, ic->streams[i]); break; - case CODEC_TYPE_AUDIO: + case AVMEDIA_TYPE_AUDIO: audio_index = i; ic->streams[i]->discard = AVDISCARD_NONE; audio_st = add_output_stream(oc, ic->streams[i]); @@ -195,12 +195,7 @@ int main(int argc, char **argv) } } - if (av_set_parameters(oc, NULL) < 0) { - fprintf(stderr, "Invalid output format parameters\n"); - exit(1); - } - - dump_format(oc, 0, input, 1); + av_dump_format(oc, 0, input, 1); if (video_st) { codec = avcodec_find_decoder(video_st->codec->codec_id); @@ -213,12 +208,12 @@ int main(int argc, char **argv) } } - if (url_fopen(&oc->pb, output_filename, URL_WRONLY) < 0) { + if (avio_open(&oc->pb, output_filename, URL_WRONLY) < 0) { fprintf(stderr, "Could not open '%s'\n", output_filename); exit(1); } - if (av_write_header(oc)) { + if (avformat_write_header(oc, NULL)) { fprintf(stderr, "Could not write mpegts header to first output file\n"); exit(1); @@ -239,7 +234,7 @@ int main(int argc, char **argv) break; } - if (packet.stream_index == video_index && (packet.flags & PKT_FLAG_KEY)) { + if (packet.stream_index == video_index && (packet.flags & AV_PKT_FLAG_KEY)) { segment_time = (double)video_st->pts.val * video_st->time_base.num / video_st->time_base.den; } else if (video_index < 0) { @@ -250,10 +245,10 @@ int main(int argc, char **argv) } if (segment_time - prev_segment_time >= segment_duration) { - put_flush_packet(oc->pb); - url_fclose(oc->pb); + avio_flush(oc->pb); + avio_close(oc->pb); - if (url_fopen(&oc->pb, output_filename, URL_WRONLY) < 0) { + if (avio_open(&oc->pb, output_filename, URL_WRONLY) < 0) { fprintf(stderr, "Could not open '%s'\n", output_filename); break; } @@ -283,7 +278,7 @@ int main(int argc, char **argv) av_freep(&oc->streams[i]); } - url_fclose(oc->pb); + avio_close(oc->pb); av_free(oc); /* End-of-transcode marker. */