0

Constrained by the need manually generate a series of 10-second MPEGTS media segments for HTTP Live Streaming (HLS), ffmpeg's mpegts seems to do what I need. This example would be for segment number 53 in the series:

ffmpeg \
  -v debug \
  -i seg-53.wav \
  -f mpegts \
  -af asetpts=%d 53 \
  -fflags genpts \
  -mpegts_flags initial_discontinuity \
  -mpegts_service_type digital_radio \
  -muxrate 128000 \
  seg-53.ts

What is PTS? I must admit that I don't fully understand it. This usage of the ffmpeg filter asetpts was based on the answer to this SO question FFmpeg make mpeg2 ts without discontinuity

FFmpeg encodes the .ts file successfully, but with these (debug-verbosity) messages that seem to be clues as to these files' shortcomings as a stream:

cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
Last message repeated 1 times
[mpegts @ 0x561e90d64740] Non-monotonous DTS in output stream 0:0; previous: 1693, current: 973; changing to 1694. This may result in incorrect timestamps in the output file.
[mpegts @ 0x561e90d64740] Non-monotonous DTS in output stream 0:0; previous: 1694, current: 1213; changing to 1695. This may result in incorrect timestamps in the output file.
[mpegts @ 0x561e90d64740] Non-monotonous DTS in output stream 0:0; previous: 1695, current: 1453; changing to 1696. This may result in incorrect timestamps in the output file.
[mpegts @ 0x561e90d64740] Non-monotonous DTS in output stream 0:0; previous: 1696, current: 1693; changing to 1697. This may result in incorrect timestamps in the output file.
[mpegts @ 0x561e90d64740] Non-monotonous DTS in output stream 0:0; previous: 1697, current: 973; changing to 1698. This may result in incorrect timestamps in the output file.
[mpegts @ 0x561e90d64740] dts < pcr, TS is invalid
Last message repeated 7 times

And when I play my stream in VLC it fails showing these errors in the log:

ts error: libdvbpsi error (PSI decoder): TS discontinuity (received 0, expected 12) for PID 17
ts error: libdvbpsi error (PSI decoder): TS discontinuity (received 0, expected 8) for PID 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.