Giter Club home page Giter Club logo

goffmpeg's Introduction

Hi there 👋

I'm a passionate Software Engineer and Architect with 8 years of hands-on experience in crafting innovative software solutions. Throughout my journey, I've been deeply involved in both developing and designing robust, scalable software applications that solve real-world problems.

💻 My technical landscape includes an array of technologies and languages, but I thrive in environments that challenge me to learn and grow. My curiosity drives me to explore new technologies and methodologies, always with the goal of enhancing the efficiency and effectiveness of my projects.

🕵️ When I'm not coding, I love diving into the latest tech trends, contributing to open source projects, and sharing my knowledge with the community. I believe in the power of collaboration and am always open to connect with fellow tech enthusiasts.

🚀 Whether it's brainstorming innovative ideas, tackling complex challenges, or just geeking out over the latest tech gadget, I'm all in. If you're passionate about technology and love solving puzzles, let's connect and create something amazing together!

Feel free to reach out or follow my work here on GitHub. Happy coding!


Personal Website

goffmpeg's People

Contributors

agxp avatar arcayr avatar basriciftci avatar deloz avatar farshidtz avatar ggymm avatar manscrober avatar mie00 avatar muhammadharis avatar nks avatar r3b-fish avatar recurser avatar rohitggarg avatar tarrencev avatar timotto avatar vivienbcr avatar xfrr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goffmpeg's Issues

Readme example doesn't work

I'm new to ffmpeg but I get an error running the example in the readme. I created the input file, but it errors with:

src/converter/main.go:16:2: err declared but not used

After using err in an control flow check I get this printed out in my terminal:

❯ go run src/converter/main.go
panic: error executing ([-i test.mov -print_format json -show_format -show_streams -show_error]) | error: exit status 1 | message: {
    "error": {
        "code": -2,
        "string": "No such file or directory"
    }
}
 ffprobe version 4.2.2 Copyright (c) 2007-2019 the FFmpeg developers
  built with Apple clang version 11.0.3 (clang-1103.0.32.59)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_4 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags=-fno-stack-check --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
test.mov: No such file or directory


goroutine 1 [running]:
main.convert()
        /Users/kennetpostigo/Projects/specter/go/specter-api/src/converter/main.go:21 +0x335
main.main()
        /Users/kennetpostigo/Projects/specter/go/specter-api/src/converter/main.go:13 +0x20
exit status 2

From this:

package main

import (
  "fmt"

  "github.com/xfrr/goffmpeg/transcoder"
)

var inputPath = "test.mov"
var outputPath = "test.mp4"

func main() {
  convert()
}

func convert() {
  trans := new(transcoder.Transcoder)

  err := trans.Initialize(inputPath, outputPath)
  if err != nil {
    panic(err)
  }

  done := trans.Run(true)

  progress := trans.Output()
  for msg := range progress {
    fmt.Println(msg)
  }

  if err = <-done; err != nil {
    panic(err)
  }
}

Do you know what I may be doing wrong here?

SetQuality missing

The README lists SetQuality as a Mediasetter however I get undefined error when trying to use it and recursive grep can't find it in the repository.

Scaling?

Is there a way to do scaling as described here using this lib?

(*Mediafile).ObtainMovFlags redeclared in this block

You have duplicated the method ObtainMovFlags.

Fran, parece que te ha ocurrido lo mismo con SetMovFlags.
Creo que somos unos cuantos que estamos usando tu proyecto, y este tipo de cambios nos impiden compilar.
Te recomendaría que hicieras los siguientes cambios en el proyecto:

  • Desarrolla tus cambios en otra rama, no master.
  • Más pruebas unitarias
  • Si las pruebas unitarias no pasan, no hagas merge a master.
  • Intenta implementar el proyecto con modules y versiona los cambios.

Gracias

FFmpeg code to Go

