Live Streaming

Your own live channel, no server needed

eMule Qt can broadcast live video to anyone on the ed3k network. There is no streaming server and no account: the viewers pass the stream on to each other, so every viewer helps the channel along. The broadcaster only has to feed the first few of them.

You need nothing but eMule Qt and an encoder that writes HLS. ffmpeg and OBS both do. Viewers watch in their web browser, or in VLC, mpv or any other player that opens a network stream.

The Live Streams tab of ed3k Sets: a channel being watched and played, and a private channel of your own on air

How it works

  • The encoder writes the stream into a folder as short pieces (segments) of one to four seconds, plus a playlist.
  • eMule Qt watches that folder. Each new segment is signed with the channel’s key and sent out on ed3k. Every block is checked by its hash, so nobody can slip something else into your channel.
  • Viewers fetch each segment from the broadcaster or from other viewers, and only keep the newest few.
  • Your player gets the stream from your own eMule Qt over a local address, http://live-<id>.localhost:<port>/. That address works only on your computer.

With two-second segments a viewer is about ten seconds behind the encoder.

Start a broadcast

  1. Make sure ed3k is switched on and connected.
  2. Make an empty folder for the stream, and start your encoder writing into it (see the examples below). The folder must be on the computer the eMule Qt core runs on. If the core runs on a NAS or in Docker, use the folder as the core sees it.
  3. Open the Kad window, the ed3k tab, and click ed3k Sets…. Go to the Live Streams tab.
  4. Click Broadcast… and fill in:
    • Title: what viewers see. Public channels are found by the words of their title, so pick words people will search for.
    • Folder: the folder your encoder writes to. eMule Qt takes the newest .m3u8 playlist in it.
    • Codecs: optional, for example avc1.64001f,mp4a.40.2. With it, a viewer whose player cannot play the stream is told so before joining.
    • Private: only people with the link can watch (see below).
  5. Click Broadcast. The channel goes on air and its ed3k:live?… link is copied to the clipboard. Copy Link copies it again later.

Stop ends the broadcast for everybody. If eMule Qt is closed or loses its connection instead, the viewers wait: when you are back within ten minutes, the channel goes on where it was cut off.

The same title always keeps the same channel and the same link, also after a restart. Delete Channel… drops a channel with its key, so its old link stops working for good.

What to send

Use
Output HLS with fMP4 segments (-hls_segment_type fmp4). MPEG-TS segments are not read.
Video H.264, up to High profile level 4.1 (1080p at 30 frames per second)
Audio AAC-LC or Opus
Segment length 1 to 4 seconds, each starting with a key frame: set the key frame interval to the segment length
Limits a segment over 4 MiB or init data over 256 KiB is skipped, so keep the bitrate sensible
Upload at least three times the stream’s bitrate: the broadcaster feeds three viewers or more, who pass it on

H.264 with AAC plays everywhere: in every browser, on phones and in common players, with nothing to install.

Examples with ffmpeg

Change into your stream folder first, so the playlist and the segments land there. All examples write 720p at 30 frames per second with a key frame every two seconds, which fits the codecs avc1.64001f,mp4a.40.2. On Windows, write each command on one line, or end the lines with ^ instead of \.

Try it with a test picture

A test pattern with a beep: the quickest way to check that everything works before you go on air.

cd ~/live/test
ffmpeg -re -f lavfi -i testsrc2=size=1280x720:rate=30 \
  -f lavfi -i sine=frequency=440:sample_rate=48000 \
  -c:v libx264 -preset veryfast -tune zerolatency -profile:v high -level 3.1 -pix_fmt yuv420p \
  -b:v 2500k -maxrate 2500k -bufsize 5000k -g 60 -keyint_min 60 -sc_threshold 0 \
  -c:a aac -b:a 128k -ar 48000 \
  -f hls -hls_time 2 -hls_list_size 6 -hls_flags delete_segments+independent_segments \
  -hls_segment_type fmp4 -hls_fmp4_init_filename init.mp4 live.m3u8

The last three lines are the HLS output and stay the same in every example below. -re makes ffmpeg go at real speed: without it, a test picture or a file is written as fast as the computer can.

Webcam and microphone

macOS (list your devices with ffmpeg -f avfoundation -list_devices true -i ""; "0:0" is the first camera and the first microphone):

ffmpeg -f avfoundation -framerate 30 -video_size 1280x720 -i "0:0" \
  -c:v libx264 -preset veryfast -tune zerolatency -profile:v high -level 3.1 -pix_fmt yuv420p \
  -b:v 2500k -maxrate 2500k -bufsize 5000k -g 60 -keyint_min 60 -sc_threshold 0 \
  -c:a aac -b:a 128k -ar 48000 \
  -f hls -hls_time 2 -hls_list_size 6 -hls_flags delete_segments+independent_segments \
  -hls_segment_type fmp4 -hls_fmp4_init_filename init.mp4 live.m3u8

