A very popular format from DVR’s that form a high percentage of devices found out in the wild.
Although I have been working with these for years, it wasn’t until a recent conversation with someone else in the field of video investigation that I realised that some people were finding them difficult. They are a little confusing at first, so it’s necessary to delve deep….
The disk structure contains folders that house the video files. There is also a codec install program and an index.xml file along with an associated folder.
Firstly, the Codec install. I have found that this codec can seriously play havoc with a working system. It causes crashes in the quartz.dll which is the Windows Directshow media handler. It also brings up an error detailing the shmedia.dll which deals with thumbnail creation. You can get around this issue by unregistering the .dll but it really requires a full system clean and repair to get it back up and running. My advice – DON’T INSTALL IT!
The .xml file will display correctly in older versions of Internet Explorer, and maybe some other programs, but finding software that displays it correctly now is difficult.
Whatever the program used, it does offer important information on what is included.
In each folder there are .avi video files and each one has a .smi file with the same name. The .smi files are subtitle files that include the date and time information. I will come back to these later.
So, without installing the codec, what options have we got? First, lets take a look at one of the files in gSpot….
As can be seen, I have the DivX 5 Codec installed so the file is being read….. but there are problems. The first one is that gSpot cannot read the GOP Structure correctly. There are other problem’s but I will try and deal with one at a time.
As DivX is a common Codec installed within standard players, it should play in SMplayer or other Codec included players etc….
During playback, the program has automatically detected the .smi file and the timecode is presented.
VLC used to be a popular method for viewing these files but whilst examining these and attempting playback in Ver. 2.0.6, the files failed to play.
The files also played back straight away in Virtualdub…..
Its here that things start to get interesting!
gSpot was obviously having issues in reading the file correctly and gave 1448 Frames. Virtualdub now gives 9038 Frames. There is a large amount of duplicates but of a bigger concern is that it is not playing back smoothly. Once every 13 new images, the frames reverse by an image. Basically 12 forward and 1 back. If the video is loaded into Virtualdub using the ffmpeg input driver – the video fails to load.
This is important to note, as if you miss this and just use virtualdub to save as an uncompressed .avi, your result will include the wrong presentation of the frames as well.
The reason why this is happening lies in what is being used to decode the video. If we utilise the built in codec of a player such as SMplayer then it plays correctly. If we use the System codec as is being used by Virtualdub – it has problems. As gSpot is also using the System codec, this explains why gSpot can’t deal with it correctly.
Now that we know that there are issues with the file, we can start to figure out what information is required, how to get it and how to deal with the file for any reason.
ffmpeg -show_streams -count_frames -pretty inputfile.avi > inputfile.txt
This gives us the details on the video stream and counts the frames. In the example used here, it gives 2202 Frames. It also presents the frame rate that when calculated results in the 9038 frames presented by Virtualdub.
To take a closer look at the Frames:
ffmpeg -show_frames -print_format xml -v quiet inputfile.avi > inputfile.xml
This results in a large xml sheet detailing the exact makeup of the video…..
There is a lot of information given, with the above screenshot just a small part, but thanks to this, we can see the GOP structure and can identify individual frames and their type if necessary. An interesting figure is the Sample Aspect Ratio (SAR). This is extra to the Pixel Aspect Ratio (PAR) and the Display Aspect Ratio (DAR) and is only used by mpeg4 based files. To calculate the Display Aspect Ratio from the Sample Aspect Ratio:
Width (352) x 12 = 4224
Height (288) x 11 = 3168
4224 / 3168 = 4:3
Anyway, back to the file. We now need to create a video with just the images in, no duplicates.
ffmpeg -i inputfile.avi -vsync drop -vcodec rawvideo outputfile.avi
This then creates an uncompressed .avi file with only the 2202 individual frames. If it’s necessary to identify their type, the .xml document can be referred to.
We now need to take a look at the subtitle in order to make a video, perhaps a DVD, for the purpose of presentation. Obviously it is possible to keep the date/time information separate and keep it as a subtitle. DVD’s can use subtitles but I prefer to hard encode them onto the video prior to any presentation format.
We need to return to using the original .avi file for this as we need to ensure that the timing stays correct.
There are a few different ways of dealing with subtitles and a handy utility is Subtitle Workshop. This will enable you to load in the .smi file and take a look through it’s structure. It can also be used to partner the specific time overlay to a specific frame number.
The quickest method though,and avoiding any other programs or subtitle reconfiguring, is to prepare FFmpeg to deal with subtitles.
1. Ensure that your version of FFmpeg is using the libass library –enable-libass. This is already enabled in all of the latest builds from Zeranoe.
2. Download the zip file called fonts.zip from my Shared box. Unzip it into the folder that contains your ffmpeg.exe. You should now have a fonts folder with a fonts.conf file inside.
FFmpeg is now set up for using subtitles.
To deal with our .avi and .smi files and create video files that have the subtitle information hard encoded in, we need to tweak the .smi files.
Open the first .smi file in Notepad. File > Save as
You need to save this into the directory that holds your ffmpeg.exe
You MUST save it as subtitle.smi
Save as type: All Files
Your FFmpeg command now to output an uncompressed .avi with the subtitles burned on ready for presentation use would be:
ffmpeg -i inputfile.avi -vf "subtitles=subtitle.smi" -vcodec rawvideo -r 25 output.avi
Note: The frame rate in the original may not be exactly 25FPS. If it was not corrected, a lot of authoring software may either not deal with the file or worse, badly encode it. As such, I correct this when creating the uncompressed copy to avoid any issues. This form of video is for preview only.
If your authoring software has the option of not re-encoding DVD compliant files then you can really speed things up by going direct from the original file to DVD Mpeg2 by using the following:
ffmpeg -i inputfile.avi -vf "subtitles=subtitle.smi" -target pal-dvd -qscale 0 output.mpg
AVS2DVD has a small tickbox under Video settings to skip transcoding on mpeg2 files.
We can quickly view the files, along with the date and time information in standalone players such as SMplayer.
We can obtain full video and frame information using FFprobe.
We can create a video of only non duplicate images by using FFmpeg and then deal with those images in Virtualdub.
We can hard burn in the date and time information by using the subtitle filter in FFmpeg.
Finally, it is worth highlighting that this type of video does suffer with the same frame timing issues as detailed here. If timing and motion forms part of your enquiry, you need to observe the individual frames very closely.
I hope that this helps you in dealing with the files.