ffmpeg -re -i "https//........../playlist.m3u8" -codec copy -map 0 -f segment -segment_list playlist.m3u8 -segment_list_flags +live -segment_time 10 out%03d.ts

How to convert?

Stopping the transcoder?

Can we make a public method to stop the transcoder? For example, if I am saving an HLS stream to file, I probably want to stop it gracefully before the event ends.

Transcoder.Output() doesn't output progress

Hi 👋

I'm trying to write a small utility that resizes video files while reporting the progress of the transcoding, so using your package I wrote this snippet that works (i.e. the file transcoding works), but no output is streamed from channel returned by the Transcoder.Output() method:

package main

import (
	"fmt"

	"github.com/xfrr/goffmpeg/transcoder"
)

var inputPath = "test.mkv"
var outputPath = "test.res.mkv"

func main() {
	trans := new(transcoder.Transcoder)

	err := trans.Initialize(inputPath, outputPath)
	if err != nil {
		panic(err)
	}
	trans.MediaFile().SetAudioCodec("copy")
	trans.MediaFile().SetVideoCodec("libx264")
	trans.MediaFile().SetVideoFilter("scale=854:480")
	trans.MediaFile().SetCRF(18)
	trans.MediaFile().SetPreset("veryslow")

	done := trans.Run(true)
	for msg := range trans.Output() {
		fmt.Println(msg) // <- Nothing printed out here
	}

	if err = <-done; err != nil {
		panic(err)
	}
}

I did a bit of digging, and it seems that bufio.Scanner() gets stuck here (no iteration in the loop).

I'm running ffmpeg 4.2.2 on macOS and Go 1.14.0, let me know if you need more information.

goffmpeg type inference/autocomplete

Recently started using the library and for some reason the type inference on this library doesn't seem to work:
image

Autocomplete for methods don't work or hint at possible options. Idk why it happens but for all other libraries I use it seems to work just fine.

Create Thumbnail

Is there a way to also create a thumbnail? That would be awesome

SetMovFlags declared twice in models/media.go?

In models/media.go, there appears to be two declarations of SetMovFlags: once on line 260, and again on 352.

Looks like this is a very recent commit to master, so perhaps you are in the midst of things....

Pass my own parameters

Hello!
I don't found any way to pass my own parameters to converter.
Can I pass my own convert string and use lib as output parser?

Thank you!

Not working in windows

bin/sh command causing file is invalid having error.. is there any other option to run it in windows operating system

Improve HLS support

Right now wrapper can create only one HLS stream.
e.g. this command will able create 2 formats in one run:

ffmpeg -y -i sintel_trailer-1080p.mp4 \
  -preset slow -g 48 -sc_threshold 0 \
  -map 0:0 -map 0:1
  -s:v:0 640x360 -c:v:0 libx264 -b:v:0 2000k \
  -s:v:1 960x540 -c:v:1 libx264 -b:v:1 365k \
  -c:a copy -var_stream_map "v:0,a:0 v:1,a:1" -master_pl_name master.m3u8 -f hls
  -hls_time 6 -hls_list_size 0 \
  -hls_segment_filename "v%v/fileSequence%d.ts" v%v/prog_index.m3u8

So, suggestion to have "addFormat" method with params such Media model and based on the sequence add params to the command.

Example in php:

$lowBitrate = (new X264)->setKiloBitrate(250);
$midBitrate = (new X264)->setKiloBitrate(500);
$highBitrate = (new X264)->setKiloBitrate(1000);

FFMpeg::fromDisk('videos')
    ->open('steve_howe.mp4')
    ->exportForHLS()
    ->setSegmentLength(10) // optional
    ->addFormat($lowBitrate)
    ->addFormat($midBitrate)
    ->addFormat($highBitrate)
    ->save('adaptive_steve.m3u8');

Getting Failed Finish

Failed Finish FFMPEG

If I copy/paste the command it works just fine no problem. No idea why this is failing.

find ffprope error at windows

