FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
filmstripenc.c
Go to the documentation of this file.
1 /*
2  * Adobe Filmstrip muxer
3  * Copyright (c) 2010 Peter Ross
4  *
5  * This file is part of FFmpeg.
6  *
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.
11  *
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.
16  *
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
20  */
21 
22 /**
23  * @file
24  * Adobe Filmstrip muxer
25  */
26 
27 #include "libavutil/intreadwrite.h"
28 #include "avformat.h"
29 
30 #define RAND_TAG MKBETAG('R','a','n','d')
31 
32 typedef struct FilmstripMuxContext {
33  int nb_frames;
35 
37 {
38  if (s->streams[0]->codecpar->format != AV_PIX_FMT_RGBA) {
39  av_log(s, AV_LOG_ERROR, "only AV_PIX_FMT_RGBA is supported\n");
40  return AVERROR_INVALIDDATA;
41  }
42  return 0;
43 }
44 
46 {
47  FilmstripMuxContext *film = s->priv_data;
48  avio_write(s->pb, pkt->data, pkt->size);
49  film->nb_frames++;
50  return 0;
51 }
52 
54 {
55  FilmstripMuxContext *film = s->priv_data;
56  AVIOContext *pb = s->pb;
57  AVStream *st = s->streams[0];
58  int i;
59 
60  avio_wb32(pb, RAND_TAG);
61  avio_wb32(pb, film->nb_frames);
62  avio_wb16(pb, 0); // packing method
63  avio_wb16(pb, 0); // reserved
64  avio_wb16(pb, st->codecpar->width);
65  avio_wb16(pb, st->codecpar->height);
66  avio_wb16(pb, 0); // leading
67  // TODO: should be avg_frame_rate
68  avio_wb16(pb, st->time_base.den / st->time_base.num);
69  for (i = 0; i < 16; i++)
70  avio_w8(pb, 0x00); // reserved
71 
72  return 0;
73 }
74 
76  .name = "filmstrip",
77  .long_name = NULL_IF_CONFIG_SMALL("Adobe Filmstrip"),
78  .extensions = "flm",
79  .priv_data_size = sizeof(FilmstripMuxContext),
80  .audio_codec = AV_CODEC_ID_NONE,
81  .video_codec = AV_CODEC_ID_RAWVIDEO,
85 };
const char * s
Definition: avisynth_c.h:631
Bytestream IO Context.
Definition: avio.h:147
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
int num
numerator
Definition: rational.h:44
int size
Definition: avcodec.h:1581
static AVPacket pkt
static int write_trailer(AVFormatContext *s)
Definition: filmstripenc.c:53
Format I/O context.
Definition: avformat.h:1325
AVOutputFormat ff_filmstrip_muxer
Definition: filmstripenc.c:75
int width
Video only.
Definition: avcodec.h:3988
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1393
uint8_t * data
Definition: avcodec.h:1580
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:204
#define av_log(a,...)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:94
const char * name
Definition: avformat.h:522
Stream structure.
Definition: avformat.h:876
AVIOContext * pb
I/O context.
Definition: avformat.h:1367
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:182
static int write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: filmstripenc.c:45
void avio_wb16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:452
#define RAND_TAG
Definition: filmstripenc.c:30
Main libavformat public API header.
int den
denominator
Definition: rational.h:45
void * priv_data
Format private data.
Definition: avformat.h:1353
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:354
AVCodecParameters * codecpar
Definition: avformat.h:1006
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avformat.h:913
This structure stores compressed data.
Definition: avcodec.h:1557
static int write_header(AVFormatContext *s)
Definition: filmstripenc.c:36