Create mpegts hls segments for use with inputsream.adaptive

Is there a way to modify:

  1. « -hls_segment_type » from fmp4 to mpegts
  2. « -hls_segment_filename » to any filename with « %d »
  3. « -hls_flags single_file » remove

I try to create a addon for kodi with inputstream.adaptive ( GitHub - xbmc/inputstream.adaptive: kodi inputstream addon for several manifest types ) to view the hls streams with authentication… but this plugin is not able to stream audio for mp4/fragmented stuff.

(i try to modify ffmpeg-vod.js for the hls options, but this breaks other stuff in tslib.js / ffprobe-utils.js)

Breaking in what way? Errors would be helpful.

Maybe this helps a bit Allow for included streams in FragmentedSampleReader · Issue #343 · xbmc/inputstream.adaptive · GitHub

inputstream.adaptive cant play the included audio-stream from a mp4-fragmented container.

For a test i just created/transcoded the same videos like peertube does, the only change was « hls_segment_type mpegts » and it works great.

That’s completely different from there being errors in tslib.js/ffprobe-utils.js.

When you’re ready to post the errors you’re seeing I’d be happy to try troubleshooting this with you.

Here are the logs after changed -hls_segment_type in ffmpeg-vod.js and import a new video:

{"level":"info","message":"Handling WebTorrent transcoding job for 02aae006-f050-4442-bb87-d4c5520b4294.","label":"","tags":["transcoding","02aae006-f050-4442-bb87-d4c5520b4294"],"timestamp":"2023-03-22T17:09:49.036Z"}
{"level":"info","message":"Creating torrent /home/peertube/storage/torrents/1083bcef-b4ab-43dc-a4b3-5db5ab02ac13-1080-hls.torrent.","label":"","timestamp":"2023-03-22T17:09:55.941Z"}
[] 2023-03-22 18:09:55.941 info: Creating torrent /home/peertube/storage/torrents/1083bcef-b4ab-43dc-a4b3-5db5ab02ac13-1080-hls.torrent.
{"err":{"stack":"TypeError: Cannot read properties of undefined (reading 'High')\n    at /home/peertube/versions/peertube-v5.0.1/dist/server/helpers/ffmpeg/ffprobe-utils.js:43:56\n    at (<anonymous>)\n    at fulfilled (/home/peertube/versions/peertube-v5.0.1/node_modules/tslib/tslib.js:115:62)","message":"Cannot read properties of undefined (reading 'High')"},"level":"info","message":"Cannot update playlist after file change. Maybe due to concurrent transcoding","label":"","timestamp":"2023-03-22T17:09:56.112Z"}
[] 2023-03-22 18:09:56.112 info: Cannot update playlist after file change. Maybe due to concurrent transcoding {
  "err": {
    "stack": "TypeError: Cannot read properties of undefined (reading 'High')\n    at /home/peertube/versions/peertube-v5.0.1/dist/server/helpers/ffmpeg/ffprobe-utils.js:43:56\n    at (<anonymous>)\n    at fulfilled (/home/peertube/versions/peertube-v5.0.1/node_modules/tslib/tslib.js:115:62)",
    "message": "Cannot read properties of undefined (reading 'High')"
[] 2023-03-22 18:09:56.113 info: HLS transcoding job for 02aae006-f050-4442-bb87-d4c5520b4294 ended.

Please post the code changes you’ve made and I’ll try to troubleshoot this for you.

--- dist/server/helpers/ffmpeg/ffmpeg-vod.js	2023-03-23 13:03:44.159246560 +0100
+++ /tmp/ffmpeg-vod.js	2023-03-28 22:02:01.879328313 +0200
@@ -102,7 +102,7 @@
         .outputOption('-hls_list_size 0')
         .outputOption('-hls_playlist_type vod')
         .outputOption('-hls_segment_filename ' + outputPath)
-        .outputOption('-hls_segment_type fmp4')
+        .outputOption('-hls_segment_type mpegts')
         .outputOption('-f hls')
         .outputOption('-hls_flags single_file');

but i guess, best option for this will be a « nativ » switch in der peertube-frontend to use fmp4 or mpegts :slight_smile:

Works for me. No errors. I’m using the transcoding-profile-debug plugin.

The web player can’t play the videos though. VLC works when they’re downloaded.

transcoding-profile-debug with special flags? or just the plugin without using any encoder flags?

No special flags. I’m also using hls instead of webtorrent.