I find the new edition had changed the code in ffmpeg/ffmpeg.go.
"ffprobe := strings.Replace(strings.Split(outProbe.String(), "\n")[0], utils.LineSeparator(), "", -1)"
this change make my item appear an error.
the ffprope become "E:\ffmpeg\bin\ffprope.exe\r".

make audio bitrate an integer similar to video bitrate

Was wondering if it would be possible to make audio bitrate an integer, makes more sense and follows the convention of video bitrate being an integer.

In theory, it would be a good idea if they were both uint32, considering bitrates don't dip below 0.

MP4 to HLS

Can you give an example to convert mp4 to hls 360p, 480p, 720p and 1080p?

Proposal: Please start using Semantic Versioning

I found that this project already supports Go modules. But sadly, the tags doesn't follow Semantic Versioning, which means that all tags of this project will be ignored by Go modules and replaced by pseudo-versions, go get acts weirdly when tags are not in that form. It would be great to have the tagged release be named in the format vX.X.X format so that go mod can read it.

	github.com/xfrr/goffmpeg v0.0.0-20200730134436-d910add31983

Else the mod file shows something like github.com/xfrr/goffmpeg v0.0.0-20200730134436-d910add31983 which is not very readable and difficult to upgrade. It’s hard to verify which version is in use. This is not conducive to version control.

So, I propose this project to follow Semantic Versioning in future versions. For example, v1.0.1, v2.0.0, v3.1.0-alpha, v3.1.0-beta.2etc.

Trying to convert MP4 to HLS

Hi 👋,

So I was able to get goffmpeg to convert a .mov -> mp4. Based of the example from the readme. I did a bit of digging into old issues and current ones to try to piece together how to convert the .mp4 I got into HLS.

Here's what I got:

❯ go run src/converter/main.go
panic: Failed Finish FFMPEG ([-nostats -loglevel 0 -y -i data/test.mp4 -c:v copy -hls_list_size 10 -hls_time 10 -hls_key_info_file  data/test.m3u8]) with exit status 1 message  

goroutine 1 [running]:
main.convert()
        /src/converter/main.go:32 +0x1c8
main.main()
        /src/converter/main.go:11 +0x20
exit status 2

From my go code:

package main

import (
  "github.com/xfrr/goffmpeg/transcoder"
)

var inputPath = "data/test.mp4"
var outputPath = "data/test.m3u8"

func main() {
  convert()
}

func convert() {
  trans := new(transcoder.Transcoder)

  err := trans.Initialize(inputPath, outputPath)
  if err != nil {
    panic(err)
  }

  // Copy video streams
  trans.MediaFile().SetVideoCodec("copy")
  // Set hls list size
  trans.MediaFile().SetHlsListSize(0)
  // Set HLS time
  trans.MediaFile().SetHlsSegmentDuration(10)

  done := trans.Run(false)

  if err = <-done; err != nil {
    panic(err)
  }
}

Any chance you know what I may be doing wrong here?

(*Mediafile).SetMovFlags redeclared in this block

GOROOT=D:\Go #gosetup
GOPATH=C:\Users\shahi\go #gosetup
D:\Go\bin\go.exe get -t -v github.com/xfrr/goffmpeg/transcoder/... #gosetup
github.com/xfrr/goffmpeg (download)
github.com/xfrr/goffmpeg/models

github.com/xfrr/goffmpeg/models

C:\Users\shahi\go\src\github.com\xfrr\goffmpeg\models\media.go:352:21: (*Mediafile).SetMovFlags redeclared in this block
previous declaration at C:\Users\shahi\go\src\github.com\xfrr\goffmpeg\models\media.go:260:6
C:\Users\shahi\go\src\github.com\xfrr\goffmpeg\models\media.go:1166:21: (*Mediafile).ObtainMovFlags redeclared in this block
previous declaration at C:\Users\shahi\go\src\github.com\xfrr\goffmpeg\models\media.go:776:6

help me

can support user define ffmpeg but not get from path

