{"id":15645176,"url":"https://github.com/binarykitchen/avconv","last_synced_at":"2025-04-14T16:08:56.044Z","repository":{"id":7757364,"uuid":"9125238","full_name":"binarykitchen/avconv","owner":"binarykitchen","description":"Simply spawns an avconv process with any parameters and streams the results to you (meta data + conversion progress)","archived":false,"fork":false,"pushed_at":"2019-06-13T21:33:09.000Z","size":1092,"stargazers_count":57,"open_issues_count":2,"forks_count":11,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-29T17:55:51.493Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npmjs.org/package/avconv","language":"JavaScript","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/binarykitchen.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","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":"2013-03-31T03:07:44.000Z","updated_at":"2024-06-29T12:29:17.000Z","dependencies_parsed_at":"2022-09-26T16:22:43.619Z","dependency_job_id":null,"html_url":"https://github.com/binarykitchen/avconv","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/binarykitchen%2Favconv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarykitchen%2Favconv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarykitchen%2Favconv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarykitchen%2Favconv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binarykitchen","download_url":"https://codeload.github.com/binarykitchen/avconv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232802714,"owners_count":18578684,"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-03T12:04:57.799Z","updated_at":"2025-01-07T00:05:54.743Z","avatar_url":"https://github.com/binarykitchen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# avconv\n\n[![Build Status](https://travis-ci.org/binarykitchen/avconv.png?branch=master)](https://travis-ci.org/binarykitchen/avconv)\n\nSimply spawns an avconv process with any parameters and *streams* the results to you (meta data + conversion progress). Very small, fast, clean and does only this:\n\n```javascript\n// Anything you want\nvar params = [ ... ];\n\n// Returns a duplex stream\nvar stream = avconv(params);\n\n// Here you know it's done\nstream.on('exit', function(...) {\n    ...\n})\n```\n\nIt also can keep you informed about the progress by emitting events. That's a very unique function of this module. Link that with an UI and it will look flash. See `progress` event below.\n\n## Support\nIf you've found avconv useful and would like to contribute to its continued development \u0026 support, please feel free to send a donation of any size - it would be greatly appreciated!\n\n[![Support via Gittip](https://rawgithub.com/chris---/Donation-Badges/master/gittip.jpeg)](https://www.gittip.com/binarykitchen)\n\n## Installation\n\nTo install avconv, use [npm](http://github.com/isaacs/npm):\n\n    $ npm install avconv\n\nThen in your node.js app, get reference to the function like that:\n\n```javascript\nvar avconv = require('avconv');\n```\n\n## Quick examples\n\n### Encode an avi video out of images\n\n```javascript\nvar params = [\n    '-f', 'image2',\n    '-loglevel', 'info',\n    '-i', '/tmp/images/',\n    '-y', '/tmp/output.avi'\n];\n\n// Returns a duplex stream\nvar stream = avconv(params);\n\n// Anytime avconv outputs any information, forward these results to process.stdout\nstream.on('message', function(data) {\n    process.stdout.write(data);\n})\n```\n\n* Avconv consultation is not subject of this module. If you need help with parameters, have a look at http://libav.org/avconv.html\n* Same goes with node streams. You can do anything with them you want. Pipe them or listen to events. Easy.\n* But if your're smart, then go, have a look at the unit tests. They contain some nice examples.\n\n### Using streams \u0026 pipes\n\n```javascript\nvar params = [\n    '-i', 'pipe:0', // Tell avconv to expect an input stream (via its stdin)\n    '-f', 's16le',  // We only want audio back\n    '-acodec',\n    'pcm_s16le',\n    'pipe:1'        // Tell avconv to stream the converted data (via its stdout)\n];\n\n// Get the duplex stream\nvar stream = avconv(params);\n\n// Pipe a file into avconv\nfs.createReadStream('video.mp4').pipe(stream);\n\n// Pipe the audio output to a new file\nstream.pipe(fs.createWriteStream('audio.raw'));\n```\n\n### How to watch for results (progress, meta data, output, errors, exit code)?\n\nIf you want to watch for errors or for exit codes from the avconv process then you should add event listeners like that:\n\n```javascript\nvar stream = avconv(params);\n\nstream.on('message', function(data) {\n    process.stdout.write(data);\n\n    /*\n    This also would work because data is utf8 encoded:\n    console.log(data);\n    */\n});\n\nstream.on('progress', function(progress) {\n    /*\n    Progress is a floating number between 0 ... 1 that keeps you\n    informed about the current avconv conversion process.\n    */\n});\n\nstream.on('error', function(data) {\n    process.stderr.write(data);\n});\n\nstream.on('data', function(data) {\n    /*\n    When you tell avconv to output to 'pipe:1',\n    this is where the data will end up (as a buffer)\n    */\n});\n\n// You can also pipe the output\nstream.pipe(fs.createWriteStream('video.mp4'));\n\nstream.once('exit', function(exitCode, signal, metadata) {\n    /*\n    Here you know the avconv process is finished\n    Metadata contains parsed avconv output as described in the next section\n    */\n});\n```\n\nAn exit code of 0 (zero) means there was no problem. An exit code of 127 means the program avconv could not be found. I recommend you to use a switch block to deal with various exit codes.\n\nDepending on the log level you have passed onto the avconv process, the output might contain any useful information. Beware that warnings or errors from within the avconv process are still shown as normal output in the `data` event.\n\nWhereas errors from the stream are rarely filled (`error` event). They happen only when there was an unix-related problem about spawning processes, memory blabbah ...\n\n## API\n\n### stream = avconv(params, [command = 'avconv'])\n\nAvconv spawns a new avconv process with any given parameters. It does not validate the parameters nor mess with the results. That's all up to you. You would see avconv complaining about bad parameters in the `data` event anyway. So:\n\n__one mandatory argument__\n\n* params - any array list with string arguments as values (see examples)\n\n__one optional argument__\n\n* command - the path to the avconv executable (for example to a static binary). Defaults to 'avconv'.\n\n__one return value__\n\n* stream - a readable stream where you can attach well-known events like:\n    * `.on('message', function(data) {...})` - a chunk of data with useful information, depending on the log level. Any warnings or errors from avconv are there too.\n    * `.on('progress', function(progress) {...})` - a floating number, 0 means conversion progress is at 0%, 1 is 100% and means, it's done. Very useful if you want to show the conversion progress on an user interface.\n    * `.on('data', function(data) {...})` - a buffer object with converted data (if outputting to pipe:1)\n    * `.on('error', function(data) {...})` - rarely used. Would contain issues related to the OS itself.\n    * `.once('exit', function(exitCode, signal, metadata) {...})` - for the exit code any integer where 0 means OK. Anything above 0 indicates a problem (exit code). The signal tells how the process ended, i.E. can be a SIGTERM you killed it with `stream.kill()`. If it's null, then it ended normally.\n\nAnd of course, you can `.kill()` the stream, if you want to abort in the middle. It will kill the process in cold blood and delegate an `exit` event to avconv's internals.\n\n### Metadata object\nMost of the output of avconv is parsed into a metadata object accessable in the `exit` event.\n\n__Please note that parsing of some stream properties may fail, resulting in `null` or `NaN` values.__\n```javascript\n// converting an flv file to webm\n{\n    input: {\n        duration: 32056, // milliseconds\n        start: 0,\n        bitrate: null,\n        stream: [\n            [\n                {\n                    type: \"video\",\n                    codec: \"h264\",\n                    format: \"yuv420p\",\n                    resolution: [ 320, 240 ],\n                    bitrate: 202, // kb/s\n                    fps: 29.92\n                },{\n                    type: \"audio\",\n                    codec: \"aac\",\n                    samplerate: 22050, // Hz\n                    channels: 2, // will be 6 for 5.1 etc.\n                    sampleformat: \"fltp\",\n                    bitrate: 63 // kbs\n                }\n            ]\n        ]\n    },\n    output: {\n        stream: [\n            [\n                {\n                    type: \"video\",\n                    codec: \"libvpx\",\n                    format: \"yuv420p\",\n                    resolution: [ 320, 240 ],\n                    bitrate: 200\n                },{\n                    type: \"audio\",\n                    codec: \"libvorbis\",\n                    samplerate: 22050,\n                    channels: 2,\n                    sampleformat: \"fltp\",\n                    bitrate: null\n                }\n            ]\n        ]\n    }\n}\n``` \n\n## Changelog\n\nSee History.md\n\n## Contributors\n\n* Michael Heuberger \u003cmichael.heuberger@binarykitchen.com\u003e\n* Jelle De Loecker \u003cjelle@kipdola.be\u003e\n* Jan Scheurer \u003clj1102@googlemail.com\u003e\n* You?\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinarykitchen%2Favconv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinarykitchen%2Favconv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinarykitchen%2Favconv/lists"}