]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/output-example.c
configure: Do not unconditionally add -Wall to host CFLAGS.
[ffmpeg] / libavformat / output-example.c
index 7eb3352b74fbc95e70675c26debf957a94c0ab3a..ddd16f1eed7485b7b9818895b89fbd95b8a7d93f 100644 (file)
 #include <string.h>
 #include <math.h>
 
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
 #include "libavformat/avformat.h"
 #include "libswscale/swscale.h"
 
@@ -69,9 +65,10 @@ static AVStream *add_audio_stream(AVFormatContext *oc, enum CodecID codec_id)
 
     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;
@@ -163,7 +160,7 @@ static void write_audio_frame(AVFormatContext *oc, AVStream *st)
 
     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;
 
@@ -203,7 +200,7 @@ static AVStream *add_video_stream(AVFormatContext *oc, enum CodecID codec_id)
 
     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;
@@ -372,7 +369,7 @@ static void write_video_frame(AVFormatContext *oc, AVStream *st)
         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);
@@ -389,7 +386,7 @@ static void write_video_frame(AVFormatContext *oc, AVStream *st)
             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;
@@ -447,10 +444,10 @@ int main(int argc, char **argv)
 
     /* 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");
@@ -484,7 +481,7 @@ int main(int argc, char **argv)
         exit(1);
     }
 
-    dump_format(oc, 0, filename, 1);
+    av_dump_format(oc, 0, filename, 1);
 
     /* now that all the parameters are set, we can open the audio and
        video codecs and allocate the necessary encode buffers */
@@ -495,7 +492,7 @@ int main(int argc, char **argv)
 
     /* open the output file, if needed */
     if (!(fmt->flags & AVFMT_NOFILE)) {
-        if (url_fopen(&oc->pb, filename, URL_WRONLY) < 0) {
+        if (avio_open(&oc->pb, filename, AVIO_FLAG_WRITE) < 0) {
             fprintf(stderr, "Could not open '%s'\n", filename);
             exit(1);
         }
@@ -548,7 +545,7 @@ int main(int argc, char **argv)
 
     if (!(fmt->flags & AVFMT_NOFILE)) {
         /* close the output file */
-        url_fclose(oc->pb);
+        avio_close(oc->pb);
     }
 
     /* free the stream */