00001 00006 #ifndef FFMPEG_OUTPUT_H 00007 #define FFMPEG_OUTPUT_H 00008 00009 00010 /* 00011 * Libavformat API example: Output a media file in any supported 00012 * libavformat format. The default codecs are used. 00013 * 00014 * Copyright (c) 2003 Fabrice Bellard 00015 * 00016 * Permission is hereby granted, free of charge, to any person obtaining a copy 00017 * of this software and associated documentation files (the "Software"), to deal 00018 * in the Software without restriction, including without limitation the rights 00019 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00020 * copies of the Software, and to permit persons to whom the Software is 00021 * furnished to do so, subject to the following conditions: 00022 * 00023 * The above copyright notice and this permission notice shall be included in 00024 * all copies or substantial portions of the Software. 00025 * 00026 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00027 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00028 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00029 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00030 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00031 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00032 * THE SOFTWARE. 00033 */ 00034 #include <stdlib.h> 00035 #include <stdio.h> 00036 #include <string.h> 00037 #include <math.h> 00038 00039 #ifndef M_PI 00040 #define M_PI 3.1415926535897931 00041 #endif 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 #include <ffmpeg/avformat.h> 00047 #include <ffmpeg/swscale.h> 00048 #ifdef __cplusplus 00049 } 00050 #endif 00051 00052 #undef exit 00053 00054 #define STREAM_PIX_FMT PIX_FMT_YUV420P /*default - mpeg*/ 00055 #define STREAM_FRAME_RATE 30 //mcv 00056 #define STREAM_NB_FRAMES 100000 //mcv 00057 00058 00059 /**************************************************************/ 00060 /* video output */ 00061 /**************************************************************/ 00062 AVStream *add_video_stream(AVFormatContext *oc, int codec_id); 00063 void open_video(AVFormatContext *oc, AVStream *st); 00064 void write_video_frame(AVFormatContext *oc, AVStream *st, int frame_count, unsigned char* imgFrame); 00065 void close_video(AVFormatContext *oc, AVStream *st); 00066 00067 00068 /**************************************************************/ 00069 /* audio output */ 00070 /**************************************************************/ 00071 AVStream *add_audio_stream(AVFormatContext *oc, int codec_id); 00072 void open_audio(AVFormatContext *oc, AVStream *st); 00073 void get_audio_frame(int16_t *samples, int frame_size, int nb_channels); 00074 void write_audio_frame(AVFormatContext *oc, AVStream *st); 00075 void close_audio(AVFormatContext *oc, AVStream *st); 00076 00077 00078 00079 #endif
1.4.7