]> git.sesse.net Git - ffmpeg/blobdiff - output_example.c
matroskaenc: use new metadata API
[ffmpeg] / output_example.c
index 515a172661103956825b9597e6aed1bd9fdf6565..612146dad0d0a462a03a864c1eee9c78ab59e712 100644 (file)
@@ -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;
@@ -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;
@@ -451,7 +453,7 @@ int main(int argc, char **argv)
     }
 
     /* allocate the output media context */
-    oc = av_alloc_format_context();
+    oc = avformat_alloc_context();
     if (!oc) {
         fprintf(stderr, "Memory error\n");
         exit(1);