#include <string.h>
#include <math.h>
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
c = st->codec;
c->codec_id = codec_id;
- c->codec_type = CODEC_TYPE_AUDIO;
+ c->codec_type = AVMEDIA_TYPE_AUDIO;
/* put sample parameters */
+ c->sample_fmt = AV_SAMPLE_FMT_S16;
c->bit_rate = 64000;
c->sample_rate = 44100;
c->channels = 2;
+
+ // some formats want stream headers to be separate
+ if(oc->oformat->flags & AVFMT_GLOBALHEADER)
+ c->flags |= CODEC_FLAG_GLOBAL_HEADER;
+
return st;
}
pkt.size= avcodec_encode_audio(c, audio_outbuf, audio_outbuf_size, samples);
- if (c->coded_frame->pts != AV_NOPTS_VALUE)
+ if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE)
pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, st->time_base);
- pkt.flags |= PKT_FLAG_KEY;
+ pkt.flags |= AV_PKT_FLAG_KEY;
pkt.stream_index= st->index;
pkt.data= audio_outbuf;
c = st->codec;
c->codec_id = codec_id;
- c->codec_type = CODEC_TYPE_VIDEO;
+ c->codec_type = AVMEDIA_TYPE_VIDEO;
/* put sample parameters */
c->bit_rate = 400000;
AVPacket pkt;
av_init_packet(&pkt);
- pkt.flags |= PKT_FLAG_KEY;
+ pkt.flags |= AV_PKT_FLAG_KEY;
pkt.stream_index= st->index;
pkt.data= (uint8_t *)picture;
pkt.size= sizeof(AVPicture);
if (c->coded_frame->pts != AV_NOPTS_VALUE)
pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, st->time_base);
if(c->coded_frame->key_frame)
- pkt.flags |= PKT_FLAG_KEY;
+ pkt.flags |= AV_PKT_FLAG_KEY;
pkt.stream_index= st->index;
pkt.data= video_outbuf;
pkt.size= out_size;
/* auto detect the output format from the name. default is
mpeg. */
- fmt = guess_format(NULL, filename, NULL);
+ fmt = av_guess_format(NULL, filename, NULL);
if (!fmt) {
printf("Could not deduce output format from file extension: using MPEG.\n");
- fmt = guess_format("mpeg", NULL, NULL);
+ fmt = av_guess_format("mpeg", NULL, NULL);
}
if (!fmt) {
fprintf(stderr, "Could not find suitable output format\n");