mp3lib

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package mp3lib provides utilities for working with MP3 files. It depends on the external tools 'mp3cut' and 'mp3length'.

mp3length provides the length of an MP3 file. Usage: mp3length mp3file Output Format: Length of mp3file: hh:mm:ss+ms

mp3cut is used to extract segments from an MP3 file. Usage: mp3cut [-o outputfile] [-T title] [-A artist] [-N album-name] [-t [hh:]mm:ss[+ms]-[hh:]mm:ss[+ms]] mp3 [-t ...] mp3 Parameters:

-o output: Output file, default mp3file.out.mp3
-T title: Set title metadata for the output mp3
-A artist: Set artist metadata for the output mp3
-N album-name: Set album name metadata for the output mp3
-t: Define the segment to extract in the format [hh:]mm:ss[+ms]-[hh:]mm:ss[+ms]

Package mp3lib provides tools to simulate slow writing processes, useful for testing timing issues with asynchronous IO operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyWithCancel

func CopyWithCancel(ctx context.Context, dst io.Writer, src io.Reader) (int64, error)

CopyWithCancel is similar to io.Copy but can be cancelled using the provided context.

func ExtractSectionToFile

func ExtractSectionToFile(mp3Path, outputPath string, startSec, endSec int) error

ExtractSectionToFile extracts a section of the MP3 file and saves it to a given path. It utilizes the mp3cut tool to extract the segment.

func ExtractSectionToWriter

func ExtractSectionToWriter(ctx context.Context, mp3Path string, w io.Writer, startSec, endSec int) error

ExtractSectionToWriter extracts a section of the MP3 file and writes it to the provided io.Writer.

It utilizes the mp3cut tool and a named FIFO pipe to communicate between the tool and the writer. This function blocks until the mp3cut process has finished and the FIFO has been read out in its entirety.

func GetLengthSeconds

func GetLengthSeconds(mp3Path string) (int, error)

GetLengthSeconds returns the length of the provided MP3 file in seconds. It utilizes the mp3length tool to obtain the length.

Returns:

Length of the MP3 file in seconds.
Error, if any (e.g., if mp3length tool encounters an issue).

Types

type SlowWriter

type SlowWriter struct {
	// contains filtered or unexported fields
}

SlowWriter wraps an io.Writer to simulate slower write speeds based on a specified duration per kilobyte. This can be useful for testing how systems handle slow IO situations.

func NewSlowWriter

func NewSlowWriter(w io.Writer, durationPerKilobyte time.Duration) *SlowWriter

NewSlowWriter creates a new SlowWriter instance that wraps the provided io.Writer. It uses the provided durationPerKilobyte to determine how long to sleep between writing chunks of data.

Parameters:

  • w: The underlying io.Writer to which the data will be written.
  • durationPerKilobyte: The time it takes to write each kilobyte of data.

func (*SlowWriter) Write

func (sw *SlowWriter) Write(p []byte) (int, error)

Write writes the provided byte slice to the underlying writer in chunks, and sleeps between chunks to simulate a slower writing process.

Jump to

Keyboard shortcuts

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