Skip to content

Attempt to transcode and stream torrents downloaded with WebTorrent using FFmpeg

License

Notifications You must be signed in to change notification settings

leeroybrun/webtorrent-transcode

Repository files navigation

webtorrent-transcode

Attempt to transcode and stream torrents downloaded with WebTorrent using FFmpeg

How to use

So, how does it works?

  • On-the-fly transcoding with ffmpeg

    We check if the file needs transcoding, if not, we stream it directly from WebTorrent to the client. In this case, we accept byte-ranges requests to seek inside the media.

    If the file needs transcoding, we pass directly the stream from the WebTorrent file (file.createReadStream()) to fluent-ffmpeg. In this case, we disable byte-ranges requests as we need to seek by time-ranges directly with ffmpeg. Time-ranges are implemented by a ?time=SS URL parameter. To support time-ranges on the HTML5 player, we use a custom plugin for Video.js (TimeRangesSeeking).

    As the duration of the video is not known, we have a custom plugin for Video.js to handle querying it on the server (which use ffprobe). The duration is then set in Video.js.

  • Plugins for Video.js

    • Time-ranges seeking

      When we move the SeekBar of Video.js, we then send a request to the server with our new time-range. We then change the source on the player, and save the time offset (our new time range). When we display the progress, we use the time offset (where we have seeked) + currentTime of the player.

    • Media duration querying

      When transcoding, we don't know the duration of the video. We query the server with the ?metadata URL query to get if from ffprobe. We then force it on the player.

Todo

Resources

About

Attempt to transcode and stream torrents downloaded with WebTorrent using FFmpeg

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published