Find ffmpeg parameters to reencode mpegts (HLS) with drawtext filter

Job ID: 33979126

Budget: $30 – $250 USD

We have an m3u8 file with mpegts binary files which include a simple video stream with audio. We must reenconde one single TS file (in the middle of the stream, not the first one) with a drawtext filter adding a text in the stream. The newly generated mpegts file must have the same sequence and continuity counter field (mpegts) set so the stream is still valid.

We must NOT add EXT-X-DISCONTINUITY in the m3u8 file because it would cause audio breaks.

Current ffmpeg command (broken):

> ffmpeg -y -i ./video1.ts -vf "drawtext=fontfile=./font.ttf: text='Test': fontcolor=black: fontsize=15: x=50: y=50" -c:v libx264 -c:a copy -profile:v main -q:v 0 -q:a 0 ./video1_new.ts

This can be tested even with copy command (no drawtext filter) (also broken):

> ffmpeg -y -i ./video1.ts -c:v copy -c:a copy -q:v 0 -q:a 0 -merge_pmt_versions ./video1_new.ts

**How do we know it's broken or how to validate the output TS?**

Simply download the HLS checker tool (http://www.tslemurs.com/ott/hls_checker_tool.html) and load the m3u8 file, make sure all segments (ts) are green.

**What needs to be done?**

We need the correct set of ffmpeg commands to do this and have it being valid in the HLS check tool.

More info:

* https://stackoverflow.com/questions/35974281/mpeg2-ts-sync-byte-and-continuity-error
* http://underpop.online.fr/f/ffmpeg/help/mpegts-1.htm.gz
Related categories: C Programming C++ Programming