Add to limit 'probesize' for getting stream information. 52/266352/2 accepted/tizen/6.5/unified/20211112.053752 submit/tizen_6.5/20211111.080152
authorJiyong Min <jiyong.min@samsung.com>
Tue, 9 Nov 2021 02:40:16 +0000 (11:40 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Thu, 11 Nov 2021 03:25:25 +0000 (03:25 +0000)
[Problem]
Crash occurred for 8k contents due to mem-usage limitation on TV.
[Cause]
After getting stream information, 'ffmpeg' decode frames to probe it.
Decoding 8k video need lots of memory. About 33MB is used for each video frame.
[Solution]
Prevent probing stream information by 'probesize' limitation.

- The 'analyzeduration' and 'probesize' options affect the accuracy of stream information.
 If it could not find some parameters for stream info, we consider increasing the values.

Change-Id: Ice2917732ce6148597a7cb6cc7186e0ac06a0b05

formats/ffmpeg/Makefile.am
formats/ffmpeg/mm_file_format_ffmpeg.c
packaging/libmm-fileinfo.spec

index 653a8a41de936c116041a8cabcf9cd94cb2ccfad..eb5befc1435490e5c3c8d08c521a720ffe8be497 100755 (executable)
@@ -45,7 +45,7 @@ endif
 
 if USE_IOMMAP
 libmmfile_formats_la_CFLAGS += -D__MMFILE_MMAP_MODE__
-endif  
+endif
 
 
 libmmfile_formats_la_LIBADD = $(MMCOMMON_LIBS) \
index 66f1714ca1502163c38b24f56ac05918c197aaa8..b34fee786ea076551acea632774bd986f524b5b2 100644 (file)
@@ -451,12 +451,25 @@ int mmfile_format_read_stream_ffmpg(MMFileFormatContext *formatContext)
        pFormatCtx = formatContext->privateFormatData;
        pFormatCtx->start_time = -1;
 
+       /**
+        * If you could not find codec parameters for stream info,
+        * consider increasing the value for the 'analyzeduration' and 'probesize' options.
+        */
        /**
         *@important if data is corrupted, occur segment fault by av_find_stream_info().
         *                      - fixed 2009-06-25.
         */
+       /**
+        * fixed 2021-11-09
+        * if the content is 8k, the mem-usage in avformat_find_stream_info() is too large, 300MB or more.
+        * so we adjust 'probesize' to reduce memory usage in avformat_find_stream_info().
+        * Please refer to below for detail.
+        * https://ffmpeg.org/ffmpeg-formats.html#Format-Options
+        */
        if (formatContext->formatType == MM_FILE_FORMAT_M2TS)
                pFormatCtx->max_analyze_duration = 100000;      // MPEGTS file timeout set
+       else
+               pFormatCtx->probesize = 900000;
 
        if (formatContext->cdis != 1) {
                if (avformat_find_stream_info(pFormatCtx, NULL) < 0) {
index 8e68cf0d7e0da39bf1684344e19bd59b65c3a180..a0379c303e2080a76713609800a5b34ed8576126 100644 (file)
@@ -1,6 +1,6 @@
 Name:      libmm-fileinfo
 Summary:    Media Fileinfo
-Version:    1.0.4
+Version:    1.0.5
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0