[FFmpeg-devel,V1,1/2] lavf/flvdec: Fix AMF NUMBER type to metadata lost precision

Submitted by Jun Zhao on March 28, 2019, 7:39 a.m.

Details

Message ID 1553758747-26559-1-git-send-email-mypopydev@gmail.com
State New
Headers show

Commit Message

Jun Zhao March 28, 2019, 7:39 a.m.
From: Jun Zhao <barryjzhao@tencent.com>

use %.12g replace %.f when save AMF NUMBER(double) type to
metadata.

before this fix, we get FLV metadata like:

 Metadata:
    lasttimestamp   : 113
    lastkeyframetimestamp: 112

after this fix:

 Metadata:
    lasttimestamp   : 113.005
    lastkeyframetimestamp: 111.678

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavformat/flvdec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 445d58d..12bfd4b 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -649,7 +649,7 @@  static int amf_parse_object(AVFormatContext *s, AVStream *astream,
                        sizeof(str_val));
             av_dict_set(&s->metadata, key, str_val, 0);
         } else if (amf_type == AMF_DATA_TYPE_NUMBER) {
-            snprintf(str_val, sizeof(str_val), "%.f", num_val);
+            snprintf(str_val, sizeof(str_val), "%.12g", num_val);
             av_dict_set(&s->metadata, key, str_val, 0);
         } else if (amf_type == AMF_DATA_TYPE_STRING) {
             av_dict_set(&s->metadata, key, str_val, 0);