]> git.sesse.net Git - ffmpeg/blobdiff - output_example.c
indent
[ffmpeg] / output_example.c
index 39866d892b7c005d3ca72f07fb02c8f695b48ac3..bd9b7c3f6ff2ad76ce283770567aba93225ee67f 100644 (file)
@@ -31,8 +31,8 @@
 #define M_PI 3.14159265358979323846
 #endif
 
-#include "avformat.h"
-#include "swscale.h"
+#include "libavformat/avformat.h"
+#include "libswscale/swscale.h"
 
 #undef exit
 
@@ -156,7 +156,8 @@ static void write_audio_frame(AVFormatContext *oc, AVStream *st)
 
     pkt.size= avcodec_encode_audio(c, audio_outbuf, audio_outbuf_size, samples);
 
-    pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, st->time_base);
+    if (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.stream_index= st->index;
     pkt.data= audio_outbuf;
@@ -217,9 +218,9 @@ static AVStream *add_video_stream(AVFormatContext *oc, int codec_id)
         c->max_b_frames = 2;
     }
     if (c->codec_id == CODEC_ID_MPEG1VIDEO){
-        /* needed to avoid using macroblocks in which some coeffs overflow
-           this doesnt happen with normal video, it just happens here as the
-           motion of the chroma plane doesnt match the luma plane */
+        /* Needed to avoid using macroblocks in which some coeffs overflow.
+           This does not happen with normal video, it just happens here as
+           the motion of the chroma plane does not match the luma plane. */
         c->mb_decision=2;
     }
     // some formats want stream headers to be separate
@@ -380,7 +381,8 @@ static void write_video_frame(AVFormatContext *oc, AVStream *st)
             AVPacket pkt;
             av_init_packet(&pkt);
 
-            pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, st->time_base);
+            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.stream_index= st->index;
@@ -538,7 +540,7 @@ int main(int argc, char **argv)
 
     if (!(fmt->flags & AVFMT_NOFILE)) {
         /* close the output file */
-        url_fclose(&oc->pb);
+        url_fclose(oc->pb);
     }
 
     /* free the stream */