{"id":26862200,"url":"https://github.com/mashingan/nimffmpeg","last_synced_at":"2025-05-06T20:26:42.897Z","repository":{"id":40269838,"uuid":"228159000","full_name":"mashingan/nimffmpeg","owner":"mashingan","description":"Nim FFMpeg binding","archived":false,"fork":false,"pushed_at":"2022-05-17T08:02:44.000Z","size":858,"stargazers_count":39,"open_issues_count":1,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-31T02:35:35.851Z","etag":null,"topics":["binding","ffmpeg-libraries","lib","nim"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mashingan.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}},"created_at":"2019-12-15T09:25:43.000Z","updated_at":"2024-07-19T09:39:58.000Z","dependencies_parsed_at":"2022-08-17T20:00:37.083Z","dependency_job_id":null,"html_url":"https://github.com/mashingan/nimffmpeg","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/mashingan%2Fnimffmpeg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mashingan%2Fnimffmpeg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mashingan%2Fnimffmpeg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mashingan%2Fnimffmpeg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mashingan","download_url":"https://codeload.github.com/mashingan/nimffmpeg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252763278,"owners_count":21800457,"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":["binding","ffmpeg-libraries","lib","nim"],"created_at":"2025-03-31T02:35:39.203Z","updated_at":"2025-05-06T20:26:42.848Z","avatar_url":"https://github.com/mashingan.png","language":"C","readme":"# Nim FFMpeg Binding (WIP)\n(Very) Thin FFMpeg C binding for Nim. The thin binding means it's almost same\nwith FFMpeg C APIs.  \nThe advantage is that we can reuse our C APIs knowledge using Nim seamlessly. We\ncan reuse any FFMpeg C tutorials to work with.\n\n## Examples\nSome snippet here can be used to get the first 5 video frame\n\n```\nvar frameCount = 0\nwhile frameCount \u003c 5:\n    if av_read_frame(pFrameContext, pPacket) \u003c 0: # negative means it's error\n        continue                                  # and we just skip this time\n    \n    if packet[].stream_index == videoIndex:       # we only process packet in specific index stream\n                                                  # in this case it's video stream\n        if avcodec_send_packet(pVideoCodecCtx, pPacket) \u003c 0:  # negative means it's error\n            continue\n        if avcodec_receive_frame(pVideoCodecCtx, pFrame) \u003c 0:\n            continue\n        doSomethingWith3YUVPlaneData(pFrame[].data) # pFrame[].data is array filled with YUV several planes\n                                                    # pFrame[].data[0] is Y plane\n                                                    # pFrame[].data[1] is U plane (or Cb be precise)\n                                                    # pFrame[].data[2] is V plane (or Cr be precise)\n        inc frameCount\n```\n\nSnippet to get the first video stream index\n\n```\nvar videoIndex = -1\nvar streams = cast[ptr UncheckedArray[ptr AVStream]](pFormatCtx[].streams)\nfor i in 0 .. pFormatCtx[].nb_streams:\n  let localparam = streams[i][].codecpar\n  if localparam[].codec_type == AVMEDIA_TYPE_VIDEO:\n    videoIndex = int i\n    break\n```\n\nThe index can be used later to know which stream index packet we'll process later.\n\nAny others examples you found should be applicable with this binding too. Several worked examples\nalso availables in `examples` folder.\n\n## To use\nTo able to compile and work with, make sure we installed shared lib to run it.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmashingan%2Fnimffmpeg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmashingan%2Fnimffmpeg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmashingan%2Fnimffmpeg/lists"}