M2TS TS packet timecode not updating; possible fix suggested

Started by KenNeighbors, September 16, 2016, 07:13:12 PM

Previous topic - Next topic

KenNeighbors

System type: Linux
ExifTool version: 10.26
Command line: exiftool -v3 Canon_HFS21.MTS | less
Console output:

Transport packet 1:
    0180: 00 00 46 5e 47 41 00 10 00 02 b0 39 00 01 c1 00 [..F^GA.....9....]
    [truncated]
  Timecode:   0x0000
  Packet ID:  0x0100 (Program 1 Map)
  Start Flag: Yes


The timecode is 0x4653 (the first four bytes), but exiftool is showing  0x0000, which was the timecode for packet 0.  It doesn't seem to update for each transport packet, but only periodically.

I fixed this by changing line 407 in M2TS.pm from:

            printf $out "  Timecode:   0x%.4x\n", Get32u(\$buff, 0) if $pLen == 192;

to

            printf $out "  Timecode:   0x%.4x\n", Get32u(\$buff, $pos - $prePos) if $pLen == 192;

I am not sure if "$pos - $prePos" is correct -- I copied it from the "Start" option in the "HexDump" command on the previous lines -- but with that value it does seem to be showing the correct timecode for all the transport packets I looked at.

I used a sample MTS file listed in this post:
    http://www.dvinfo.net/forum/canon-xf-series-hd-camcorders/478223-xf300-compared-panasonic-hdc-tm700.html#post1524096:
Direct link to sample file (137MB):
    http://www.aktiv-verlag.com/~webvideos/testvideos/2010/canon/Canon_HFS21.MTS

Phil Harvey

Excellent!!  Looks good.  Thanks for this bug fix.  It will appear in ExifTool 10.27 when it is released.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).