{"id":1080,"date":"2009-10-08T18:51:15","date_gmt":"2009-10-08T16:51:15","guid":{"rendered":"https:\/\/alax.info\/blog\/?p=1080"},"modified":"2009-10-08T18:51:15","modified_gmt":"2009-10-08T16:51:15","slug":"how-to-make-a-constant-frame-rate-video-stream-from-variable-frame-rate-stream-and-rescale-it","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/1080","title":{"rendered":"How to make a constant frame rate video stream from variable frame rate stream, and rescale it"},"content":{"rendered":"<p>From a conversation:<\/p>\n<blockquote><p>I have a  video stream with variable frame rate, I want to make this in to a constant\u00a0 frame rate. Do you know of any filters that could help me with this?<\/p><\/blockquote>\n<p>Such filter is actually quite easy. You only need to update time stamps of the media samples that are going through. I am not aware of\u00a0 an &#8220;out of the box&#8221; ready filter, but you can even do it without special filter: if you build your graph with <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd377544%28VS.85%29.aspx\">Sample Grabber Filter<\/a> in it in\u00a0 the place of interest, and initialize it to have a callback for each sample, then in <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd376987%28VS.85%29.aspx\">SampleCB<\/a> method you will be able to update time stamps using methods of <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd407001%28VS.85%29.aspx\">IMediaSample<\/a> interface. This is sufficient to redistribute the frames on the timeline, so that they go at constant frame rate.<\/p>\n<blockquote><p>In your opinion what is the best way to scale the video?<\/p><\/blockquote>\n<p>The best depends on what is the criteria (speed, quality etc). The simplest for me while very efficient &#8211; and I did this a number of times &#8211; is to use a custom filter which inside it uses <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd145120%28VS.85%29.aspx\">StretchBlt<\/a> <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd145120%28VS.85%29.aspx\" target=\"_blank\"><\/a> function on a per frame basis to scale input RGB video into output RGB video of a different resolution.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>From a conversation: I have a video stream with variable frame rate, I want to make this in to a constant\u00a0 frame rate. Do you know of any filters that could help me with this? Such filter is actually quite easy. You only need to update time stamps of the media samples that are going&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/1080\">Read the full article<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[78,273,272,246,274,486],"class_list":["post-1080","post","type-post","status-publish","format-standard","hentry","category-technology","tag-directshow","tag-fps","tag-frame-rate","tag-resolution","tag-time-stamp","tag-video"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/1080","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/comments?post=1080"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/1080\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=1080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=1080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=1080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}