FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rawenc.c
Go to the documentation of this file.
1 /*
2  * RAW muxers
3  * Copyright (c) 2001 Fabrice Bellard
4  * Copyright (c) 2005 Alex Beregszaszi
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include "avformat.h"
24 #include "rawenc.h"
25 
27 {
28  avio_write(s->pb, pkt->data, pkt->size);
29  return 0;
30 }
31 
33 {
34  if (s->nb_streams != 1) {
35  av_log(s, AV_LOG_ERROR, "%s files have exactly one stream\n",
36  s->oformat->name);
37  return AVERROR(EINVAL);
38  }
39  return 0;
40 }
41 
42 /* Note: Do not forget to add new entries to the Makefile as well. */
43 
44 #if CONFIG_AC3_MUXER
45 AVOutputFormat ff_ac3_muxer = {
46  .name = "ac3",
47  .long_name = NULL_IF_CONFIG_SMALL("raw AC-3"),
48  .mime_type = "audio/x-ac3",
49  .extensions = "ac3",
50  .audio_codec = AV_CODEC_ID_AC3,
51  .video_codec = AV_CODEC_ID_NONE,
52  .write_header = force_one_stream,
53  .write_packet = ff_raw_write_packet,
54  .flags = AVFMT_NOTIMESTAMPS,
55 };
56 #endif
57 
58 #if CONFIG_ADX_MUXER
59 AVOutputFormat ff_adx_muxer = {
60  .name = "adx",
61  .long_name = NULL_IF_CONFIG_SMALL("CRI ADX"),
62  .extensions = "adx",
63  .audio_codec = AV_CODEC_ID_ADPCM_ADX,
64  .video_codec = AV_CODEC_ID_NONE,
65  .write_header = force_one_stream,
66  .write_packet = ff_raw_write_packet,
67  .flags = AVFMT_NOTIMESTAMPS,
68 };
69 #endif
70 
71 #if CONFIG_CAVSVIDEO_MUXER
72 AVOutputFormat ff_cavsvideo_muxer = {
73  .name = "cavsvideo",
74  .long_name = NULL_IF_CONFIG_SMALL("raw Chinese AVS (Audio Video Standard) video"),
75  .extensions = "cavs",
76  .audio_codec = AV_CODEC_ID_NONE,
77  .video_codec = AV_CODEC_ID_CAVS,
78  .write_header = force_one_stream,
79  .write_packet = ff_raw_write_packet,
80  .flags = AVFMT_NOTIMESTAMPS,
81 };
82 #endif
83 
84 #if CONFIG_DATA_MUXER
85 AVOutputFormat ff_data_muxer = {
86  .name = "data",
87  .long_name = NULL_IF_CONFIG_SMALL("raw data"),
88  .write_header = force_one_stream,
89  .write_packet = ff_raw_write_packet,
90  .flags = AVFMT_NOTIMESTAMPS,
91 };
92 #endif
93 
94 #if CONFIG_DIRAC_MUXER
95 AVOutputFormat ff_dirac_muxer = {
96  .name = "dirac",
97  .long_name = NULL_IF_CONFIG_SMALL("raw Dirac"),
98  .extensions = "drc",
99  .audio_codec = AV_CODEC_ID_NONE,
100  .video_codec = AV_CODEC_ID_DIRAC,
101  .write_header = force_one_stream,
102  .write_packet = ff_raw_write_packet,
103  .flags = AVFMT_NOTIMESTAMPS,
104 };
105 #endif
106 
107 #if CONFIG_DNXHD_MUXER
108 AVOutputFormat ff_dnxhd_muxer = {
109  .name = "dnxhd",
110  .long_name = NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
111  .extensions = "dnxhd",
112  .audio_codec = AV_CODEC_ID_NONE,
113  .video_codec = AV_CODEC_ID_DNXHD,
114  .write_header = force_one_stream,
115  .write_packet = ff_raw_write_packet,
116  .flags = AVFMT_NOTIMESTAMPS,
117 };
118 #endif
119 
120 #if CONFIG_DTS_MUXER
121 AVOutputFormat ff_dts_muxer = {
122  .name = "dts",
123  .long_name = NULL_IF_CONFIG_SMALL("raw DTS"),
124  .mime_type = "audio/x-dca",
125  .extensions = "dts",
126  .audio_codec = AV_CODEC_ID_DTS,
127  .video_codec = AV_CODEC_ID_NONE,
128  .write_header = force_one_stream,
129  .write_packet = ff_raw_write_packet,
130  .flags = AVFMT_NOTIMESTAMPS,
131 };
132 #endif
133 
134 #if CONFIG_EAC3_MUXER
135 AVOutputFormat ff_eac3_muxer = {
136  .name = "eac3",
137  .long_name = NULL_IF_CONFIG_SMALL("raw E-AC-3"),
138  .mime_type = "audio/x-eac3",
139  .extensions = "eac3",
140  .audio_codec = AV_CODEC_ID_EAC3,
141  .video_codec = AV_CODEC_ID_NONE,
142  .write_header = force_one_stream,
143  .write_packet = ff_raw_write_packet,
144  .flags = AVFMT_NOTIMESTAMPS,
145 };
146 #endif
147 
148 #if CONFIG_G722_MUXER
149 AVOutputFormat ff_g722_muxer = {
150  .name = "g722",
151  .long_name = NULL_IF_CONFIG_SMALL("raw G.722"),
152  .mime_type = "audio/G722",
153  .extensions = "g722",
154  .audio_codec = AV_CODEC_ID_ADPCM_G722,
155  .video_codec = AV_CODEC_ID_NONE,
156  .write_header = force_one_stream,
157  .write_packet = ff_raw_write_packet,
158  .flags = AVFMT_NOTIMESTAMPS,
159 };
160 #endif
161 
162 #if CONFIG_G723_1_MUXER
163 AVOutputFormat ff_g723_1_muxer = {
164  .name = "g723_1",
165  .long_name = NULL_IF_CONFIG_SMALL("raw G.723.1"),
166  .mime_type = "audio/g723",
167  .extensions = "tco,rco",
168  .audio_codec = AV_CODEC_ID_G723_1,
169  .video_codec = AV_CODEC_ID_NONE,
170  .write_header = force_one_stream,
171  .write_packet = ff_raw_write_packet,
172  .flags = AVFMT_NOTIMESTAMPS,
173 };
174 #endif
175 
176 #if CONFIG_H261_MUXER
177 AVOutputFormat ff_h261_muxer = {
178  .name = "h261",
179  .long_name = NULL_IF_CONFIG_SMALL("raw H.261"),
180  .mime_type = "video/x-h261",
181  .extensions = "h261",
182  .audio_codec = AV_CODEC_ID_NONE,
183  .video_codec = AV_CODEC_ID_H261,
184  .write_header = force_one_stream,
185  .write_packet = ff_raw_write_packet,
186  .flags = AVFMT_NOTIMESTAMPS,
187 };
188 #endif
189 
190 #if CONFIG_H263_MUXER
191 AVOutputFormat ff_h263_muxer = {
192  .name = "h263",
193  .long_name = NULL_IF_CONFIG_SMALL("raw H.263"),
194  .mime_type = "video/x-h263",
195  .extensions = "h263",
196  .audio_codec = AV_CODEC_ID_NONE,
197  .video_codec = AV_CODEC_ID_H263,
198  .write_header = force_one_stream,
199  .write_packet = ff_raw_write_packet,
200  .flags = AVFMT_NOTIMESTAMPS,
201 };
202 #endif
203 
204 #if CONFIG_H264_MUXER
205 AVOutputFormat ff_h264_muxer = {
206  .name = "h264",
207  .long_name = NULL_IF_CONFIG_SMALL("raw H.264 video"),
208  .extensions = "h264,264",
209  .audio_codec = AV_CODEC_ID_NONE,
210  .video_codec = AV_CODEC_ID_H264,
211  .write_header = force_one_stream,
212  .write_packet = ff_raw_write_packet,
213  .flags = AVFMT_NOTIMESTAMPS,
214 };
215 #endif
216 
217 #if CONFIG_HEVC_MUXER
218 AVOutputFormat ff_hevc_muxer = {
219  .name = "hevc",
220  .long_name = NULL_IF_CONFIG_SMALL("raw HEVC video"),
221  .extensions = "hevc",
222  .audio_codec = AV_CODEC_ID_NONE,
223  .video_codec = AV_CODEC_ID_HEVC,
224  .write_packet = ff_raw_write_packet,
225  .flags = AVFMT_NOTIMESTAMPS,
226 };
227 #endif
228 
229 #if CONFIG_M4V_MUXER
230 AVOutputFormat ff_m4v_muxer = {
231  .name = "m4v",
232  .long_name = NULL_IF_CONFIG_SMALL("raw MPEG-4 video"),
233  .extensions = "m4v",
234  .audio_codec = AV_CODEC_ID_NONE,
235  .video_codec = AV_CODEC_ID_MPEG4,
236  .write_packet = ff_raw_write_packet,
237  .flags = AVFMT_NOTIMESTAMPS,
238 };
239 #endif
240 
241 #if CONFIG_MJPEG_MUXER
242 AVOutputFormat ff_mjpeg_muxer = {
243  .name = "mjpeg",
244  .long_name = NULL_IF_CONFIG_SMALL("raw MJPEG video"),
245  .mime_type = "video/x-mjpeg",
246  .extensions = "mjpg,mjpeg",
247  .audio_codec = AV_CODEC_ID_NONE,
248  .video_codec = AV_CODEC_ID_MJPEG,
249  .write_header = force_one_stream,
250  .write_packet = ff_raw_write_packet,
251  .flags = AVFMT_NOTIMESTAMPS,
252 };
253 
254 AVOutputFormat ff_singlejpeg_muxer = {
255  .name = "singlejpeg",
256  .long_name = NULL_IF_CONFIG_SMALL("JPEG single image"),
257  .mime_type = "image/jpeg",
258  .audio_codec = AV_CODEC_ID_NONE,
259  .video_codec = AV_CODEC_ID_MJPEG,
260  .write_packet = ff_raw_write_packet,
261  .flags = AVFMT_NOTIMESTAMPS,
262  .write_header = force_one_stream,
263 };
264 #endif
265 
266 #if CONFIG_MLP_MUXER
267 AVOutputFormat ff_mlp_muxer = {
268  .name = "mlp",
269  .long_name = NULL_IF_CONFIG_SMALL("raw MLP"),
270  .extensions = "mlp",
271  .audio_codec = AV_CODEC_ID_MLP,
272  .video_codec = AV_CODEC_ID_NONE,
273  .write_header = force_one_stream,
274  .write_packet = ff_raw_write_packet,
275  .flags = AVFMT_NOTIMESTAMPS,
276 };
277 #endif
278 
279 #if CONFIG_MPEG1VIDEO_MUXER
280 AVOutputFormat ff_mpeg1video_muxer = {
281  .name = "mpeg1video",
282  .long_name = NULL_IF_CONFIG_SMALL("raw MPEG-1 video"),
283  .mime_type = "video/mpeg",
284  .extensions = "mpg,mpeg,m1v",
285  .audio_codec = AV_CODEC_ID_NONE,
286  .video_codec = AV_CODEC_ID_MPEG1VIDEO,
287  .write_header = force_one_stream,
288  .write_packet = ff_raw_write_packet,
289  .flags = AVFMT_NOTIMESTAMPS,
290 };
291 #endif
292 
293 #if CONFIG_MPEG2VIDEO_MUXER
294 AVOutputFormat ff_mpeg2video_muxer = {
295  .name = "mpeg2video",
296  .long_name = NULL_IF_CONFIG_SMALL("raw MPEG-2 video"),
297  .extensions = "m2v",
298  .audio_codec = AV_CODEC_ID_NONE,
299  .video_codec = AV_CODEC_ID_MPEG2VIDEO,
300  .write_header = force_one_stream,
301  .write_packet = ff_raw_write_packet,
302  .flags = AVFMT_NOTIMESTAMPS,
303 };
304 #endif
305 
306 #if CONFIG_RAWVIDEO_MUXER
307 AVOutputFormat ff_rawvideo_muxer = {
308  .name = "rawvideo",
309  .long_name = NULL_IF_CONFIG_SMALL("raw video"),
310  .extensions = "yuv,rgb",
311  .audio_codec = AV_CODEC_ID_NONE,
312  .video_codec = AV_CODEC_ID_RAWVIDEO,
313  .write_packet = ff_raw_write_packet,
314  .flags = AVFMT_NOTIMESTAMPS,
315 };
316 #endif
317 
318 #if CONFIG_TRUEHD_MUXER
319 AVOutputFormat ff_truehd_muxer = {
320  .name = "truehd",
321  .long_name = NULL_IF_CONFIG_SMALL("raw TrueHD"),
322  .extensions = "thd",
323  .audio_codec = AV_CODEC_ID_TRUEHD,
324  .video_codec = AV_CODEC_ID_NONE,
325  .write_header = force_one_stream,
326  .write_packet = ff_raw_write_packet,
327  .flags = AVFMT_NOTIMESTAMPS,
328 };
329 #endif
330 
331 #if CONFIG_VC1_MUXER
332 AVOutputFormat ff_vc1_muxer = {
333  .name = "vc1",
334  .long_name = NULL_IF_CONFIG_SMALL("raw VC-1 video"),
335  .extensions = "vc1",
336  .audio_codec = AV_CODEC_ID_NONE,
337  .video_codec = AV_CODEC_ID_VC1,
338  .write_header = force_one_stream,
339  .write_packet = ff_raw_write_packet,
340  .flags = AVFMT_NOTIMESTAMPS,
341 };
342 #endif
const char * s
Definition: avisynth_c.h:631
static int force_one_stream(AVFormatContext *s)
Definition: rawenc.c:32
int size
Definition: avcodec.h:1163
static AVPacket pkt
Format I/O context.
Definition: avformat.h:1272
uint8_t * data
Definition: avcodec.h:1162
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:177
#define av_log(a,...)
struct AVOutputFormat * oformat
The output container format.
Definition: avformat.h:1291
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define AVERROR(e)
Definition: error.h:43
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:175
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1328
const char * name
Definition: avformat.h:513
int ff_raw_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: rawenc.c:26
preferred ID for MPEG-1/2 video decoding
Definition: avcodec.h:107
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition: avformat.h:472
AVIOContext * pb
I/O context.
Definition: avformat.h:1314
Main libavformat public API header.
This structure stores compressed data.
Definition: avcodec.h:1139