{"id":13905441,"url":"https://github.com/jiashaokun/ffmpeg","last_synced_at":"2025-04-12T21:31:21.841Z","repository":{"id":50287538,"uuid":"135265672","full_name":"jiashaokun/ffmpeg","owner":"jiashaokun","description":"基于FFmpeg的python视频处理包-因疫情影响，工作比较繁忙，心情也没在视频上面再研究，该项目已经搁置，源码很简单，大家可以自己研究一下自己扩展","archived":false,"fork":false,"pushed_at":"2022-07-28T03:44:30.000Z","size":110,"stargazers_count":115,"open_issues_count":5,"forks_count":26,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-04T01:08:41.223Z","etag":null,"topics":["ffmpeg","python"],"latest_commit_sha":null,"homepage":"","language":"Python","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/jiashaokun.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}},"created_at":"2018-05-29T08:32:20.000Z","updated_at":"2025-03-14T02:53:43.000Z","dependencies_parsed_at":"2022-09-06T17:00:13.173Z","dependency_job_id":null,"html_url":"https://github.com/jiashaokun/ffmpeg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiashaokun%2Fffmpeg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiashaokun%2Fffmpeg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiashaokun%2Fffmpeg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiashaokun%2Fffmpeg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiashaokun","download_url":"https://codeload.github.com/jiashaokun/ffmpeg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248635011,"owners_count":21137158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","python"],"created_at":"2024-08-06T23:01:15.777Z","updated_at":"2025-04-12T21:31:21.814Z","avatar_url":"https://github.com/jiashaokun.png","language":"Python","funding_links":[],"categories":["HarmonyOS"],"sub_categories":["Windows Manager"],"readme":"# ffmpeg python\n\n\u003e* 该项目是使用 python 对 FFmpeg 的类库做了一次封装使用，因最近不搞视频，所以很长时间不维护了，大家可以参照写法，使用 python 构建自己的视频处理服务（Dont forget GPU）。\n\n## 系统依赖\nffmpeg 3.0 及以上\nffprobe 3.0 及以上\npython 3.0 及以上\n\nmac，linux，windows 相应的 gpu 显卡驱动 （使用硬编码时需支持）\n\n### ffmpeg安装参见\n[安装ffmpeg](https://note.youdao.com/s/PgfOK55h)\n\n[ffmpeg命令总结](https://note.youdao.com/s/68D7uJUL)\n\n### Install\n```shell\npip install ffmpeg\n```\n\n### Use Demo 向视频（指定位置和时间，默认坐标为 0 ）添加 n 张图片\n```shell\nfrom ffmpeg import video\n\n# 输入视频\ninput_file = \"demo.mp4\"\n\n# 输出视频\nout_file = \"demo_out.mp4\"\n\n# 图片列表\nimg_data = [\n        {\n            \"img\": \"demo1.png\",\n            \"x\": \"\",\n            \"y\": \"\",\n            \"str_time\": \"5\",\n            \"end_time\": \"15\",\n        },\n        {\n            \"img\": \"demo2.png\",\n            \"x\": \"\",\n            \"y\": \"\",\n            \"str_time\": \"20\",\n            \"end_time\": \"25.5\"\n        }\n    ]\n\nvideo.ins_img(input_file, img_data, out_file)\n```\n\n### Demo 视频添加动图 gif apng 等\n\n```shell\nfrom ffmpeg import video\n\ninput_file = \"demo.mp4\"\n\nout_file = \"demo_out.mp4\"\n\nimg_data = {\n    \"img\": \"img.apng\",\n    \"x\": \"20\",\n    \"y\": \"20\",\n    \"str_time\": \"2\",\n    \"end_time\": \"10\"\n}\n\n\nvideo.ins_dynamic_img(input_file, img_data, out_file)\n```\n\n### 图片处理   图片转 mp4  5: 时长为 5 秒的 mp4\n```shell\nfrom ffmpeg import image\n\nimage.img_trans_video(\"png/text_%02d.jpg\", \"5\", \"out.mp4\")\n```\n\n### 复合模式\n```python\nfrom ffmpeg import stream\nstream = Stream()\n# 输入文件\nstream.input(input_file)\n# 图片\nstream.img(\"t1.png\")\nstream.img(\"t2.png\", \"10\", y=10, str_time=5, end_time=10)\n# 动图\nstream.img_dynamic(\"t1.apng\", \"10\", \"10\", \"5\", \"10\")\nstream.img_dynamic(\"t2.gif\", x=10, y=10, str_time=5, end_time=9)\n# 文字水印\nstream.word_water_mark(\"test1\", x=\"10\", y=\"10\", str_time=\"0\", end_time=\"20\", font=\"ttf.ttf\", color=\"blue\")\nstream.word_water_mark(\"test2\", x=\"10\", y=\"10\", str_time=\"0\", end_time=\"20\", font=\"ttf.ttf\", color=\"blue\")\n# 字幕\nstream.subbtitle(\"tt.srt\")\n# 显卡加速，该方式目前只适用于 mac 和 navida, 参数size是视频大小，该值越大，越慢\nstream.fast(\"5M\")\n# 输出文件\nstream.out(out_file)\nstream.run()\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiashaokun%2Fffmpeg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiashaokun%2Fffmpeg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiashaokun%2Fffmpeg/lists"}