5 Live vpx transcoding plus packaging
Kongqun Yang edited this page 2017-08-23 11:20:21 -07:00

This example uses pipe to chain transcoding and packaging together. Another option is to use socket.

Assuming you have a live iptv stream available at 225.1.1.8:8001 at port 8001 with interface address 172.29.46.122.

Create Pipe

mkfifo pipe1

Transcoding Command

ffmpeg -i udp://225.1.1.8:8001?localaddr=172.29.46.122 -g 90 -speed 4 -threads 8 \
       -c:v libvpx -f webm pipe: > pipe1

Option -speed 4 tells the encoder to encode really fast, sacrificing quality. This is needed otherwise ffmpeg is not fast enough to keep up with the live stream.

Packaging Command

packager in=pipe1,stream=audio,init_segment=livehd-audio.webm,segment_template=livehd-audio-\$Number\$.webm \
         in=pipe1,stream=video,init_segment=livehd-video.webm,template=livehd-video-\$Number\$.webm \
  --mpd_output livehd.mpd  --dump_stream_info --min_buffer_time=10 \
  --time_shift_buffer_depth=300 --segment_duration=3 --io_block_size 65536

Option -io_block_size 65536 tells packager to use an io_block_size of 65K for threaded io file. This is necessary as reading from pipe blocks until the specified number of bytes, which is specified in io_block_size for threaded io file, thus the value of io_block_size cannot be too large.

This example can be easily extended to support more streams and add encryption.