--- Makefile.orig 2012-02-06 17:49:57.000000000 +0100 +++ Makefile 2012-02-06 17:50:14.000000000 +0100 @@ -1,5 +1,5 @@ all: - gcc -Wall -g segmenter.c -o segmenter -lavformat -lavcodec -lavutil + gcc -I/usr/include/ffmpeg -Wall -g segmenter.c -o segmenter -lavformat -lavcodec -lavutil clean: rm segmenter --- segmenter.c.orig 2012-02-06 17:52:20.000000000 +0100 +++ segmenter.c 2012-02-06 18:22:22.000000000 +0100 @@ -25,7 +25,7 @@ AVCodecContext *output_codec_context; AVStream *output_stream; - output_stream = av_new_stream(output_format_context, 0); + output_stream = avformat_new_stream(output_format_context, 0); if (!output_stream) { fprintf(stderr, "Could not allocate stream\n"); exit(1); @@ -50,7 +50,7 @@ } 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; @@ -62,7 +62,7 @@ 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; @@ -228,18 +228,26 @@ exit(1); } + /* + FIXME: int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, + AVDictionary **options); + */ + ret = av_open_input_file(&ic, input, ifmt, 0, NULL); if (ret != 0) { fprintf(stderr, "Could not open input file, make sure it is an mpegts file: %d\n", ret); exit(1); } + /* + FIXME: int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options); + */ if (av_find_stream_info(ic) < 0) { fprintf(stderr, "Could not read stream information\n"); 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); @@ -257,12 +265,12 @@ 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]); @@ -273,28 +281,39 @@ } } + /* + FIXME: @deprecated pass the options to avformat_write_header directly. + int avformat_write_header(AVFormatContext *s, AVDictionary **options); + */ if (av_set_parameters(oc, NULL) < 0) { fprintf(stderr, "Invalid output format parameters\n"); exit(1); } - dump_format(oc, 0, output_prefix, 1); + av_dump_format(oc, 0, output_prefix, 1); codec = avcodec_find_decoder(video_st->codec->codec_id); if (!codec) { fprintf(stderr, "Could not find video decoder, key frames will not be honored\n"); } + /* + FIXME: int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options); + */ if (avcodec_open(video_st->codec, codec) < 0) { fprintf(stderr, "Could not open video decoder, key frames will not be honored\n"); } snprintf(output_filename, strlen(output_prefix) + 15, "%s-%u.ts", output_prefix, output_index++); - 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); } + /* + FIXME: int avformat_write_header(AVFormatContext *s, AVDictionary **options); + */ + if (av_write_header(oc)) { fprintf(stderr, "Could not write mpegts header to first output file\n"); exit(1); @@ -317,7 +336,7 @@ 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) { @@ -328,8 +347,8 @@ } 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 (max_tsfiles && (int)(last_segment - first_segment) >= max_tsfiles - 1) { remove_file = 1; @@ -349,7 +368,7 @@ } snprintf(output_filename, strlen(output_prefix) + 15, "%s-%u.ts", output_prefix, output_index++); - 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; } @@ -379,7 +398,7 @@ av_freep(&oc->streams[i]); } - url_fclose(oc->pb); + avio_close(oc->pb); av_free(oc); if (max_tsfiles && (int)(last_segment - first_segment) >= max_tsfiles - 1) {