{"id":16401606,"url":"https://github.com/yev/java-ffmpeg-pipe","last_synced_at":"2025-04-10T19:44:40.506Z","repository":{"id":15942613,"uuid":"18684904","full_name":"yev/java-ffmpeg-pipe","owner":"yev","description":"Simple yet powerful example of integration ffmpeg with java","archived":false,"fork":false,"pushed_at":"2014-04-23T07:12:21.000Z","size":216,"stargazers_count":11,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-15T20:57:07.863Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/yev.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":"2014-04-11T18:46:21.000Z","updated_at":"2024-10-01T01:04:55.000Z","dependencies_parsed_at":"2022-09-24T05:51:16.437Z","dependency_job_id":null,"html_url":"https://github.com/yev/java-ffmpeg-pipe","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/yev%2Fjava-ffmpeg-pipe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yev%2Fjava-ffmpeg-pipe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yev%2Fjava-ffmpeg-pipe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yev%2Fjava-ffmpeg-pipe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yev","download_url":"https://codeload.github.com/yev/java-ffmpeg-pipe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281425,"owners_count":21077423,"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":[],"created_at":"2024-10-11T05:43:34.976Z","updated_at":"2025-04-10T19:44:40.487Z","avatar_url":"https://github.com/yev.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"java-ffmpeg-pipe\n================\n\nSimple yet powerful example of integration ffmpeg with java\n\n\n\u003cdiv width=\"100%\" align=\"center\"\u003e\n\u003cimg src=\"https://raw.github.com/yev/java-ffmpeg-pipe/master/doc/Java-Ffmpeg-Pipe.jpg\" align=\"center\"/\u003e\n\u003c/div\u003e\n\n================\n\nIn my last project I encountered the very intresting task: save the snapshots (images) from an RTMP stream into the \nmemcached server.\n\nThe first solution was to use the file system as a temporary media storage for getting the images from ffmpeg.\nThen the java service listens for the events from the specific folder and once getting the event, read the file from FS and push the binary data to the memcached.\nThe problem is FS triggering event speed. It was too fast, al least for ext3. So the image wasn't completly written to the disk but Java service was already notified about the file creation. And binary data send to memcached was truncated and the image wasn't displayed properly.\n\nWe needed to get rid of FS and read row binary data directly from ffmpeg and push it to ff.\nWe can do it with a pipe.\nBut how to distiguish differnt images in the pipe binary stream.\n\nSolution\n----------\n\nMy hack is to use a particlur binary signature of the end of image format (png and jpeg). The valid image file has always 2 last bytes equal to FF D9\n\nAnother, more elegant solution with pure Java approach is using [Xuggler](http://www.xuggle.com/xuggler/) library. Xuggler has JNI calls to embeded ffmpeg to get job done.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyev%2Fjava-ffmpeg-pipe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyev%2Fjava-ffmpeg-pipe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyev%2Fjava-ffmpeg-pipe/lists"}