FFmpeg
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 #include "avio_internal.h"
30 #include "mux.h"
31 #include "rawenc.h"
32 
33 #define RAND_TAG MKBETAG('R','a','n','d')
34 
36 {
37  if (s->streams[0]->codecpar->format != AV_PIX_FMT_RGBA) {
38  av_log(s, AV_LOG_ERROR, "only AV_PIX_FMT_RGBA is supported\n");
39  return AVERROR_INVALIDDATA;
40  }
41  return 0;
42 }
43 
45 {
46  AVIOContext *pb = s->pb;
47  AVStream *st = s->streams[0];
48 
49  avio_wb32(pb, RAND_TAG);
50  avio_wb32(pb, st->nb_frames);
51  avio_wb16(pb, 0); // packing method
52  avio_wb16(pb, 0); // reserved
53  avio_wb16(pb, st->codecpar->width);
54  avio_wb16(pb, st->codecpar->height);
55  avio_wb16(pb, 0); // leading
56  // TODO: should be avg_frame_rate
57  avio_wb16(pb, st->time_base.den / st->time_base.num);
58  ffio_fill(pb, 0x00, 16); // reserved
59 
60  return 0;
61 }
62 
64  .p.name = "filmstrip",
65  .p.long_name = NULL_IF_CONFIG_SMALL("Adobe Filmstrip"),
66  .p.extensions = "flm",
67  .p.audio_codec = AV_CODEC_ID_NONE,
68  .p.video_codec = AV_CODEC_ID_RAWVIDEO,
69  .write_header = write_header,
70  .write_packet = ff_raw_write_packet,
71  .write_trailer = write_trailer,
72 };
AVOutputFormat::name
const char * name
Definition: avformat.h:508
AV_CODEC_ID_RAWVIDEO
@ AV_CODEC_ID_RAWVIDEO
Definition: codec_id.h:65
write_trailer
static int write_trailer(AVFormatContext *s)
Definition: filmstripenc.c:44
FFOutputFormat::p
AVOutputFormat p
The public AVOutputFormat.
Definition: mux.h:34
AVRational::num
int num
Numerator.
Definition: rational.h:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:256
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:128
ff_raw_write_packet
int ff_raw_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: rawenc.c:31
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
AVFormatContext
Format I/O context.
Definition: avformat.h:1104
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:861
AVStream::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avformat.h:877
FFOutputFormat
Definition: mux.h:30
ffio_fill
void ffio_fill(AVIOContext *s, int b, int64_t count)
Definition: aviobuf.c:208
AVStream::nb_frames
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:899
AVIOContext
Bytestream IO Context.
Definition: avio.h:166
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:115
avio_wb32
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:386
ff_filmstrip_muxer
const FFOutputFormat ff_filmstrip_muxer
Definition: filmstripenc.c:63
rawenc.h
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:50
avio_internal.h
AVCodecParameters::height
int height
Definition: codec_par.h:129
write_header
static int write_header(AVFormatContext *s)
Definition: filmstripenc.c:35
AVStream
Stream structure.
Definition: avformat.h:838
avformat.h
AVRational::den
int den
Denominator.
Definition: rational.h:60
RAND_TAG
#define RAND_TAG
Definition: filmstripenc.c:33
avio_wb16
void avio_wb16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:464
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
mux.h