can support user define ffmpeg but not get from path.

func (t *Transcoder) Initialize(inputPath string, outputPath string) error {
	var err error

	configuration := t.configuration
	if len(configuration.FfmpegBin) == 0 || len(configuration.FfprobeBin) == 0 {
		configuration, err = ffmpeg.Configure()
		if err != nil {
			fmt.Println(err)
			return err
		}
	}
}

Getting path for file crashes when that file appears multiple times in PATH.

I tried this on Windows 10 and get this result:


C:\ProgramData\chocolatey\bin\ffprobe.exe
C:\ProgramData\chocolatey\lib\ffmpeg\tools\ffmpeg\bin\ffprobe.exe

panic: error executing ([-i D:\Users\Gert\Videos\Don Syme - Keynote - F# Code I Love _ Lambda Days 2019-MGLxyyTF3OM.mp4 -print_format json -show_format -show_streams -show_error]) | error: exec: "C:\\ProgramData\\chocolatey\\bin\\ffprobe.exeC:\\ProgramData\\chocolatey\\lib\\ffmpeg\\tools\\ffmpeg\\bin\\ffprobe.exe": file does not exist

Changing the configuration function could help:

ffmpeg := strings.Replace(strings.Split(outFFmpeg.String(), "\n")[0], utils.LineSeparator(), "", -1)
fprobe := strings.Replace(strings.Split(outProbe.String(), "\n")[0], utils.LineSeparator(), "", -1)

But I can't test on Linux or Mac right now.

Option to get resolution of file without transcoding

First, thanks for this library as it's incredibly useful and it was very hard to find simple libraries to wrap around ffmpeg for easy video encoding.

One of the features I need is to be able to know the resolution of a file and make decisions based on that, but I couldn't get it working. (Maybe just using ffprobe)

Is this something you could add? I'm not clear on how to implement it without using Transcoder.Initialize (but that gives me a fault if I don't finish the encode).

Thanks

How to set FourCC/Tag

Hi, thank you for this awesome, up to date binding. How can I add a vtag to the transcoder?
The cli option would be -vtag xvid for example.
Thanks!

How do I set `-tag:v hvc1` for QuickTime-compatible HEVC (H.265) encoding?

Hi, I'm following the steps at https://brandur.org/fragments/ffmpeg-h265 to allow ffmpeg-converted H.265 videos to be playable on QuickTime. However, I'm still unsure on how to set that properly using this library.

In a batch processing Go script, I decided to use the following examples to convert H.264 videos to H.265.

trans.MediaFile().SetPreset("fast")
trans.MediaFile().SetVideoCodec("libx265")
trans.MediaFile().SetVideoProfile("main")
trans.MediaFile().SetTags(map[string]string{"p": "hvc1"})
trans.MediaFile().SetFrameRate(VIDEO_FRAME_RATE)
trans.MediaFile().SetAudioCodec("aac")
trans.MediaFile().SetAudioRate(AUDIO_SAMPLING_RATE)

In this case, the tag is still not applied properly.

I've also replaced trans.MediaFile().SetTags(map[string]string{"p": "hvc1"}) with others, including:

  • trans.MediaFile().SetTags(map[string]string{"hvc1": ""}) (same behavior)
  • trans.MediaFile().SetRawOutputArgs([]string{"-tag:v hvc1"})
    • Error: failed finish ffmpeg ([-y -i videos/orig/58.mp4 -r 30 -ar 44100 -c:v libx265 -profile:v main -c:a aac -preset fast -tag:v hvc1 -hls_list_size 0 videos/h265-aac-mp4/58.mp4]) with exit status 1 message
    • However, running ffmpeg -y -i videos/orig/58.mp4 -r 30 -ar 44100 -c:v libx265 -profile:v main -c:a aac -preset fast -tag:v hvc1 -hls_list_size 0 videos/h265-aac-mp4/58.mp4 manually works and produces the QuickTime-playable HEVC video.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.