mpdgen

package module
v0.0.0-...-1dc8820 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2021 License: MIT Imports: 7 Imported by: 0

README

mpdgen

Utilities to generate MPEG DASH manifest files and segment files.

This pacakge contains utilities which call ffmpeg and MP4Box commands on Linux to generate DASH manifestfiles and audio/video segment files. The generated files can be used for streaming videos on demand.

The utitlities in this package are mainly for testing and experimenting purpose. Use with cautions in production environment.

Prerequisites

The utilies run on Linux OS and have been tested under Ubuntu16.04 and Ubuntu18.04. ffmpeg and MP4Box must be preinstalled. For ffmpeg please refer to its installation guide. For MP4Box, install with "apt-get install gpac" command.

Usage

Generate DASH manifest and setments using MPDGen().

package main

import (
    "flag"
    "log"
)

var (
    srcFile = flag.String("file", "", "The path to the soruce video.")
    destDir = flag.String("dest", "", "The directory where the manifest and segments are stored.")
    segment = flag.String("segment", "1000", "Dash segment value")
)

func main() {
    flag.Parse()

    if *srcFile == "" || *destDir == "" {
        log.Fatalf("The --file and --dest flags must be provided.")
    }
    MPDGen(*srcFile, *destDir, *segment)
}

To play the video in browser, you can use the dash.js libaray.

Documentation

Index

Constants

View Source
const (
	// FFMPEG is the location of ffmpeg binary on Linux/Ubuntu.
	FFMPEG = "/usr/local/bin/ffmpeg"

	// MP4BOX is the location of MP4Box binary on Linux/Ubuntu.
	MP4BOX = "/usr/bin/MP4Box"
)

Variables

This section is empty.

Functions

func ConcatenateVideos

func ConcatenateVideos(srcDir, destDir string) error

ConcatenateVideos concatenates multiple mp4 files into a single file.

func ConvertToMP4

func ConvertToMP4(videoSrcPath, videoDestDir string) error

ConvertToMP4 converts a non-mp4 video to a mp4 video.

func MP3ToMP4

func MP3ToMP4(mp3File, mp4File string) error

MP3ToMP4 converts a mp3 file to a mp4 file.

func MP3ToMP4Batch

func MP3ToMP4Batch(srcDir, destDir string) error

MP3ToMP4Batch converts mp3 files to mp4 format in batch.

func MPDGen

func MPDGen(videoSrcPath, videoDestDir, segment string) error

MPDGen runs MP4Box command to generate a Dash manifest file for the specified video at videoSrcPath. It also generates the audio and video segments needed by the manifest file.

MP4Box -dash 1000 -dash-profile live -segment-name video -out video.mpd output.mp4#video

func MPDGenMP3

func MPDGenMP3(videoSrcPath, videoDestDir, segment string) error

MPDGenMP3 generates Dash manifest file and audio segments for the specified video file (in mp4 foramt) at videoSrcPath.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL