Stream Mapping from Vista Quantum Files

Ripping the individual camera streams from the Vista files

Many DVR companies do actually conform to standard video practices. When they do, it makes it so much easier to deal with the video for any purpose. One of the abilities in mpeg4 type video is to hold a number of streams together in one file. In the film world they could be different viewing angles or extra scenes. In the CCTV world, its a group of cameras. The below is a pretty common example, but you may find many different variations so always test and verify any stream mapping you conduct.

Disk Contents

Disk Contents

The video files are held within the Download folder but first we need to see what they look like within the player.

File Selection

File Selection

After going through the initial open  / find file and selecting the Download folder, the above dialogue box appears in front of the player interface. From this I can see 4 files with a date and times to and from.

When I select the first one, the main interface kicks into life.

Cameras

As the footage plays (not displayed in the image above) the number 12 appears next to the frame size. The frame size is shown as 360×288. The player does give a user the option to extract a still image but nothing for video export. I always look at the programs properties as well to see if any links are shown there but as is usual, there is nothing in the way of help. I see four camera views but have no idea on whether there are more cameras in use but not exported. I have no idea if Video Motion Detection is in use and another camera could kick in at any minute. It’s a bit of a mystery so we need to look further inside the Download folder.

InsideDownloadFolder

Inside the Download Folder

This reveals 4, reasonably large , un-extended files and 4 smaller .idx files. The. idx extension is regularly used for video indexes showing the time clock but they are all written differently and putting these into an understandable text for later use and analysis is, quite often, impossible. There are one or two that use standard subtitle formats that make things much easier for presentation work.

The four bigger files, I assume, are therefore the video. Now, we had four clips shown in the initial dialogue box when opening the program. When we viewed the video we had four camera angles. We need to establish if these files are the cameras or the time clips.

By dragging the first un-extended file into MediaInfo, we have our answer.

MediaInfo

MediaInfo

This tells me that its an MP4 Video file containing 4 streams at a duration of 13mn 32s. This is the duration reported by the player in the clip window. So, the files are the time clips and each one contains 4 streams of video – the cameras.

Important: There are some files that when dragged into a media player such as SMplayer, it will detect the first mp4 stream and play it. It only plays stream0 and not the others. It is very easy to miss other cameras included in the file.

I verified the MediaInfo findings and took a closer look at the streams by parsing the file through FFprobe:

The results for Stream0:

[STREAM]
index=0
codec_name=mpeg4
codec_long_name=MPEG-4 part 2
profile=unknown
codec_type=video
codec_time_base=1/50
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=352
height=288
has_b_frames=1
sample_aspect_ratio=12:11
display_aspect_ratio=4:3
pix_fmt=yuv420p
level=-99
timecode=N/A
quarter_sample=0
divx_packed=0
id=0x1e2
r_frame_rate=50/1
avg_frame_rate=50/1
time_base=1/90000
start_pts=5351900384
start_time=16:31:05.559822
duration_ts=73111044
duration=0:13:32.344933
bit_rate=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
[/STREAM]

Before we get into separating and dealing with the camera angles, it’s worth noting that the video, when played within the player presents an overlay stating 360 x 288. However, all the reports and analysis state a pixel width and height of 352 x 288!

Time to start creating our new files, and there are a few options. Depending on the use of the video may dictate what path is chosen. That decision would be down to you. Whatever method, we need to use the mapping parameter within FFmpeg.

ffmpeg -i videofile  -map 0:0 -vcodec copy -f avi -fflags genpts stream0.avi

The -map parameter tells the program to only parse stream 0. After completing the first one I just press the up arrow on the keyboard which puts the last command back within my window. I change the stream number and output file number and then hit enter again.

ffmpeg -i videofile  -map 0:1 -vcodec copy -f avi -fflags genpts stream1.avi

ffmpeg -i videofile  -map 0:2 -vcodec copy -f avi -fflags genpts stream2.avi

ffmpeg -i videofile  -map 0:3 -vcodec copy -f avi -fflags genpts stream3.avi

It’s really fast and within 30 seconds I have four video files.

All videos have the same encoding and timing. If your NLE can accept mp4 wrapped avi files then these should drop in nicely. They also scrub very quickly within programs like Virtualdub.

It may be necessary to do a little bit more analysis with these files.

Avinaptic (and other programs) reveal:

81227 Total Frames
71477 Null Frames
9750 Individual frames
of which
650 are I frames
9100 are P Frames

If we wanted to create frame only streams, thereby having no duplicate files, it would be necessary to transcode out of the mp4 encoding. Before doing this though we need to know the GOP structure.

Gspot results and GOP Presentation order

Gspot results and GOP Presentation order

GSpot verifies my frame count and displays the GOP. A 15 Frame GOP. I verified this with FFprobe again using the same process as detailed here. The results confirmed what Gspot had reported.

pict_type=I
coded_picture_number=0
pict_type=P
coded_picture_number=1
pict_type=P
coded_picture_number=2
pict_type=P
coded_picture_number=3
pict_type=P
coded_picture_number=4
pict_type=P
coded_picture_number=5
pict_type=P
coded_picture_number=6
pict_type=P
coded_picture_number=7
pict_type=P
coded_picture_number=8
pict_type=P
coded_picture_number=9
pict_type=P
coded_picture_number=10
pict_type=P
coded_picture_number=11
pict_type=P
coded_picture_number=12
pict_type=P
coded_picture_number=13
pict_type=P
coded_picture_number=14

By using FFmpeg again on the exported stream we can output a video with no duplicate frames. By identifying their frame numbers we know if they were an I frame or a P frame.

ffmpeg -i stream0.avi -vcodec rawvideo -vsync drop  stream0-UC.avi

There are a number of other options open to us.

If we added in -r 12 to the command above we could have the avi play at the correct frame rate (remember the 12 displayed in the window of the original player). So the command would be

ffmpeg -i stream0.avi -vcodec rawvideo -vsync drop -r 12 stream0-UC12.avi

If we wanted to go straight to this from the original video file and not bother extracting the streams in their original format…..

ffmpeg -i inputstream -map 0:0 -vcodec rawvideo -vsync drop -r 12 stream0-UC12.avi

The only problem in doing this is proving the GOP structure.

Mp4 is now pretty easy to deal with….h264 is becoming easier…..and now they have gone and brought out h265! Perhaps DVR manufacturers will start to give us an idea on what they do to the video by the time h265 starts to spread, then again perhaps pigs might fly!

Advertisements
By Spreadys Posted in EEPIP

2 comments on “Stream Mapping from Vista Quantum Files

  1. Pingback: UMV Files and SimplePlayer_M4.exe | Spreadys Space

  2. Pingback: Samsung RE4 and VFS4 Files | Spreadys Space

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s