X

NV5 Geospatial Blog

Each month, NV5 Geospatial posts new blog content across a variety of categories. Browse our latest posts below to learn about important geospatial information or use the search bar to find a specific topic or author. Stay informed of the latest blog posts, events, and technologies by joining our email list!



Thermal Infrared Echoes: Illuminating the Last Gasp of a Dying Star

Thermal Infrared Echoes: Illuminating the Last Gasp of a Dying Star

4/24/2025

This blog was written by Eli Dwek, Emeritus, NASA Goddard Space flight Center, Greenbelt, MD and Research Fellow, Center for Astrophysics, Harvard & Smithsonian, Cambridge, MA. It is the fifth blog in a series showcasing our IDL® Fellows program which supports passionate retired IDL users who may need support to continue their work... Read More >

A New Era of Hyperspectral Imaging with ENVI® and Wyvern’s Open Data Program

A New Era of Hyperspectral Imaging with ENVI® and Wyvern’s Open Data Program

2/25/2025

This blog was written in collaboration with Adam O’Connor from Wyvern.   As hyperspectral imaging (HSI) continues to grow in importance, access to high-quality satellite data is key to unlocking new insights in environmental monitoring, agriculture, forestry, mining, security, energy infrastructure management, and more.... Read More >

Ensure Mission Success With the Deployable Tactical Analytics Kit (DTAK)

Ensure Mission Success With the Deployable Tactical Analytics Kit (DTAK)

2/11/2025

In today’s fast-evolving world, operational success hinges on real-time geospatial intelligence and data-driven decisions. Whether it’s responding to natural disasters, securing borders, or executing military operations, having the right tools to integrate and analyze data can mean the difference between success and failure.... Read More >

How the COVID-19 Lockdown Improved Air Quality in Ecuador: A Deep Dive Using Satellite Data and ENVI® Software

How the COVID-19 Lockdown Improved Air Quality in Ecuador: A Deep Dive Using Satellite Data and ENVI® Software

1/21/2025

The COVID-19 pandemic drastically altered daily life, leading to unexpected environmental changes, particularly in air quality. Ecuador, like many other countries, experienced significant shifts in pollutant concentrations due to lockdown measures. In collaboration with Geospace Solutions and Universidad de las Fuerzas Armadas ESPE,... Read More >

Rapid Wildfire Mapping in Los Angeles County

Rapid Wildfire Mapping in Los Angeles County

1/14/2025

On January 8, WorldView-3 shortwave infrared (SWIR) imagery captured the ongoing devastation of the wildfires in Los Angeles County. The data revealed the extent of the burned areas at the time of the capture, offering critical insights for rapid response and recovery. To analyze the affected region, we utilized a random forest... Read More >

1345678910Last
«May 2025»
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
16359 Rate this article:
No rating

How many frames are in a movie?

Anonym
In IDL 8.2.3, we introduced video read capabilities, though the IDLffVideoRead class and the READ_VIDEO function, to complement the video write capabilities available since IDL 8.1. I'm still new to using video as a data format, so I thought I'd post an example of something interesting that I learned recently. We've included a video of a coronal mass ejection viewed from NASA's SDO and SOHO spacecraft in the IDL distribution:
IDL> video_file = file_which('CME.mp4')
How many frames are in this video file? The answer isn't as simple I'd expected. Start with QUERY_VIDEO, which can return a structure of information about a video file:
IDL> !null = query_video(video_file, video_info)
IDL> print, video_info.num_frames
         574
There are 574 frames in the file. But wait, let's try to read the entire file into IDL with READ_VIDEO:
IDL> movie = read_video(video_file, /all)
IDL> help, movie
MOVIE           BYTE      = Array[3, 512, 288, 564]
READ_VIDEO returns frames as pixel-interleaved RGB images. So I guess there are only 564 frames in the file? Let's turn to the lower-level API exposed in IDLffVideoRead to check whether it provides different information. The GetStreams method gives information about the single video stream in the file:
IDL> v = idlffvideoread(video_file)
IDL> print, (v.getstreams()).count
         574
If you look at the source code for QUERY_VIDEO, you'll see that it uses this technique for returning the frame count. But what about iterating through the file, reading frame by frame, until the end is reached?  This code block:
   i = 0
   repeat begin
      data = v.getnext(type=t)
      ++i
   endrep until t eq -1
does so. The result:
IDL> print, --i
         564
OK, why are there two different values for the number of frames in the video file? I asked an engineer on the IDL team, Andrew Magill, who is far more knowledgeable about video than I am, about this. He offered a pair of possibilities:
It's possible FFmpeg doesn't actually know ahead of time how many frames there are. The number out of ::GetStreams might be an estimate based on video length, framerate, file size, etc. Or maybe there are actually 574 frames, but the last 9 can't be decoded.
Andrew also gave some technical details that I haven't included, and suggested that these may not be the only possibilities. Further, I thought his summary was enlightening:
Unfortunately, video technology is full of these little technical gotchas, and seems to be full of questions that can only be answered with "well, it depends".  FFmpeg can seem really inconsistent sometimes, but I think they've done a heroic job of making all these different standards work almost exactly the same.
I hope that through Andrew's work, and the power of FFmpeg, we can make video processing a straightforward task in IDL. I'll post other examples of working with video as I learn more about it!
Please login or register to post comments.