I'm trying to read the GPS data from a GoPro camera, and the "tracks" method on AVAsset only lists three tracks, while there are actually five, according to ffmpeg.
What can I do to see all the tracks? I'm particularly interested in the GPMF track that contains GPS data.
Here's what AVAsset produces:
NSArray *trackA = asset.tracks;
index = 0;
for (AVAssetTrack *track in trackA) {
XLog(@"%ld. trackID = %d", index, track.trackID);
XLog(@"%ld. mediaType = %@", index, track.mediaType);
XLog(@"%ld. data size = %@", index, NSStringFromSize(track.naturalSize));
XLog(@"___________________________");
index++;
}
AVAsset creation date = 2022-11-13 13:33:57 +0000
AVAsset metadata = 2022-11-13 13:33:57 +0000
0. trackID = 1
0. mediaType = vide
0. data size = {3840, 2160}
___________________________
1. trackID = 2
1. mediaType = soun
1. data size = {0, 0}
___________________________
2. trackID = 3
2. mediaType = tmcd
2. data size = {0, 0}
while here is what ffmpeg produces.
ffmpeg -i GX010045.MP4
ffmpeg version 5.1.2 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 14.0.0 (clang-1400.0.29.202)
...
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'GX010045.MP4':
Metadata:
major_brand : mp41
minor_version : 538120216
compatible_brands: mp41
creation_time : 2022-11-13T13:33:57.000000Z
location : +38.0357-122.5819/
location-eng : +38.0357-122.5819/
firmware : HD9.01.01.72.00
Duration: 00:08:52.54, start: 0.000000, bitrate: 60206 kb/s
Stream #0:0[0x1](eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 59941 kb/s, 59.94 fps, 59.94 tbr, 60k tbn (default)
Metadata:
creation_time : 2022-11-13T13:33:57.000000Z
handler_name : GoPro H.265
vendor_id : [0][0][0][0]
encoder : GoPro H.265 encoder
timecode : 13:33:09:07
Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
Metadata:
creation_time : 2022-11-13T13:33:57.000000Z
handler_name : GoPro AAC
vendor_id : [0][0][0][0]
timecode : 13:33:09:07
Stream #0:2[0x3](eng): Data: none (tmcd / 0x64636D74) (default)
Metadata:
creation_time : 2022-11-13T13:33:57.000000Z
handler_name : GoPro TCD
timecode : 13:33:09:07
Stream #0:3[0x4](eng): Data: bin_data (gpmd / 0x646D7067), 48 kb/s (default)
Metadata:
creation_time : 2022-11-13T13:33:57.000000Z
handler_name : GoPro MET
Stream #0:4[0x5](eng): Data: none (fdsc / 0x63736466), 13 kb/s (default)
Metadata:
creation_time : 2022-11-13T13:33:57.000000Z
handler_name : GoPro SOS
At least one output file must be specified
AVAsset simply reports tracks that Apple is interested in. You have to write an .mp4 parser to find the tracks that other providers add (like GoPro).