# Welcome to trace-shrink

`trace-shrink` is a python package that allows you to analyze captures of HTTP traffic, from HAR files, Proxyman logs, or Bodylogger files.
Its main focus is on providing a base to analyze recorded ABR streams (HLS and MPEG-DASH), in particular live streams in which the same URL to the manifest is GET-ed multiple times.

## Traces?

Archives, captures, logs, traces, etc. are all essentially variations of the same thing. They are all files that contain HTTP traffic.  In this tool, I use the term "trace" to refer to any of these files.

Currently, the tool supports the following trace file formats:

- .har (typically from Chrome DevTools)
- .proxymanlogv2 (generated by the excellent [Proxyman](https://proxyman.com/))
- .log (bodylogger format - read-only)

## Features

- Unified API regardless of the type of trace file
- Detect ABR manifest URLs from HAR files, Proxyman logs, or Bodylogger files
- Extract a stream of requests to a single ABR manifest URL
- Convert between formats (e.g., bodylogger to HAR)

## Installation

```bash
pip install trace-shrink
```

## Usage

See the [usage](usage.md) page for more details.

## Beyond trace-shrink

This package is limited to working with trace files, with a grasp of what requests within it are related to an ABR streaming session.

Having extracted the relevant requests, you can then use other tools to analyze the stream.
What tool you then use it up to you. Some recommendations (from my personal experience) are:

- [m3u8](https://github.com/globocom/m3u8) to parse and analyze HLS streams
- [mpd-inspector](https://github.com/wabiloo/mpd-inspector) to parse and analyze MPEG-DASH streams (yes, it's another of my projects)

Other tools that are built on top of trace-shrink:

- [abr-encore](https://github.com/wabiloo/abr-encore) creates a server for replaying the ABR stream contained in the trace file almost like it was when captured. It's a great way to test any client or manifest manipulator in a controlled environment.
