Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] libavformat/asfdec_f: add asf video average framerate support
@ 2025-10-09 11:21 ZhangXu via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: ZhangXu via ffmpeg-devel @ 2025-10-09 11:21 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: zhangxu

From: zhangxu <zhangxu@sobey.com>

Refer to Advanced Systems Format (ASF) Specification

Parse AverageTimePerFrame from ExtendedStreamPropertiesObject

Signed-off-by: ZhangXu <zhangxu@sobey.com>
---
 libavformat/asfdec_f.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index 3b46fe01f6..aaff5278d9 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -63,6 +63,8 @@ typedef struct ASFStream {
 
     int64_t packet_pos;
 
+    int64_t avg_time_dur;                ///< the average time duration
+
     uint16_t stream_language_index;
 
     int      palette_changed;
@@ -481,6 +483,7 @@ static int asf_read_ext_stream_properties(AVFormatContext *s)
     int ext_len, payload_ext_ct, stream_ct, i;
     uint32_t leak_rate, stream_num;
     unsigned int stream_languageid_index;
+    uint64_t stream_avg_time_dur;
 
     avio_rl64(pb); // starttime
     avio_rl64(pb); // endtime
@@ -498,7 +501,10 @@ static int asf_read_ext_stream_properties(AVFormatContext *s)
     if (stream_num < 128)
         asf->streams[stream_num].stream_language_index = stream_languageid_index;
 
-    avio_rl64(pb); // avg frametime in 100ns units
+    stream_avg_time_dur = avio_rl64(pb); // avg frametime in 100ns units
+    if (stream_num < 128)
+        asf->streams[stream_num].avg_time_dur = stream_avg_time_dur;
+
     stream_ct      = avio_rl16(pb); // stream-name-count
     payload_ext_ct = avio_rl16(pb); // payload-extension-system-count
 
@@ -838,6 +844,10 @@ static int asf_read_header(AVFormatContext *s)
                     i, st->codecpar->codec_type, asf->dar[i].num, asf->dar[i].den,
                     st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
 
+            //this field set for video
+            if (asf->streams[i].avg_time_dur && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+                av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den, 10000000, asf->streams[i].avg_time_dur, INT_MAX);
+            
             // copy and convert language codes to the frontend
             if (asf->streams[i].stream_language_index < 128) {
                 const char *rfc1766 = asf->stream_languages[asf->streams[i].stream_language_index];
-- 
2.25.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-10-09 11:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-09 11:21 [FFmpeg-devel] [PATCH] libavformat/asfdec_f: add asf video average framerate support ZhangXu via ffmpeg-devel

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ http://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git