Search code examples
ffmpeghttp-live-streamingaacid3

HLS: reading PRIV ID3 tag with com.apple.streaming.transportStreamTimestamp PTS time mark


I have a hls live stream where i can go back 30 minutes (timeshift):

I want to save a part of the 30 minutes window as mp4 file locally.

I parsed the playlist, downloaded the single ts and aac segments and have put them together (concatinate). The result is always asynchronous.

There is a timestamp in the ts segments but not in the aac segments. The timestamps of the aac segment are probably in a private id3 tag, but i don't know how i can read them.

Here is a good analysis: https://github.com/flavioribeiro/nginx-audio-track-for-hls-module/issues/22

Does anyone have an idea how i can read that timestamp (OS: Linux)?


Solution

  • # get audio start from aac segment
    # dump private id3 Tag
    HEXDUMP=`exiftool -Private -b file.aac | od -t x8 --endian=big --address-radix=n | xargs echo -n`
    # convert to decimal
    DECIMAL=$((0x$HEXDUMP))
    # it is an MPEG-2 Timestamp in 1/90000 Seconds, get it in seconds
    AUDIOSTART=`expr $DECIMAL / 90000`