All Projects → jordicenzano → Go Ts Segmenter

jordicenzano / Go Ts Segmenter

Licence: gpl-3.0
Live TS segmenter and HLS manifest creation in Go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Go Ts Segmenter

Hls Trimming Frame Accuracy
JS Code that given a group of HLS chunks, a start timestamp, and end timestamp it creates one MP4 that contains the original V/A frame accuracy trimmed and perfectly aligned
Stars: ✭ 46 (+9.52%)
Mutual labels:  hls, chunk
Jmuxer
jMuxer - a simple javascript mp4 muxer that works in both browser and node environment.
Stars: ✭ 222 (+428.57%)
Mutual labels:  hls, chunk
transport-stream-online-segmenter
Transport stream web based HLS segmenter.
Stars: ✭ 30 (-28.57%)
Mutual labels:  hls, chunk
Streamline
A reference system for end to end live streaming video. Capture, encode, package, uplink, origin, CDN, and player.
Stars: ✭ 581 (+1283.33%)
Mutual labels:  hls
Clappr
🎬 An extensible media player for the web.
Stars: ✭ 5,436 (+12842.86%)
Mutual labels:  hls
Laravel Ffmpeg
This package provides an integration with FFmpeg for Laravel. Laravel's Filesystem handles the storage of the files.
Stars: ✭ 807 (+1821.43%)
Mutual labels:  hls
Futures Batch
An adapter for futures, which chunks up elements and flushes them after a timeout, or when the buffer is full. (Formerly known as tokio-batch.)
Stars: ✭ 37 (-11.9%)
Mutual labels:  chunk
Livego
live video streaming server in golang
Stars: ✭ 7,312 (+17309.52%)
Mutual labels:  hls
Video.js
Video.js - open source HTML5 & Flash video player
Stars: ✭ 32,478 (+77228.57%)
Mutual labels:  hls
Pipecnn
An OpenCL-based FPGA Accelerator for Convolutional Neural Networks
Stars: ✭ 775 (+1745.24%)
Mutual labels:  hls
Hlsjs P2p Engine
Let your viewers become your unlimitedly scalable CDN.
Stars: ✭ 759 (+1707.14%)
Mutual labels:  hls
Go Oryx
The go-oryx is SRS++, focus on real-time live streaming load-balancer.
Stars: ✭ 608 (+1347.62%)
Mutual labels:  hls
P2p Media Loader
An open-source engine for P2P streaming of live and on demand video directly in a web browser HTML page
Stars: ✭ 822 (+1857.14%)
Mutual labels:  hls
Janus Webrtc Gateway Docker
Perfect Docker Image for Media Streaming Expert User ( https://github.com/meetecho/janus-gateway )
Stars: ✭ 582 (+1285.71%)
Mutual labels:  hls
Ios P2p Engine
Let your viewers become your unlimitedly scalable CDN.
Stars: ✭ 31 (-26.19%)
Mutual labels:  hls
React Player
A React component for playing a variety of URLs, including file paths, YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia and DailyMotion
Stars: ✭ 5,931 (+14021.43%)
Mutual labels:  hls
Webpack Hashed Chunkids
a plugin to help webpack to generate unique chunk id based on unique module id
Stars: ✭ 15 (-64.29%)
Mutual labels:  chunk
Yedda
YEDDA: A Lightweight Collaborative Text Span Annotation Tool. Code for ACL 2018 Best Demo Paper Nomination.
Stars: ✭ 704 (+1576.19%)
Mutual labels:  chunk
Ffmpeg
Mirror of https://git.ffmpeg.org/ffmpeg.git
Stars: ✭ 27,382 (+65095.24%)
Mutual labels:  hls
M3u8
Parser and generator of M3U8-playlists for Apple HLS. Library for Go language. 🎦
Stars: ✭ 800 (+1804.76%)
Mutual labels:  hls

go-ts-segmenter

This tool enables you to segment (create HLS playable chunks) a live transport stream that is read from stdin or from a TCP socket. It also creates in real time the the HLS manifest (the chunklist). The output can be sent to files in local disk or pushed using HTTP to any webserver you have configured as a live streaming origin.

This segmenter also implements "periscope" LHLS mode. This low latency mode is used in any output type (local files and HTTP).

This code is not designed to be used in any production workflow, it has been created as a learning GoLang exercise.

Block diagram goes here

Usage

Installation

  1. Just install GO in your computer. See GoLang, instructions
  2. Clone this repo:
cd ~
go get github.com/jordicenzano/go-ts-segmenter
  1. Go the the source code dir `
cd go/src/github.com/jordicenzano/go-ts-segmenter
  1. Install the package dependencies:
go get
  1. Compile main.go doing:
make

Testing

You can execute bin/go-ts-segmenter -h to see all the possible command arguments.

Usage of ./bin/go-ts-segmenter:
  -apid int
        Audio PID to parse (default -1)
  -apids
        Enable auto PID detection, if true no need to pass vpid and apid (default true)
  -awsId string
        AWSId in case you do not want to use default machine credentials
  -awsSecret string
        AWSSecret in case you do not want to use default machine credentials
  -chunklistFilename string
        Chunklist filename (default "chunklist.m3u8")
  -chunksBaseFilename string
        Chunks base filename (default "chunk_")
  -dstPath string
        Output path (default "./results")
  -host string
        HTTP Host (default "localhost:9094")
  -httpMaxRetries int
        Max retries for HTTP service unavailable (default 40)
  -initType int
        Indicates where to put the init data PAT and PMT packets (0- No ini data, 1- Init segment, 2- At the beginning of each chunk (default 2)
  -initialHTTPRetryDelay int
        Initial retry delay in MS for chunk HTTP (no chunk transfer) uploads. Value = intent * initialHttpRetryDelay (default 5)
  -inputType int
        Where gets the input data (1-stdin, 2-TCP socket) (default 1)
  -insecure
        Skips CA verification for HTTPS out
  -lhls int
        If > 0 activates LHLS, and it indicates the number of advanced chunks to create
  -liveWindowSize int
        Live window size in chunks (default 3)
  -localPort int
        Local port to listen in case inputType = 2 (default 2002)
  -logsPath string
        Logs file path
  -manifestDestinationType int
        Indicates where the destination (0- No output, 1- File + flag indicator, 2- HTTP, 3- S3) (default 1)
  -manifestType int
        Manifest to generate (0- Vod, 1- Live event, 2- Live sliding window (default 2)
  -mediaDestinationType int
        Indicates where the destination (0- No output, 1- File + flag indicator, 2- HTTP chunked transfer, 3- HTTP regular, 4- S3 regular) (default 1)
  -protocol string
        HTTP Scheme (http, https) (default "http")
  -s3Bucket string
        S3 bucket to upload files, in case of sing an S3 destination
  -s3IsPublicRead
        Set ACL = "public-read" for all S3 uploads
  -s3Region string
        Specific aws region to use for AWS S3 destination
  -s3UploadTimeout int
        Timeout for any S3 upload in MS (default 10000)
  -targetDur float
        Target chunk duration in seconds (default 4)
  -verbose
        enable to get verbose logging
  -vpid int
        Video PID to parse (default -1)

Examples output to disc

  • Generate simple HLS from a test VOD TS file in ./results/vod:
cat ./fixture/testSmall.ts| bin/go-ts-segmenter -dstPath ./results/vod
  • Generate simple HLS from a test live stream in ./results/live (requires ffmpeg):
ffmpeg -f lavfi -re -i smptebars=duration=20:size=320x200:rate=30 -f lavfi -i sine=frequency=1000:duration=20:sample_rate=48000 -pix_fmt yuv420p -c:v libx264 -b:v 180k -g 60 -keyint_min 60 -profile:v baseline -preset veryfast -c:a aac -b:a 96k -f mpegts - | bin/go-ts-segmenter -dstPath ./results/live
  • Generate simple HLS from a test live stream with overlay data (frame number + date) in ./results/live (requires ffmpeg):
ffmpeg -f lavfi -re -i smptebars=duration=20:size=320x200:rate=30 -f lavfi -i sine=frequency=1000:duration=20:sample_rate=48000 -pix_fmt yuv420p -c:v libx264 -b:v 180k -g 60 -keyint_min 60 -profile:v baseline -preset veryfast -c:a aac -b:a 96k -vf "drawtext=fontfile=/Library/Fonts/Arial.ttf: text=\'Local time %{localtime\: %Y\/%m\/%d %H.%M.%S} (%{n})\': x=10: y=10: fontsize=16: fontcolor=white: box=1: boxcolor=0x00000099" -f mpegts - | bin/go-ts-segmenter -dstPath ./results/live-overlay

Note: The previous snippet only works on MAC OS, you should probably remove (or modify) the fontfile path if you use another OS.

  • Generate LHLS with 3 advanced chunks from a test live stream in ./results/live (requires ffmpeg):
ffmpeg -f lavfi -re -i smptebars=duration=6000:size=320x200:rate=30 -f lavfi -i sine=frequency=1000:duration=6000:sample_rate=48000 -pix_fmt yuv420p -c:v libx264 -b:v 180k -g 60 -keyint_min 60 -profile:v baseline -preset veryfast -c:a aac -b:a 96k -f mpegts - | bin/go-ts-segmenter -dstPath ./results/live-lhls -lhls 3

Note: To serve the LHLS data generated by this application you need to use webserver-chunked-growingfiles. The stream will play in any HLS compatible player, but if you really want t see ultra low latency you will need to use a player that takes advantage of chunked transfer.

Examples output to HTTP

  • Generate multirendition LHLS with 3 advanced chunks from a test live stream and broadcast that stream as a chunked transfer (requires ffmpeg and go-chunked-streaming-server).
  1. First start the go-chunked-streaming-server
./go-chunked-streaming-server
  1. Start the multirendition test source multi-rendition-pipe-to-http.sh:
cd scripts
./multi-rendition-pipe-to-http.sh
  1. Play the resulting stream (playback URL: http://localhost:9094/pipe-http/playlist.m3u8) with a player that supports LHLS, or you can also play it with any HLS player such Safari. In both cases you will see a latency reduction. In the case of an LHLS player you will probably see <1s latency, in regular HLS players you will see a latency similar to target duration.

Examples output to S3

  • In this example we will send ONLY the resulting media segments to S3.
  1. Start the following script single-rendition-media-tcp-to-s3.sh:
cd scripts
./single-rendition-media-tcp-to-s3.sh NAME-OF-DEST-BUCKET

Note: By default it will use the default AWS credentials of the current user

  1. You should find the media files in the following place in the specified bucket results/720p_00000.ts

Docker

Pulling image from docker hub

  1. Ensure you have docker installed
  2. Type: docker pull jcenzano/docker-go-ts-segmenter

Creating the docker image locally

  1. Ensure you have docker docker and make installed
  2. Type make build_docker

Testing the docker image

  1. You can test the image with this command (you should see the help):
docker run --rm -it jcenzano/docker-go-ts-segmenter
  1. To segment TS via TCP, using localhost port 2022 as input for TS
docker run -i -t --rm -p 2002:2002 -v ~/Movies/testTsSeg:/tmpdata jcenzano/docker-go-ts-segmenter:latest -inputType 2 -dstPath /tmpdata -chunksBaseFilename source_ -chunklistFilename source.m3u8

On another terminal you can send a test video to the previous docker:

ffmpeg -f lavfi -re -i smptebars=duration=20:size=320x200:rate=30 -f lavfi -i sine=frequency=1000:duration=20:sample_rate=48000 -pix_fmt yuv420p -c:v libx264 -b:v 180k -g 60 -keyint_min 60 -profile:v baseline -preset veryfast -c:a aac -b:a 96k -f mpegts "tcp://localhost:2002"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].