Our site remains ad-free thanks to Linode. See if Linode works for you with $100 in credit. Accelerate innovation with simple, affordable, and accessible Linux cloud solutions and services. See why developers around the world trust Linode.
The post is not sponsored by the above affiliate and the content here is not representative of their company.
When you watch a video online, either it being YouTube, Vimeo, HTML5 or even an advertisement, the video is saved to your computer. When HTTP is sending you a video to watch, a segment or part of the video is sent. Multiple of these requests are being handled at the same time. When a segment is ready it starts playing the video while still receiving more video segments. With this method, you can watch you video while still receiving future video parts, thus minimizing the buffering time.
Since the file gets saved to your computer, there are programs to view videos you have watched online and be able to “save” them. It’s not really saving to your computer since they are already located on your computer. Although, if you don’t move them away from the web browsers cache folder, they will most likely get deleted. A web browser has a set cache size usually. When a file gets too old and expires from the cache it’s deleted or if more room is needed the file is deleted. Google Chrome uses a Least Recently Used algorithm to detect which part of the cache they can deleted to save space.
Right now we have a simple Least Recently Used algorithm that just starts deleting old entries once a certain limit is exceeded, and a second algorithm that takes reuse and age into account before evicting an entry.
Using the tool VideoCacheView by NirSoft, you can see all of the cached videos on your computer. I have only tested this with Firefox and Chrome. This isn’t some magical tool that will be able to recover a full video you watched a few days ago. This tool should be used right after watching a video that you want to save. Any time after that, you can assume the file is deleted. The sad truth is, even if you use the tool right after you watch a video, getting the video may be difficult. When you watch videos online, some services split the video into different requests which make video seeking faster and buffering faster also. Finding all of the required files and rendering them together can be very time consuming. But don’t let that deter you from at least trying this method first.
How VideoCacheView Works
This is the way I best believe VideoCacheView works. I didn’t decode VideoCacheView or look into what it was reading from the file system. The way VideoCacheView works is very similar to how cache viewing software works, except that it filters out any file that isn’t a video.
- Find the Web Browsers Cache Directories. Finding the cache directories is either stored as a string in the registry or saved as a known default location. For example, Chrome saves to C:\Users\Name\AppData\Local\Google\Chrome\User Data\Default\Cache. Other browsers also have their own set default locations.
- Open the Cache Index or Structure. In Chrome, we have both index and data_# files. These two files combined will give you the location or data for each element stored in the cache. If the cache element is too large, such as a video, it’s saved to an external location with the file name of f_hexcode. The hexcode is stored in the data_# files.
- Check if Cache Element is a Video. This can be done in a few different ways, the best being header check. Each file type has a different header to identify itself. The software will check each file and see if it’s really a video file or not. The alternative is to look at the file name. The filename at times will be appended with the file extension, but this can’t always be trusted. Any file can have any file extension and yet not be what it says it is. (This is one way people can exploit websites).
For Chrome, either Google Chrome or Chromium, you can learn more about the cache data structure at the Chromium Developers Site. I’m kinda shocked they didn’t just use a SQLite file like they did with the majority of their other files. At the time of writing this post, they are working on a new caching method, but I am unaware what they are changing between the two versions.
I would also like to give a shout out to NirSoft. They have a lot of amazing tools that I use on a daily basis. And you can expect some of their software to be in future videos and tutorials.