diff mbox

[FFmpeg-devel] Fixed incorrect timestamps and initialization issues in transcoding.c example.

Message ID 01010164ce5f1cb3-8ad44823-17fa-4b6c-972a-abcd8cb2939e-000000@us-west-2.amazonses.com
State New
Headers show

Commit Message

Brian C. Wiles July 24, 2018, 10:18 p.m. UTC
---
 doc/examples/transcoding.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

-- 
2.17.1

Comments

Michael Niedermayer Aug. 8, 2018, 10:33 a.m. UTC | #1
On Tue, Jul 24, 2018 at 10:18:17PM +0000, Brian C. Wiles wrote:
> ---
>  doc/examples/transcoding.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 

[...]

> @@ -517,6 +518,11 @@ int main(int argc, char **argv)
>          return 1;
>      }
>  
> +    av_register_all();
> +    avcodec_register_all();
> +    avfilter_register_all();

These are deprecated functions

[...]
diff mbox

Patch

diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c
index a83fa3a185..bf653f7c50 100644
--- a/doc/examples/transcoding.c
+++ b/doc/examples/transcoding.c
@@ -2,6 +2,7 @@ 
  * Copyright (c) 2010 Nicolas George
  * Copyright (c) 2011 Stefano Sabatini
  * Copyright (c) 2014 Andrey Utkin
+ * Copyright (c) 2018 Brian C. Wiles.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -517,6 +518,11 @@  int main(int argc, char **argv)
         return 1;
     }
 
+    av_register_all();
+    avcodec_register_all();
+    avfilter_register_all();
+    avformat_network_init();
+
     if ((ret = open_input_file(argv[1])) < 0)
         goto end;
     if ((ret = open_output_file(argv[2])) < 0)
@@ -554,7 +560,9 @@  int main(int argc, char **argv)
             }
 
             if (got_frame) {
-                frame->pts = frame->best_effort_timestamp;
+                frame->pts = av_rescale_q(frame->best_effort_timestamp,
+                                          stream_ctx[stream_index].dec_ctx->time_base,
+                                          stream_ctx[stream_index].enc_ctx->time_base);
                 ret = filter_encode_write_frame(frame, stream_index);
                 av_frame_free(&frame);
                 if (ret < 0)