{"id":13467422,"url":"https://github.com/sunlubo/SwiftFFmpeg","last_synced_at":"2025-03-26T02:31:30.261Z","repository":{"id":38628100,"uuid":"140159810","full_name":"sunlubo/SwiftFFmpeg","owner":"sunlubo","description":"A Swift wrapper for the FFmpeg API","archived":false,"fork":false,"pushed_at":"2025-01-31T03:04:03.000Z","size":25397,"stargazers_count":550,"open_issues_count":18,"forks_count":84,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-23T22:11:58.558Z","etag":null,"topics":["audio","av1","ffmpeg","ffmpeg-api","h264","hevc","mp4","multimedia","swift","video","webm"],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/sunlubo.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}},"created_at":"2018-07-08T10:56:52.000Z","updated_at":"2025-03-23T13:32:46.000Z","dependencies_parsed_at":"2024-01-29T18:06:55.496Z","dependency_job_id":null,"html_url":"https://github.com/sunlubo/SwiftFFmpeg","commit_stats":{"total_commits":222,"total_committers":6,"mean_commits":37.0,"dds":"0.15315315315315314","last_synced_commit":"fdf975bd93513b6007acde46cda9357a52c8f427"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunlubo%2FSwiftFFmpeg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunlubo%2FSwiftFFmpeg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunlubo%2FSwiftFFmpeg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunlubo%2FSwiftFFmpeg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunlubo","download_url":"https://codeload.github.com/sunlubo/SwiftFFmpeg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245576529,"owners_count":20638125,"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":["audio","av1","ffmpeg","ffmpeg-api","h264","hevc","mp4","multimedia","swift","video","webm"],"created_at":"2024-07-31T15:00:56.184Z","updated_at":"2025-03-26T02:31:30.254Z","avatar_url":"https://github.com/sunlubo.png","language":"Swift","funding_links":[],"categories":["Libs","Media and Graphics","HarmonyOS","Swift","Video [🔝](#readme)"],"sub_categories":["Video","Windows Manager"],"readme":"# SwiftFFmpeg\n\nA Swift wrapper for the FFmpeg API.\n\n\u003e Note: SwiftFFmpeg is still in development, and the API is not guaranteed to be stable. It's subject to change without warning.\n\n## Installation\n\nYou should install [FFmpeg](http://ffmpeg.org/) (Requires FFmpeg 7.1 or higher) before use this library, on macOS, you can:\n\n```bash\nbrew install ffmpeg\n```\n\n### Swift Package Manager\n\nSwiftFFmpeg primarily uses [SwiftPM](https://swift.org/package-manager/) as its build tool, so we recommend using that as well. If you want to depend on SwiftFFmpeg in your own project, it's as simple as adding a `dependencies` clause to your `Package.swift`:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/sunlubo/SwiftFFmpeg.git\", from: \"1.0.0\")\n]\n```\n\n## Documentation\n\n- [API documentation](https://sunlubo.github.io/SwiftFFmpeg)\n\n## Usage\n\n```swift\nimport Foundation\nimport SwiftFFmpeg\n\nif CommandLine.argc \u003c 2 {\n    print(\"Usage: \\(CommandLine.arguments[0]) \u003cinput file\u003e\")\n    exit(1)\n}\nlet input = CommandLine.arguments[1]\n\nlet fmtCtx = try AVFormatContext(url: input)\ntry fmtCtx.findStreamInfo()\n\nfmtCtx.dumpFormat(isOutput: false)\n\nguard let stream = fmtCtx.videoStream else {\n    fatalError(\"No video stream.\")\n}\nguard let codec = AVCodec.findDecoderById(stream.codecParameters.codecId) else {\n    fatalError(\"Codec not found.\")\n}\nlet codecCtx = AVCodecContext(codec: codec)\ncodecCtx.setParameters(stream.codecParameters)\ntry codecCtx.openCodec()\n\nlet pkt = AVPacket()\nlet frame = AVFrame()\n\nwhile let _ = try? fmtCtx.readFrame(into: pkt) {\n    defer { pkt.unref() }\n\n    if pkt.streamIndex != stream.index {\n        continue\n    }\n\n    try codecCtx.sendPacket(pkt)\n\n    while true {\n        do {\n            try codecCtx.receiveFrame(frame)\n        } catch let err as AVError where err == .tryAgain || err == .eof {\n            break\n        }\n\n        let str = String(\n            format: \"Frame %3d (type=%@, size=%5d bytes) pts %4lld key_frame %d\",\n            codecCtx.frameNumber,\n            frame.pictureType.description,\n            frame.pktSize,\n            frame.pts,\n            frame.isKeyFrame\n        )\n        print(str)\n\n        frame.unref()\n    }\n}\n\nprint(\"Done.\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunlubo%2FSwiftFFmpeg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunlubo%2FSwiftFFmpeg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunlubo%2FSwiftFFmpeg/lists"}