Revision 7d727f13

View differences:

ffmpeg.c
3779 3779
    if (!strcmp(filename, "-"))
3780 3780
        filename = "pipe:";
3781 3781

  
3782
    oc = avformat_alloc_context();
3782
    oc = avformat_alloc_output_context(last_asked_format, NULL, filename);
3783
    last_asked_format = NULL;
3783 3784
    if (!oc) {
3784 3785
        print_error(filename, AVERROR(ENOMEM));
3785 3786
        ffmpeg_exit(1);
3786 3787
    }
3787

  
3788
    if (last_asked_format) {
3789
        file_oformat = av_guess_format(last_asked_format, NULL, NULL);
3790
        if (!file_oformat) {
3791
            fprintf(stderr, "Requested output format '%s' is not a suitable output format\n", last_asked_format);
3792
            ffmpeg_exit(1);
3793
        }
3794
        last_asked_format = NULL;
3795
    } else {
3796
        file_oformat = av_guess_format(NULL, filename, NULL);
3797
        if (!file_oformat) {
3798
            fprintf(stderr, "Unable to find a suitable output format for '%s'\n",
3799
                    filename);
3800
            ffmpeg_exit(1);
3801
        }
3802
    }
3803

  
3804
    oc->oformat = file_oformat;
3805
    av_strlcpy(oc->filename, filename, sizeof(oc->filename));
3788
    file_oformat= oc->oformat;
3806 3789

  
3807 3790
    if (!strcmp(file_oformat->name, "ffm") &&
3808 3791
        av_strstart(filename, "http:", NULL)) {
libavformat/avformat.h
1048 1048
AVFormatContext *avformat_alloc_context(void);
1049 1049

  
1050 1050
/**
1051
 * Allocate an AVFormatContext.
1052
 * avformat_free_context() can be used to free the context and everything
1053
 * allocated by the framework within it.
1054
 */
1055
AVFormatContext *avformat_alloc_output_context(const char *format, AVOutputFormat *oformat, const char *filename);
1056

  
1057
/**
1051 1058
 * Read packets of a media file to get stream information. This
1052 1059
 * is useful for file formats with no headers such as MPEG. This
1053 1060
 * function also computes the real framerate in case of MPEG-2 repeat
......
1295 1302
/**
1296 1303
 * media file output
1297 1304
 */
1298
int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
1305
attribute_deprecated int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
1299 1306

  
1300 1307
/**
1301 1308
 * Split a URL string into components.
libavformat/utils.c
2719 2719
    return 0;
2720 2720
}
2721 2721

  
2722
AVFormatContext *avformat_alloc_output_context(const char *format, AVOutputFormat *oformat, const char *filename){
2723
    AVFormatContext *s= avformat_alloc_context();
2724
    if(!s)
2725
        goto nomem;
2726

  
2727
    if(!oformat){
2728
        if (format) {
2729
            oformat = av_guess_format(format, NULL, NULL);
2730
            if (!oformat) {
2731
                av_log(s, AV_LOG_ERROR, "Requested output format '%s' is not a suitable output format\n", format);
2732
                goto error;
2733
            }
2734
        } else {
2735
            oformat = av_guess_format(NULL, filename, NULL);
2736
            if (!oformat) {
2737
                av_log(s, AV_LOG_ERROR, "Unable to find a suitable output format for '%s'\n",
2738
                        filename);
2739
                goto error;
2740
            }
2741
        }
2742
    }
2743

  
2744
    s->oformat= oformat;
2745
    if (s->oformat->priv_data_size > 0) {
2746
        s->priv_data = av_mallocz(s->oformat->priv_data_size);
2747
        if (!s->priv_data)
2748
            goto nomem;
2749
        if (s->oformat->priv_class) {
2750
            *(const AVClass**)s->priv_data= s->oformat->priv_class;
2751
            av_opt_set_defaults(s->priv_data);
2752
        }
2753
    } else
2754
        s->priv_data = NULL;
2755

  
2756
    if(filename)
2757
        av_strlcpy(s->filename, filename, sizeof(s->filename));
2758
    return s;
2759
nomem:
2760
    av_log(s, AV_LOG_ERROR, "Out of memory\n");
2761
error:
2762
    avformat_free_context(s);
2763
    return NULL;
2764
}
2765

  
2722 2766
static int validate_codec_tag(AVFormatContext *s, AVStream *st)
2723 2767
{
2724 2768
    const AVCodecTag *avctag;

Also available in: Unified diff