Example of using Pion WebRTC to play H264 + Ogg from disk

This repo demonstrates how you can use Pion WebRTC to play H264 and Ogg from disk. These same APIs can be used to pull from other sources.

You can use the follow command to create inputs

  • ffmpeg -i $INPUT_FILE -an -c:v libx264 -bsf:v h264_mp4toannexb -b:v 2M -max_delay 0 -bf 0 output.h264
  • ffmpeg -i $INPUT_FILE -c:a libopus -page_duration 20000 -vn output.ogg

Or pull from my website

Open play-from-disk-h264 example page

jsfiddle.net you should see two text-areas and a 'Start Session' button

Run play-from-disk-h264 with your browsers SessionDescription as stdin

The output.ogg and output.h264 you created should be in the same directory as play-from-disk-h264. In the jsfiddle the top textarea is your browser, copy that and:

Linux/macOS

Run echo $BROWSER_SDP | play-from-disk-h264

Windows

  1. Paste the SessionDescription into a file.
  2. Run play-from-disk-h264 < my_file

Input play-from-disk-h264's SessionDescription into your browser

Copy the text that play-from-disk-h264 just emitted and copy into second text area

Hit 'Start Session' in jsfiddle, enjoy your video!

A video should start playing in your browser above the input boxes. play-from-disk-h264 will exit when the file reaches the end

Congrats, you have used Pion WebRTC! Now start building something cool

Similar Resources

WebRTC media servers stress testing tool (currently only Janus)

 WebRTC media servers stress testing tool (currently only Janus)

GHODRAT WebRTC media servers stress testing tool (currently only Janus) Architecture Janus media-server under load Deployment ghodrat # update or crea

Nov 9, 2022

Go Webrtc Signaling Server

Go Webrtc Signaling Server This package is used to listen for Remote SDP (Sessio

Sep 7, 2022

Peerconnection_explainer - PeerConnection-Explainer parses WebRTC Offers/Answers then provides summaries and suggestions

PeerConnection Explainer PeerConnection Explainer decodes WebRTC... so you don't have too! PeerConnection Explainer parses WebRTC Offers/Answers then

Oct 31, 2022

Overlay networks based on WebRTC.

Overlay networks based on WebRTC.

weron Overlay networks based on WebRTC. ⚠️ weron has not yet been audited! While we try to make weron as secure as possible, it has not yet undergone

Jan 4, 2023

Simple-request-limiter - Example of limiting API requests using standard Go library

Route: http://localhost:8080/urls example of body in POST request that was used:

Feb 2, 2022

turn a directory into a GUI, slash example of VNC-based GUI

dirgui @rsnous on Jan 11, 2021: "idea: filesystem-GUI adapter, where a directory turns into a form, executable files inside that directory turn into

May 3, 2022

An example go service that is being tested by nonnative.

Nonnative Example An example go service that is being tested by nonnative. Structure The project follows the structure in golang-standards/project-lay

Oct 31, 2021

Example of how to write reverse proxy in Go that runs on Cloud Run with Tailscale

Cloudrun Tailscale Reverse Proxy Setup Create a ephemeral key in Tailscale Set TAILSCALE_AUTHKEY in your Cloud Run environment variables Set TARGET_UR

Dec 18, 2022

md wiki example with golang

Articles To run the service please download the repository and run docker build . -t "md-wiki:2019" docker run -ti -p 8080:8080 -p 9090:9090 md-wiki:2

May 12, 2022
Comments
  • Fix audio and video stream

    Fix audio and video stream

    I've implemented the fix we talked about on Slack. Audio and video transmit flawlessly now.

    Also, with the original FFmpeg command for creating H264 video, I had lag and desynchronization issues (video would fall behind the audio). I've created a new command with fixes those issues.

    I think we should also apply these fixes to the official examples in the pion/webrtc repo that use IVF, since they have the same issue. If you like, I can make a PR for that as well.

    Also maybe the play-from-disk-h264 can be added to the official examples?

    Only thing that remains is that the video stream takes a few seconds of loading to start. In my code, I fixed that by using code I found in one of pion/webrtc's issues which merges SPS and PPS packets:

    // ** Fixes to make video start streaming instantly **
    // 1. Prepend NAL start prefix code
    nal.Data = append([]byte{0x00, 0x00, 0x00, 0x01}, nal.Data...)
    // 2. Merge SPS and PPS packets
    if nal.UnitType == h264reader.NalUnitTypeSPS || nal.UnitType == h264reader.NalUnitTypePPS {
        spsAndPpsCache = append(spsAndPpsCache, nal.Data...)
        continue
    } else if nal.UnitType == h264reader.NalUnitTypeCodedSliceIdr {
        nal.Data = append(spsAndPpsCache, nal.Data...)
        spsAndPpsCache = []byte{}
    }
    

    However, I was unsure if this should be added to this example, because this looks like a separate fix to the H264 packetizer.

A yet to be voice call application in terminal. with the power of go and webRTC (pion).

Kenny I'm just trying to make a cli operated voice call chat application using go with help of webRTC and PortAudio. It might stay a Work In Progress

Dec 2, 2022
This project is the eloboration of pion/webrtc.

This project is the eloboration of pion/webrtc. The idea is to make the (pion/webrtc) sfu-ws example be able to handle multiple rooms

Nov 29, 2021
A simple WebRTC Signaling server for flutter-webrtc and html5
A simple WebRTC Signaling server for flutter-webrtc and html5

flutter-webrtc-server A simple WebRTC Signaling server for flutter-webrtc and html5. Online Demo: https://demo.cloudwebrtc.com:8086/ Features Support

Dec 13, 2021
A toy MMO example built using Ebiten and WebRTC DataChannels (UDP)
A toy MMO example built using Ebiten and WebRTC DataChannels (UDP)

Ebiten WebRTC Toy MMO ⚠️ This is a piece of incomplete hobby work and not robust. Please read the "Why does this project exist?" section. What is this

Aug 28, 2022
Playing with go, gobot & pion
Playing with go, gobot & pion

Tello-WebRTC-FPV Lately there were a couple of articles about pion and it looked very cool, but I didn't know what I could do with it. I then remember

Nov 21, 2022
Ananas is an experimental project for kubernetes CSI (Container Storage Interface) by using azure disk. Likewise, Ananas is the name of my cute british shorthair.

ananas Ananas is an experimental project for kubernetes CSI (Container Storage Interface) by using azure disk. Likewise, Ananas is the name of my cute

Aug 4, 2021
Pure Go implementation of the WebRTC API
Pure Go implementation of the WebRTC API

Pion WebRTC A pure Go implementation of the WebRTC API New Release Pion WebRTC v3.0.0 has been released! See the release notes to learn about new feat

Jan 1, 2023
Pure Go implementation of the WebRTC API
Pure Go implementation of the WebRTC API

Pure Go implementation of the WebRTC API

Jan 8, 2023
gRPC over WebRTC

gRPC over WebRTC Just a proof of concept, please be kind. How to Start all the things Client, create-react-app + grpc-web signaling + webrtc extension

Dec 16, 2022
Scalable WebRTC Signaling Server with ayame-like protocol.

ayu ayu is WebRTC Signaling Server with ayame-like protocol. Scalable: ayu uses Redis to store room states, so it can be used on serverless platforms

Nov 11, 2022