示例#1
0
static int gxf_write_umf_material_description(AVFormatContext *s)
{
    GXFContext *gxf = s->priv_data;
    AVIOContext *pb = s->pb;
    int timecode_base = gxf->time_base.den == 60000 ? 60 : 50;
    int64_t timestamp = 0;
    AVDictionaryEntry *t;
    uint64_t nb_fields;
    uint32_t timecode_in; // timecode at mark in
    uint32_t timecode_out; // timecode at mark out

#if FF_API_TIMESTAMP
    if (s->timestamp)
        timestamp = s->timestamp;
    else
#endif
        if (t = av_dict_get(s->metadata, "creation_time", NULL, 0))
            timestamp = ff_iso8601_to_unix_time(t->value);

    timecode_in = GXF_TIMECODE(gxf->tc.color, gxf->tc.drop,
                               gxf->tc.hh, gxf->tc.mm,
                               gxf->tc.ss, gxf->tc.ff);

    nb_fields = gxf->nb_fields +
                gxf->tc.hh * (timecode_base * 3600) +
                gxf->tc.mm * (timecode_base * 60)   +
                gxf->tc.ss * timecode_base          +
                gxf->tc.ff;

    timecode_out = GXF_TIMECODE(gxf->tc.color, gxf->tc.drop,
                                nb_fields / (timecode_base * 3600) % 24,
                                nb_fields / (timecode_base * 60)   % 60,
                                nb_fields /  timecode_base % 60,
                                nb_fields %  timecode_base);

    avio_wl32(pb, gxf->flags);
    avio_wl32(pb, gxf->nb_fields); /* length of the longest track */
    avio_wl32(pb, gxf->nb_fields); /* length of the shortest track */
    avio_wl32(pb, 0); /* mark in */
    avio_wl32(pb, gxf->nb_fields); /* mark out */
    avio_wl32(pb, timecode_in); /* timecode mark in */
    avio_wl32(pb, timecode_out); /* timecode mark out */
    avio_wl64(pb, timestamp); /* modification time */
    avio_wl64(pb, timestamp); /* creation time */
    avio_wl16(pb, 0); /* reserved */
    avio_wl16(pb, 0); /* reserved */
    avio_wl16(pb, gxf->audio_tracks);
    avio_wl16(pb, 1); /* timecode track count */
    avio_wl16(pb, 0); /* reserved */
    avio_wl16(pb, gxf->mpeg_tracks);
    return 48;
}
示例#2
0
文件: gxfenc.c 项目: Arcen/FFmpeg
static int gxf_write_umf_material_description(AVFormatContext *s)
{
    GXFContext *gxf = s->priv_data;
    AVIOContext *pb = s->pb;
    int timecode_base = gxf->time_base.den == 60000 ? 60 : 50;
    int64_t timestamp = 0;
    AVDictionaryEntry *t;
    uint32_t timecode;

#if FF_API_TIMESTAMP
    if (s->timestamp)
        timestamp = s->timestamp;
    else
#endif
    if (t = av_dict_get(s->metadata, "creation_time", NULL, 0))
        timestamp = ff_iso8601_to_unix_time(t->value);

    // XXX drop frame
    timecode =
        gxf->nb_fields / (timecode_base * 3600) % 24 << 24 | // hours
        gxf->nb_fields / (timecode_base * 60) % 60   << 16 | // minutes
        gxf->nb_fields /  timecode_base % 60         <<  8 | // seconds
        gxf->nb_fields %  timecode_base;                     // fields

    avio_wl32(pb, gxf->flags);
    avio_wl32(pb, gxf->nb_fields); /* length of the longest track */
    avio_wl32(pb, gxf->nb_fields); /* length of the shortest track */
    avio_wl32(pb, 0); /* mark in */
    avio_wl32(pb, gxf->nb_fields); /* mark out */
    avio_wl32(pb, 0); /* timecode mark in */
    avio_wl32(pb, timecode); /* timecode mark out */
    avio_wl64(pb, timestamp); /* modification time */
    avio_wl64(pb, timestamp); /* creation time */
    avio_wl16(pb, 0); /* reserved */
    avio_wl16(pb, 0); /* reserved */
    avio_wl16(pb, gxf->audio_tracks);
    avio_wl16(pb, 1); /* timecode track count */
    avio_wl16(pb, 0); /* reserved */
    avio_wl16(pb, gxf->mpeg_tracks);
    return 48;
}
示例#3
0
文件: dvenc.c 项目: eugenehp/ffmbc
static DVMuxContext* dv_init_mux(AVFormatContext* s)
{
    DVMuxContext *c = s->priv_data;
    AVDictionaryEntry *t;
    int i;

    /* we support at most 1 video and 2 audio streams */
    if (s->nb_streams > 5)
        return NULL;

    c->n_ast  = 0;
    c->ast[0] = c->ast[1] = c->ast[2] = c->ast[3] = NULL;

    /* We have to sort out where audio and where video stream is */
    for (i=0; i<s->nb_streams; i++) {
        switch (s->streams[i]->codec->codec_type) {
        case AVMEDIA_TYPE_VIDEO:
            if (c->vst) return NULL;
            c->vst = s->streams[i];
            break;
        case AVMEDIA_TYPE_AUDIO:
            if (c->n_ast > 1) return NULL;
            c->ast[c->n_ast++] = s->streams[i];
            break;
        default:
            goto bail_out;
        }
    }

    /* Some checks -- DV format is very picky about its incoming streams */
    if (!c->vst || c->vst->codec->codec_id != CODEC_ID_DVVIDEO)
        goto bail_out;
    for (i=0; i<c->n_ast; i++) {
        if (c->ast[i] && (c->ast[i]->codec->codec_id    != CODEC_ID_PCM_S16BE ||
                          c->ast[i]->codec->sample_rate != 48000 ||
                          c->ast[i]->codec->channels    != 2))
            goto bail_out;
    }
    c->sys = ff_dv_codec_profile(c->vst->codec);
    if (!c->sys)
        goto bail_out;

    if (((c->n_ast > 1) && (c->sys->n_difchan < 2)) ||
        ((c->n_ast > 2) && (c->sys->n_difchan < 4))) {
        /* only 1 stereo pair is allowed in 25Mbps mode */
        /* only 2 stereo pairs allowed in 50Mbps mode */
        goto bail_out;
    }

    /* Ok, everything seems to be in working order */
    c->frames     = 0;
    c->has_audio  = 0;
    c->has_video  = 0;
#if FF_API_TIMESTAMP
    if (s->timestamp)
        c->start_time = s->timestamp;
    else
#endif
    if (t = av_dict_get(s->metadata, "creation_time", NULL, 0))
        c->start_time = ff_iso8601_to_unix_time(t->value);

    for (i=0; i < c->n_ast; i++) {
        if (c->ast[i] && !(c->audio_data[i]=av_fifo_alloc(100*AVCODEC_MAX_AUDIO_FRAME_SIZE))) {
            while (i > 0) {
                i--;
                av_fifo_free(c->audio_data[i]);
            }
            goto bail_out;
        }
    }

    return c;

bail_out:
    return NULL;
}