{"id":34121748,"url":"https://github.com/iwanlebron/ffmpeg-go","last_synced_at":"2026-05-28T12:32:00.828Z","repository":{"id":65695762,"uuid":"596936827","full_name":"iwanlebron/ffmpeg-go","owner":"iwanlebron","description":"golang binding for ffmpeg","archived":false,"fork":false,"pushed_at":"2025-06-16T06:20:13.000Z","size":23929,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-19T06:57:28.724Z","etag":null,"topics":["ffpmeg","ffprobe","go"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iwanlebron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-02-03T09:00:38.000Z","updated_at":"2025-06-16T06:20:18.000Z","dependencies_parsed_at":"2023-12-02T06:28:23.670Z","dependency_job_id":"bb1f6886-2d37-4db0-b842-719f5b87f930","html_url":"https://github.com/iwanlebron/ffmpeg-go","commit_stats":{"total_commits":17,"total_committers":2,"mean_commits":8.5,"dds":0.05882352941176472,"last_synced_commit":"6ac6c37bcaa9a66cf0cac675d626f5e16962330c"},"previous_names":["iwanlebron/ffmpeg-go","ivanlebron/ffmpeg-go"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/iwanlebron/ffmpeg-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwanlebron%2Fffmpeg-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwanlebron%2Fffmpeg-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwanlebron%2Fffmpeg-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwanlebron%2Fffmpeg-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iwanlebron","download_url":"https://codeload.github.com/iwanlebron/ffmpeg-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwanlebron%2Fffmpeg-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33609237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["ffpmeg","ffprobe","go"],"created_at":"2025-12-14T21:54:55.259Z","updated_at":"2026-05-28T12:32:00.816Z","avatar_url":"https://github.com/iwanlebron.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ffmpeg-go\n\nffmpeg-go is golang port of https://github.com/kkroening/ffmpeg-python\n\ncheck examples/example_test.go and ffmpeg_test.go for more examples.\n\n# Examples\n\n```go\nsplit := Input(TestInputFile1).VFlip().Split()\n\tsplit0, split1 := split.Get(\"0\"), split.Get(\"1\")\n\toverlayFile := Input(TestOverlayFile).Crop(10, 10, 158, 112)\nerr := Concat([]*Stream{\n    split0.Trim(KwArgs{\"start_frame\": 10, \"end_frame\": 20}),\n    split1.Trim(KwArgs{\"start_frame\": 30, \"end_frame\": 40})}).\n    Overlay(overlayFile.HFlip(), \"\").\n    DrawBox(50, 50, 120, 120, \"red\", 5).\n    Output(TestOutputFile1).\n    OverWriteOutput().\n    Run()\n```\n\n## Transcoding From One Codec To Another\n\n```go\nerr := ffmpeg.Input(\"./sample_data/in1.mp4\").\n\t\tOutput(\"./sample_data/out1.mp4\", ffmpeg.KwArgs{\"c:v\": \"libx265\"}).\n\t\tOverWriteOutput().ErrorToStdOut().Run()\n```\n\n## Cut Video From Timestamp\n\n```go\nerr := ffmpeg.Input(\"./sample_data/in1.mp4\", ffmpeg.KwArgs{\"ss\": 1}).\n    Output(\"./sample_data/out1.mp4\", ffmpeg.KwArgs{\"t\": 1}).OverWriteOutput().Run()\nassert.Nil(t, err)\n```\n\n## Add Watermark For Video\n```go\n// show watermark with size 64:-1 in the top left corner after seconds 1\noverlay := ffmpeg.Input(\"./sample_data/overlay.png\").Filter(\"scale\", ffmpeg.Args{\"64:-1\"})\nerr := ffmpeg.Filter(\n    []*ffmpeg.Stream{\n        ffmpeg.Input(\"./sample_data/in1.mp4\"),\n        overlay,\n    }, \"overlay\", ffmpeg.Args{\"10:10\"}, ffmpeg.KwArgs{\"enable\": \"gte(t,1)\"}).\n    Output(\"./sample_data/out1.mp4\").OverWriteOutput().ErrorToStdOut().Run()\n```\n\nresult:\n\n![img.png](./docs/example_overlay.png)\n\n## Cut Video For Gif\n\n```go\nerr := ffmpeg.Input(\"./sample_data/in1.mp4\", ffmpeg.KwArgs{\"ss\": \"1\"}).\n    Output(\"./sample_data/out1.gif\", ffmpeg.KwArgs{\"s\": \"320x240\", \"pix_fmt\": \"rgb24\", \"t\": \"3\", \"r\": \"3\"}).\n    OverWriteOutput().ErrorToStdOut().Run()\n```\n\nresult:\n\n![img.png](./docs/example_gif.gif)\n\n## Task Frame From Video\n\n```bash\nfunc ExampleReadFrameAsJpeg(inFileName string, frameNum int) io.Reader {\n\tbuf := bytes.NewBuffer(nil)\n\terr := ffmpeg.Input(inFileName).\n\t\tFilter(\"select\", ffmpeg.Args{fmt.Sprintf(\"gte(n,%d)\", frameNum)}).\n\t\tOutput(\"pipe:\", ffmpeg.KwArgs{\"vframes\": 1, \"format\": \"image2\", \"vcodec\": \"mjpeg\"}).\n\t\tWithOutput(buf, os.Stdout).\n\t\tRun()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn buf\n}\n\nreader := ExampleReadFrameAsJpeg(\"./sample_data/in1.mp4\", 5)\nimg, err := imaging.Decode(reader)\nif err != nil {\n    t.Fatal(err)\n}\nerr = imaging.Save(img, \"./sample_data/out1.jpeg\")\nif err != nil {\n    t.Fatal(err)\n}\n```\nresult :\n\n![image](./examples/sample_data/out1.jpeg)\n\n## Get Multiple Output\n\n```go\n// get multiple output with different size/bitrate\ninput := ffmpeg.Input(\"./sample_data/in1.mp4\").Split()\nout1 := input.Get(\"0\").Filter(\"scale\", ffmpeg.Args{\"1920:-1\"}).\nOutput(\"./sample_data/1920.mp4\", ffmpeg.KwArgs{\"b:v\": \"5000k\"})\nout2 := input.Get(\"1\").Filter(\"scale\", ffmpeg.Args{\"1280:-1\"}).\nOutput(\"./sample_data/1280.mp4\", ffmpeg.KwArgs{\"b:v\": \"2800k\"})\n\nerr := ffmpeg.MergeOutputs(out1, out2).OverWriteOutput().ErrorToStdOut().Run()\n```\n\n## Show FFmpeg Progress\n\nsee complete example at: [showProgress](./examples/showProgress.go)\n\n```bash\nfunc ExampleShowProgress(inFileName, outFileName string) {\n\ta, err := ffmpeg.Probe(inFileName)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\ttotalDuration := gjson.Get(a, \"format.duration\").Float()\n\n\terr = ffmpeg.Input(inFileName).\n\t\tOutput(outFileName, ffmpeg.KwArgs{\"c:v\": \"libx264\", \"preset\": \"veryslow\"}).\n\t\tGlobalArgs(\"-progress\", \"unix://\"+TempSock(totalDuration)).\n\t\tOverWriteOutput().\n\t\tRun()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\nExampleShowProgress(\"./sample_data/in1.mp4\", \"./sample_data/out2.mp4\")\n```\n\nresult\n\n```bash\nprogress:  .0\nprogress:  0.72\nprogress:  1.00\nprogress:  done\n```\n\n## Integrate FFmpeg-go With Open-CV (gocv) For Face-detect\n\nsee complete example at: [opencv](./examples/opencv_test.go)\n\nresult: ![image](./examples/sample_data/face-detect.jpg)\n\n## Set Cpu limit/request For FFmpeg-go\n\n```go\ne := ComplexFilterExample(\"./sample_data/in1.mp4\", \"./sample_data/overlay.png\", \"./sample_data/out2.mp4\")\nerr := e.RunWithResource(0.1, 0.5)\nif err != nil {\n    assert.Nil(t, err)\n}\n```\n\nresult from command top: we will see ffmpeg used 0.5 core as expected.\n\n```bash\n\u003e top \nPID    USER       PR  NI    VIRT    RES    SHR S  %CPU   %MEM     TIME+ COMMAND\n1386105 root      20   0 2114152 273780  31672 R  50.2   1.7      0:16.79 ffmpeg\n```\n\n# View Progress Graph\n\nfunction view generate [mermaid](https://mermaid-js.github.io/mermaid/#/) chart, which can be use in markdown or view [online](https://mermaid-js.github.io/mermaid-live-editor/)\n\n```go\nsplit := Input(TestInputFile1).VFlip().Split()\n\tsplit0, split1 := split.Get(\"0\"), split.Get(\"1\")\n\toverlayFile := Input(TestOverlayFile).Crop(10, 10, 158, 112)\nb, err := Concat([]*Stream{\n    split0.Trim(KwArgs{\"start_frame\": 10, \"end_frame\": 20}),\n    split1.Trim(KwArgs{\"start_frame\": 30, \"end_frame\": 40})}).\n    Overlay(overlayFile.HFlip(), \"\").\n    DrawBox(50, 50, 120, 120, \"red\", 5).\n    Output(TestOutputFile1).\n    OverWriteOutput().View(ViewTypeFlowChart)\nfmt.Println(b)\n```\n![image](./docs/flowchart2.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwanlebron%2Fffmpeg-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiwanlebron%2Fffmpeg-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwanlebron%2Fffmpeg-go/lists"}