2 * Adobe Filmstrip muxer
3 * Copyright (c) 2010 Peter Ross
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 * Adobe Filmstrip muxer
27 #include "libavutil/intreadwrite.h"
31 #define RAND_TAG MKBETAG('R','a','n','d')
33 static int write_header(AVFormatContext *s)
35 if (s->streams[0]->codecpar->format != AV_PIX_FMT_RGBA) {
36 av_log(s, AV_LOG_ERROR, "only AV_PIX_FMT_RGBA is supported\n");
37 return AVERROR_INVALIDDATA;
42 static int write_trailer(AVFormatContext *s)
44 AVIOContext *pb = s->pb;
45 AVStream *st = s->streams[0];
48 avio_wb32(pb, RAND_TAG);
49 avio_wb32(pb, st->nb_frames);
50 avio_wb16(pb, 0); // packing method
51 avio_wb16(pb, 0); // reserved
52 avio_wb16(pb, st->codecpar->width);
53 avio_wb16(pb, st->codecpar->height);
54 avio_wb16(pb, 0); // leading
55 // TODO: should be avg_frame_rate
56 avio_wb16(pb, st->time_base.den / st->time_base.num);
57 for (i = 0; i < 16; i++)
58 avio_w8(pb, 0x00); // reserved
63 AVOutputFormat ff_filmstrip_muxer = {
65 .long_name = NULL_IF_CONFIG_SMALL("Adobe Filmstrip"),
67 .audio_codec = AV_CODEC_ID_NONE,
68 .video_codec = AV_CODEC_ID_RAWVIDEO,
69 .write_header = write_header,
70 .write_packet = ff_raw_write_packet,
71 .write_trailer = write_trailer,