Linux, with PulseAudio or PipeWire for the sound:

ffmpeg -f v4l2 -framerate 30 -video_size 1280x720 -i /dev/video0 -f pulse -i default \
  -c:v libx264 -preset veryfast -tune zerolatency -profile:v high -level 3.1 -pix_fmt yuv420p \
  ...

Windows (list your devices with ffmpeg -list_devices true -f dshow -i dummy and use their names):

ffmpeg -f dshow -video_size 1280x720 -framerate 30 -i video="Integrated Camera":audio="Microphone Array" ^
  -c:v libx264 -preset veryfast -tune zerolatency -profile:v high -level 3.1 -pix_fmt yuv420p ^
  ...

Your screen

Replace the input of the webcam example:

  • macOS: -f avfoundation -framerate 30 -capture_cursor 1 -i "1:0", where 1 is the screen in the device list. Add -vf scale=1280:720 for a screen larger than 720p.
  • Windows: -f gdigrab -framerate 30 -i desktop, with -vf scale=1280:720.
  • Linux (X11): -f x11grab -framerate 30 -video_size 1920x1080 -i :0.0, with -vf scale=1280:720. On Wayland, use OBS.

A video file, on a loop

ffmpeg -re -stream_loop -1 -i movie.mp4 \
  -c:v libx264 -preset veryfast -profile:v high -level 3.1 -pix_fmt yuv420p -vf scale=-2:720 \
  -b:v 2500k -maxrate 2500k -bufsize 5000k -g 60 -keyint_min 60 -sc_threshold 0 -r 30 \
  -c:a aac -b:a 128k -ar 48000 \
  -f hls -hls_time 2 -hls_list_size 6 -hls_flags delete_segments+independent_segments \
  -hls_segment_type fmp4 -hls_fmp4_init_filename init.mp4 live.m3u8

The file is encoded again on purpose: copying it with -c copy keeps its own key frames, and the segments would no longer start with one.

Let the graphics card encode

Instead of -c:v libx264 -preset veryfast -tune zerolatency, use -c:v h264_videotoolbox on a Mac, -c:v h264_nvenc with an NVIDIA card or -c:v h264_qsv with Intel graphics. Keep -g 60 and the bitrate options.

OBS

OBS writes the same output when it records. In Settings → Output, set Output Mode to Advanced. On the Recording tab, choose Type Custom Output (FFmpeg), Container Format hls, and the muxer settings hls_time=2 hls_list_size=6 hls_segment_type=fmp4 hls_flags=delete_segments. Pick an H.264 encoder with a key frame interval of 2 seconds and AAC audio, set the file path to your stream folder, then click Start Recording.

.:Key frames
Every segment must start with a key frame, or viewers who join get a broken picture until the next one. With ffmpeg, -g has to be the frame rate times -hls_time (30 × 2 = 60), and -sc_threshold 0 stops extra key frames at scene changes.

Private channels

Tick Private and the link carries a secret. The channel is not listed and cannot be found by search: only people who have the link can watch it, and the stream is encrypted for everyone else.

The link is the key. Whoever you give it to can pass it on, and a link that is out cannot be taken back. To shut people out, delete the channel and start a new one with a new link.

Watching a stream

By link

Click an ed3k:live?… link on a web page or in a chat, and eMule Qt opens it. Or copy the link and use Watch Link… in the Live Streams tab. eMule Qt joins the channel and opens it in your web browser.

By search

In the Search window, choose the method ed3k Channel (live) and enter words from the channel’s title. The results show the channels on air with their title, bitrate, format and language. Double-click one, or right-click it and choose Watch. Only public channels can be found this way.

The player

  • Your web browser opens by itself and plays the stream on a small player page. It reconnects by itself when the broadcaster restarts the stream.
  • VLC, mpv and other players play the same address. Copy it from the browser’s address bar and open it as a network stream, e.g. Media → Open Network Stream in VLC.
  • Open in the Live Streams tab opens a stream you are watching again. Stop leaves it.

The Live Streams tab shows each stream with its status, the peers you exchange it with, the segments and bytes received, and how many players are watching through your eMule Qt.

While you watch, your eMule Qt passes the stream on to other viewers: this is what makes a channel work without a server.

The stream is only served to the computer the core runs on. If your eMule Qt window is connected to a core on a NAS or another computer, the stream is listed but cannot be opened there.

 

Back to all features