This code is imported from mssdemux's tfxd/tfrf parsing function https://bugzilla.gnome.org/show_bug.cgi?id=777825