The PlayMemories app from Sony offers a "Map view" of the GPS data captured by the camera. This is done by selecting "Tools", "Map view", and then dragging a video or photo containing GPS data into a box indicated by the app. This results in a static view of the GPS location data overlayed on a map and/or satellite photo.
Another option for viewing the GPS data captured with video is within PlayMemories using the "Multi view" option. This is done by selecting "Tools", "Edit Media Files", "Create Multi view", and then dragging a video containing GPS data into the box indicated by the app. This generates another video file with the date, time, speed information, and an animated breadcrumb trail overlayed onto the video.
A third option is to view the captured GPS data in a third party map viewer. This involves first converting the NMEA sentences log file, described in my first post, into a GPX (GPS Exchange) file using a Windows app called "NMEA2KMZ" for example. The GPX file format is a widely used file format for exchanging GPS data.
A web search on "GPX viewer" returns a whole lot of viewers including Google Earth for viewing the GPX file.
Wednesday, 13 November 2013
Wednesday, 6 November 2013
Visualizing Sony HDR AS30V GPS Data
I recently got the Sony HDR AS30V POV camera primarily because it had a built-in GPS function that wasn't available on the other POV cameras. However, in order to visualize the logged GPS data, the captured video must be uploaded into the Sony PlayMemories app where the GPS information is overlayed on to the video. The video sequence is then re-encoded.
Apart from additional time required to re-encode the a video (potentially many hours for a long video), this process is currently not supported by the MacOS version of the PlayMemories app. There is also the issue of re-encoding the compressed video which will further degrade the video, although my experience has shown that the re-encoded video from PlayMemories is very good.
I would like to describe a way of visualizing the logged GPS information without using the PlayMemories app. This method will create the GPS information in a subtitle file. This subtitle file can be added as a track in a MPEG-4 file in conjunction with the original video, or it can be read in explicitly during playback of the original MPEG-4 file. The GPS subtitle track can be selectively enabled or disabled during playback without affecting the original video information. Having access to the raw GPS data also allows you to derive other information like tracking angle to display.
The steps involved in the process are :
- Upload the MPEG-4 video file from the MicroSD card
- Upload the GPS log file from the MicroSD card
- Convert the GPS log file into a Subrip file to be used as the subtitle
- Create a new MPEG-4 file containing the original MPEG-4 video file and the GPS subtitle file. (Optional)
Uploading the MPEG4 Video File
Connect the camera to your computer and browse through the files on the MicroSD card. The recorded video is stored in .MP4 files located in the MP_ROOT > 100ANV01 directory. Upload the required file on to your computer.
Uploading the GPS Log File
The GPS information on the camera is stored in files located on the MicroSD card. It is stored in the PRIVATE > SONY > GPS directory. The .LOG file is a text file containing NMEA sentences which log the time, position and speed information. There is a .LOG file for each .MP4 file recorded when the GPS is enabled.
Converting the .LOG File to a Subtitle File
I have written a simple C-program log2srt.c that reads the speed information from the .LOG file and writes it to a .srt file specifying the speed to be displayed at different time instances. As the speed information is recorded in knots in the .LOG file, I have included the option to convert it to km/h or mph.
The program can be further enhanced to change the format or location of the subtitle, and also write out other information for display to the subtitle file as required.
Creating a new MPEG4 file with Video and Subtitle(Optional)
The MP4Box program was used to add the subtitle track into a new MPEG4 file using the following command.
MP4Box -add <MP4 filename> -add <srt filename> -new <new MP4 filename>
For example :
MP4Box -add in.MP4 -add speed.srt -new out.MP4
MP4Box is available for Windows, MacOS and also Linux.
Using the "MP4Box -info <filename>" command, we can see the before and after information about the tracks in the MPEG-4 file.
Here is the track information about a file before I added the subtitle track.
* Movie Info *
Timescale 90000 - Duration 01:33:04.579
2 track(s)
Fragmented File: no
File Brand MSNV - version 21364873
Created: GMT Sun Nov 3 01:53:06 2013
Modified: GMT Sun Nov 3 01:53:06 2013
File has no MPEG4 IOD/OD
Track # 1 Info - TrackID 1 - TimeScale 30000 - Media Duration 01:33:04.579
Track has 1 edit lists: track duration is 01:33:04.579
Media Info: Language "Undetermined" - Type "vide:avc1" - 167370 samples
Visual Track layout: x=0 y=0 width=1280 height=720
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 1280 x 720
AVC Info: 1 SPS - 1 PPS - Profile Main @ Level 4
NAL Unit length bits: 32
Pixel Aspect Ratio 1:1 - Indicated track size 1280 x 720
Self-synchronized
Track # 2 Info - TrackID 2 - TimeScale 48000 - Media Duration 01:33:04.576
Track has 1 edit lists: track duration is 01:33:04.576
Media Info: Language "Undetermined" - Type "soun:mp4a" - 261777 samples
MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 48000
Synchronized on stream 1
Here is the track information about the file I added the subtitle track to. Notice "TrackID 3" has been added as "Timed Text".
* Movie Info *
Timescale 600 - Duration 01:33:04.578
3 track(s)
Fragmented File: no
File suitable for progressive download (moov before mdat)
File Brand isom - version 1
Created: GMT Thu Nov 7 05:18:29 2013
Modified: GMT Thu Nov 7 05:18:29 2013
File has root IOD (9 bytes)
Scene PL 0xff - Graphics PL 0xff - OD PL 0xff
Visual PL: Not part of MPEG-4 Visual profiles (0xfe)
Audio PL: AAC Profile @ Level 2 (0x29)
No streams included in root OD
Track # 1 Info - TrackID 1 - TimeScale 30000 - Media Duration 01:33:04.579
Track has 1 edit lists: track duration is 01:33:04.578
Media Info: Language "Undetermined" - Type "vide:avc1" - 167370 samples
Visual Track layout: x=0 y=0 width=1280 height=720
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 1280 x 720
AVC Info: 1 SPS - 1 PPS - Profile Main @ Level 4
NAL Unit length bits: 32
Pixel Aspect Ratio 1:1 - Indicated track size 1280 x 720
Self-synchronized
Track # 2 Info - TrackID 2 - TimeScale 48000 - Media Duration 01:33:04.576
Track has 1 edit lists: track duration is 01:33:04.575
Media Info: Language "Undetermined" - Type "soun:mp4a" - 261777 samples
MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 48000
Synchronized on stream 1
Track # 3 Info - TrackID 3 - TimeScale 1000 - Media Duration 01:33:04.000
Media Info: Language "Undetermined" - Type "text:tx3g" - 5535 samples
Timed Text - Size 1280 x 720 - Translation X=0 Y=0 - Layer 0
Playing the MPEG4 file with Subtitle
Currently, I have only used VLC for playback. When using VLC, the subtitle track has to be explicitly enabled by selecting "TRACK 1" under the Subtitle > Sub Track menu after you open the MPEG4 file which contains the embedded subtitle track.
VLC is also able to include the subtitle file on-the-fly while playing the original MPEG-4. This allows you to bypass the process of creating a new MPEG-4 file which has the subtitle track included. After commencing playback of the MPEG-4 file in VLC, go to the Subtitle > Add Subtitle File menu to add the subtitle file created by the log2srt.c program.
VLC is available for Windows, MacOS and also Linux.
Moreover, the subtitle file can be uploaded to YouTube as a Caption file so that the information can be overlayed over the video as shown in this example.
Future Enhancements
As mentioned earlier, other GPS information can be written to the .srt file. I will update the program as more features are added.
Subscribe to:
Posts (Atom)