Revision 8190f62f

View differences:

doc/ffserver.conf
306 306
#</Stream>
307 307

  
308 308

  
309
# Transcode an incoming live feed to another live feed,
310
# using libx264 and video presets
311

  
312
#<Stream live.h264>
313
#Format rtp
314
#Feed feed1.ffm
315
#VideoCodec libx264
316
#VideoFrameRate 24
317
#VideoBitRate 100
318
#VideoSize 480x272
319
#AVPresetVideo default
320
#AVPresetVideo baseline
321
#AVOptionVideo flags +global_header
322
#
323
#AudioCodec libfaac
324
#AudioBitRate 32
325
#AudioChannels 2
326
#AudioSampleRate 22050
327
#AVOptionAudio flags +global_header
328
#</Stream>
329

  
309 330
##################################################################
310 331
# SDP/multicast examples
311 332
#
ffserver.c
3949 3949
    return ret;
3950 3950
}
3951 3951

  
3952
static int ffserver_opt_preset(const char *arg,
3953
                       AVCodecContext *avctx, int type,
3954
                       enum CodecID *audio_id, enum CodecID *video_id)
3955
{
3956
    FILE *f=NULL;
3957
    char filename[1000], tmp[1000], tmp2[1000], line[1000];
3958
    int i, ret = 0;
3959
    const char *base[3]= { getenv("FFMPEG_DATADIR"),
3960
                           getenv("HOME"),
3961
                           FFMPEG_DATADIR,
3962
                         };
3963

  
3964
    for(i=0; i<3 && !f; i++){
3965
        if(!base[i])
3966
            continue;
3967
        snprintf(filename, sizeof(filename), "%s%s/%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", arg);
3968
        f= fopen(filename, "r");
3969
        if(!f){
3970
            AVCodec *codec = avcodec_find_encoder(avctx->codec_id);
3971
            if (codec) {
3972
                snprintf(filename, sizeof(filename), "%s%s/%s-%s.ffpreset", base[i],  i != 1 ? "" : "/.ffmpeg", codec->name, arg);
3973
                f= fopen(filename, "r");
3974
            }
3975
        }
3976
    }
3977

  
3978
    if(!f){
3979
        fprintf(stderr, "File for preset '%s' not found\n", arg);
3980
        return 1;
3981
    }
3982

  
3983
    while(!feof(f)){
3984
        int e= fscanf(f, "%999[^\n]\n", line) - 1;
3985
        if(line[0] == '#' && !e)
3986
            continue;
3987
        e|= sscanf(line, "%999[^=]=%999[^\n]\n", tmp, tmp2) - 2;
3988
        if(e){
3989
            fprintf(stderr, "%s: Invalid syntax: '%s'\n", filename, line);
3990
            ret = 1;
3991
            break;
3992
        }
3993
        if(!strcmp(tmp, "acodec")){
3994
            *audio_id = opt_audio_codec(tmp2);
3995
        }else if(!strcmp(tmp, "vcodec")){
3996
            *video_id = opt_video_codec(tmp2);
3997
        }else if(!strcmp(tmp, "scodec")){
3998
            /* opt_subtitle_codec(tmp2); */
3999
        }else if(ffserver_opt_default(tmp, tmp2, avctx, type) < 0){
4000
            fprintf(stderr, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n", filename, line, tmp, tmp2);
4001
            ret = 1;
4002
            break;
4003
        }
4004
    }
4005

  
4006
    fclose(f);
4007

  
4008
    return ret;
4009
}
4010

  
3952 4011
static AVOutputFormat *ffserver_guess_format(const char *short_name, const char *filename,
3953 4012
                                             const char *mime_type)
3954 4013
{
......
4403 4462
            if (ffserver_opt_default(arg, arg2, avctx, type|AV_OPT_FLAG_ENCODING_PARAM)) {
4404 4463
                ERROR("AVOption error: %s %s\n", arg, arg2);
4405 4464
            }
4465
        } else if (!strcasecmp(cmd, "AVPresetVideo") ||
4466
                   !strcasecmp(cmd, "AVPresetAudio")) {
4467
            AVCodecContext *avctx;
4468
            int type;
4469
            get_arg(arg, sizeof(arg), &p);
4470
            if (!strcasecmp(cmd, "AVPresetVideo")) {
4471
                avctx = &video_enc;
4472
                video_enc.codec_id = video_id;
4473
                type = AV_OPT_FLAG_VIDEO_PARAM;
4474
            } else {
4475
                avctx = &audio_enc;
4476
                audio_enc.codec_id = audio_id;
4477
                type = AV_OPT_FLAG_AUDIO_PARAM;
4478
            }
4479
            if (ffserver_opt_preset(arg, avctx, type|AV_OPT_FLAG_ENCODING_PARAM, &audio_id, &video_id)) {
4480
                ERROR("AVPreset error: %s\n", arg);
4481
            }
4406 4482
        } else if (!strcasecmp(cmd, "VideoTag")) {
4407 4483
            get_arg(arg, sizeof(arg), &p);
4408 4484
            if ((strlen(arg) == 4) && stream)

Also available in: Unified diff