{"id":15086025,"url":"https://github.com/elizabevil/ffmpegx","last_synced_at":"2026-02-07T05:32:57.200Z","repository":{"id":248244244,"uuid":"828156467","full_name":"elizabevil/ffmpegx","owner":"elizabevil","description":"a lib with go control ffmpeg bin","archived":false,"fork":false,"pushed_at":"2025-04-17T07:28:41.000Z","size":923,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-28T19:47:28.498Z","etag":null,"topics":["ffmpeg","ffmpeg-command","go","golang-library"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elizabevil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-13T09:34:53.000Z","updated_at":"2025-06-18T13:33:21.000Z","dependencies_parsed_at":"2024-07-13T11:48:38.854Z","dependency_job_id":"0bdc29e4-03de-4867-b8c4-ce0a7ffafe98","html_url":"https://github.com/elizabevil/ffmpegx","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"d950b697b458dbba2460fec7a393378d9f597406"},"previous_names":["elizabevil/ffmpex"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/elizabevil/ffmpegx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elizabevil%2Fffmpegx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elizabevil%2Fffmpegx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elizabevil%2Fffmpegx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elizabevil%2Fffmpegx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elizabevil","download_url":"https://codeload.github.com/elizabevil/ffmpegx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elizabevil%2Fffmpegx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29187219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T05:07:31.176Z","status":"ssl_error","status_checked_at":"2026-02-07T05:06:15.227Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ffmpeg","ffmpeg-command","go","golang-library"],"created_at":"2024-09-25T07:03:10.561Z","updated_at":"2026-02-07T05:32:57.187Z","avatar_url":"https://github.com/elizabevil.png","language":"Go","readme":"# # FFmpex\r\n\r\n\u003e ###### go control ffmpeg program\r\n\r\nEncapsulates commonly used methods and parameters\r\n\r\n\u003e All From =\u003eFFmpegDoc https://www.ffmpeg.org/documentation.html\r\n\r\n---\r\n\r\n### Usage notes\r\n\r\n\u003e go get github.com/elizabevil/ffmpegx@version\r\n\r\n- args\r\n\r\n```go\r\n//ffmpeg [global_options] {[input_file_options] -i input_url} ... {[output_file_options] output_url} ...\r\n\r\n```\r\n\r\n- Make args\r\n\r\n```go\r\n//make cmd args\r\n//https://www.ffmpeg.org/documentation.html\r\n//ffmpeg [global_options] {[input_file_options] -i input_url} ... {[output_file_options] output_url} ...\r\n\r\n\r\nhls := muxerx.HLS{\r\nHlsInitTime:        1,\r\nHlsTime:            10,\r\nHlsDeleteThreshold: 2,\r\nHlsListSize:        \u0026typex.ZeroUN, //default 5 --\u003e force 0\r\nHlsSegmentFilename: \"%Y%m%d%H%M%S.ts\",\r\n}\r\nfmt.Println(hls.Args())// show args\r\nfmt.Println(parsex.DefaultParser.ParamParse(hls))// or this\r\n\r\n//[-hls_segment_filename %Y%m%d%H%M%S.ts -hls_delete_threshold 2 -hls_list_size 0 -hls_time 10 -hls_init_time 1]\r\n\r\n\r\nparam := paramx.Param{}\r\nparam.GlobalHandle(func(input *optionx.Global) {\r\ninput.Overwrite = true\r\n}).InputHandle(func(input *optionx.Input) {\r\ninput.Inputs = []string{InputVedio}\r\n}).OutputHandle(func(output *optionx.Output) {\r\noutput.Outputs = []string{OutputVideo}\r\n}).CommonHandle(paramx.PositionInput, optionx.Common{\r\nAn: true,\r\n}).CommonHandle(paramx.PositionOutput, optionx.Common{\r\nF: \"hls\",\r\nCodecSpecifier: []typex.StreamSpecifier{\r\n{\"v\", \"h264x\"},\r\n},\r\n}).CommonHandle(paramx.PositionOutput, optionx.Common{ //overwrite\r\nF: \"flv\",\r\nT: 4,\r\n})\r\nfmt.Println(param.Args())\r\n//[-y -an -i ./file/input.mp4 -t 4 -f flv ./file/output.mp4]\r\n\r\n//===============\r\ninput := optionx.Input{Input: InputVedio}\r\nargs := paramx.AnyArgs{\"-c\": \"copy\"}\r\noutput := optionx.Output{Output: OutputVideoHls}\r\n?? := impl interfacex.IArg\r\nargInterface := paramx.BuildIArgInterface(input, args, ??, output) // Concat args\r\nfmt.Println(argInterface.Args())\r\n//[-i ./file/input.mp4 -c copy ?? output.mp4]\r\n\r\n```\r\n\r\n- YourParse Args\r\n\r\n```go\r\n// you can impl Arg interface\r\ntype Arg interface {\r\n    Args() typex.Args\r\n}\r\n\r\ntype YourParse struct {// your paesr method\r\n}\r\n\r\nfunc (y YourParse) ParamParse(input any) typex.Args {\r\n\treturn []string{\"-c\", \"copy\"}\r\n}\r\n\r\nfunc (y YourParse) ParamItemType(of reflect.Value) (string, bool) {\r\n\treturn \"c\", false\r\n}\r\n//================\r\ntype YourHls muxerx.HLS // your type\r\nfunc (r YourHls) Args() typex.Args {\r\n\treturn YourParse{}.ParamParse(r)\r\n}\r\nfmt.Println(YourHls{}.Args()) //see args\r\n//paramx.BuildIArgInterface(input, args, hls, output)\r\nparamx.BuildIArgInterface(input, args, YourHls{}, output) // complete args\r\n```\r\n\r\n- Run\r\n\r\n```go\r\n//==or== \r\ntranscoderx.Cmd(bin string, args interfacex.IArg)   //*exec.Cmd \r\n\r\n// makeTranscoder\r\ntranscode := transcoderx.NewTranscoder(transcoderx.NewConfig())// with default config\r\ntranscode.Args = makeParams() // set ffmpeg/ffplay args\r\ntranscode.Cmd()   //*exec.Cmd \r\n\r\n```\r\n\r\n- Get Metadata\r\n\r\n```go\r\nmetadata, err := transcoderx.Metadata(ffprobeBinPath, InputVedio) // use ffprobeBin to get InputVedio's Metadata \r\nfmt.Println(metadata.Format)  // println Format\r\nfmt.Println(metadata.Streams) // println Streams\r\n\r\ntranscoderx.Metadata()\t//default\r\ntranscoderx.MetadataWithArgs() // with args\r\n//args\r\ngeneric := optionx.Generic{HideBanner: true}\r\nfprobe := optionx.FFprobe{\r\n    I:                InputVedio,\r\n    PrintFormat:      optionx.OutputFormat_json,\r\n    ShowError:        true,\r\n    ShowFormat:       true,\r\n    ShowStreams:      true,\r\n}\r\ntranscoderx.Debug = true\r\nmetadata, err := transcoderx.MetadataWithArgs(FfprobeBin, paramx.BuildIArgInterface(generic, fprobe), transcoderx.JsonUnmarshal, func(out []byte, err []byte) {\r\n    //bytes\r\n\t})\r\n\r\nif err != nil {\r\n    fmt.Println(\"MetadataX\", err)\r\n    return\r\n}\r\nfmt.Println(metadata.Format)\r\nfmt.Println(metadata.Streams) // println Streams\r\n//OutputFormat_json: JsonUnmarshal{}\r\n//OutputFormat_xml : XmlUnmarshal{}\r\n\r\n```\r\n\r\n- Audio Channel_layout\r\n\r\n```go\r\nstreams := metadata.StreamWithType(AVMEDIA_TYPE_AUDIO) // if this stream `s codec_type is audio\r\nlayout := streams[0].GetChannelLayout() //{stereo {1 2 3}}\r\nfmt.Println(metadatax.ChannelNames[layout.Layout.Mask]) //{LFE low frequency}\r\n```\r\n\r\n- Use Pipeline Run\r\n\r\n```go\r\n\r\ntranscoderx.Debug = true // show args\r\nduration := 1000 * time.Millisecond  \r\nkillDuration := duration * 100\r\n\r\nbackground, cc := context.WithTimeout(context.Background(), duration) // ctx\r\ndefer cc()\r\n\r\n//Ph:= impl interfacex.ProgressHandle // set your self method to parse progress\r\nrunFunc, err := transcoderx.Pipeline(FfmpegBin, Ph, makeParamsToHls(), func(cmd *exec.Cmd) {\r\n    cmd.Dir = \"/tmp\"\r\n})\r\nif err != nil {\r\n    return\r\n}\r\nerr = runFunc(background, func(process *os.Process) {\r\n    go func() {\r\n        time.Sleep(killDuration) // after killDuration \r\n        process.Kill()\r\n    }()\r\n}, func(progress metadatax.Progress) {\r\n    //progress:: {1 0.0 -1.0 N/A 00:00:00.03 N/A  N/A      }\r\n\t//progress:: {16 0.0 -1.0 N/A 00:00:00.53 N/A  1.06x      }\r\n    fmt.Println(\"progress::\", progress)\r\n})\r\n\r\n```\r\n\r\n- some types fun\r\n\r\n```go\r\nfmt.Println(typex.TimeZero) //0000-01-01 00:00:00 +0000 UTC\r\nduration := 3*time.Second + 500*time.Millisecond //3.5s\r\nfmt.Println(typex.TimeDuration(duration, time.Millisecond)) //3500 Millisecond\r\nfmt.Println(typex.TimeDurationSecond(duration))//3.5s\r\nfmt.Println(typex.TimeDurationSecondI(duration))//3 s\r\nfmt.Println(typex.TimeDurationParseSecondF(\"200ms\"))//0.2s\r\nfmt.Println(typex.TimeDurationParseSecondF(\"200000us\"))//0.2s\r\nfmt.Println(typex.TimeDurationParseSecondF(\"00:01:01\"))//61s\r\nfmt.Println(typex.TimeDurationParseSecondF(\"61s\"))//61s\r\n\r\n\r\nfmt.Println(typex.NewVideoSize(1024, 720))//720x1024\r\nfmt.Println(typex.NewRatio(1024, 720))//720:1024\r\nfmt.Println(typex.NewRate(25, 1))  //25/1\r\n```\r\n\r\n- More examples ==\u003esee examples dir ","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felizabevil%2Fffmpegx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felizabevil%2Fffmpegx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felizabevil%2Fffmpegx/lists"}