Title: Does this work?: Audio NumPy Array » ffmpegio audio-processing » NumPy Array · python-ffmpegio/python-ffmpegio · Discussion #13 · GitHub
Open Graph Title: Does this work?: Audio NumPy Array » ffmpegio audio-processing » NumPy Array · python-ffmpegio/python-ffmpegio · Discussion #13
X Title: Does this work?: Audio NumPy Array » ffmpegio audio-processing » NumPy Array · python-ffmpegio/python-ffmpegio · Discussion #13
Description: Does this work?: Audio NumPy Array » ffmpegio audio-processing » NumPy Array
Open Graph Description: Good afternoon thank you very much for sharing your great work!, it's very useful to have ffmpegio. Because ffmpeg has great audio-/video-processing features, I had this idea: Is it possible to use...
X Description: Good afternoon thank you very much for sharing your great work!, it's very useful to have ffmpegio. Because ffmpeg has great audio-/video-processing features, I had this idea: Is it possible to...
Opengraph URL: https://github.com/python-ffmpegio/python-ffmpegio/discussions/13
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Does this work?: Audio NumPy Array » ffmpegio audio-processing » NumPy Array","text":"\u003cp dir=\"auto\"\u003eGood afternoon\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003ethank you very much for sharing your great work!\u003c/strong\u003e, it's very useful to have \u003ccode class=\"notranslate\"\u003effmpegio\u003c/code\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eBecause ffmpeg has great audio-/video-processing features, I had this idea:\u003c/p\u003e\n\u003ch4 dir=\"auto\"\u003eIs it possible to use \u003ccode class=\"notranslate\"\u003effmpegio\u003c/code\u003e to process numpy arrays with ffmpeg audio/video processors without having to create files on the disc?\u003c/h4\u003e\n\u003cp dir=\"auto\"\u003eI have a practical, simple example:\u003c/p\u003e\n\u003col dir=\"auto\"\u003e\n\u003cli\u003eStereo audio data is stored in a numpy array\u003c/li\u003e\n\u003cli\u003eThe numpy array is passed to \u003ccode class=\"notranslate\"\u003effmpegio\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode class=\"notranslate\"\u003effmpegio\u003c/code\u003e uses ffmpeg and converts the stereo signal to mono\u003c/li\u003e\n\u003cli\u003eAfterwards, the result is passed back to Python as numpy Array\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp dir=\"auto\"\u003e\u003cem\u003e(I use this example because if one mathematically convert stereo to mono, the result is about 3dB less loud than the stereo signal and there can be spikes with large peaks. So one must start a postprocessor after the mono conversion - what ffmpeg does very well 😃)\u003c/em\u003e\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThanks a lot for any help!, kind regards,\u003cbr\u003e\nThomas\u003c/p\u003e","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"\u003cp dir=\"auto\"\u003e\u003ca class=\"user-mention notranslate\" data-hovercard-type=\"user\" data-hovercard-url=\"/users/schittli/hovercard\" data-octo-click=\"hovercard-link-click\" data-octo-dimensions=\"link_type:self\" href=\"https://github.com/schittli\"\u003e@schittli\u003c/a\u003e - That's an interesting usecase that I didn't think of. I had to do some digging to find a workaround, and luckily there is an \u003ccode class=\"notranslate\"\u003eanull\u003c/code\u003e filter, which does nothing but just pass the input samples to output. With it, you can use the \u003ccode class=\"notranslate\"\u003efilter\u003c/code\u003e function.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eHere is a quick example:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"import ffmpegio as ff\nimport numpy as np\nfrom matplotlib import pyplot as plt\n\nfs = 16000\nT = 1\nx = np.random.default_rng().integers(2^-15,2^15,dtype='int16',size=(T*fs,2))\n\nfsout,y = ff.audio.filter('anull', fs, x, ac=1) # no explicit filtering, just implicit stereo-\u0026gt;mono conversion\n\nplt.plot(x)\nplt.plot(y)\nplt.show()\"\u003e\u003cpre class=\"notranslate\"\u003e\u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003effmpegio\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eas\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eff\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003enumpy\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eas\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003enp\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ematplotlib\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003epyplot\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eas\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eplt\u003c/span\u003e\n\n\u003cspan class=\"pl-s1\"\u003efs\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e16000\u003c/span\u003e\n\u003cspan class=\"pl-c1\"\u003eT\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e1\u003c/span\u003e\n\u003cspan class=\"pl-s1\"\u003ex\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003enp\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003erandom\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003edefault_rng\u003c/span\u003e().\u003cspan class=\"pl-c1\"\u003eintegers\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e2\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e^\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e15\u003c/span\u003e,\u003cspan class=\"pl-c1\"\u003e2\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e^\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e15\u003c/span\u003e,\u003cspan class=\"pl-s1\"\u003edtype\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e\u003cspan class=\"pl-s\"\u003e'int16'\u003c/span\u003e,\u003cspan class=\"pl-s1\"\u003esize\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003eT\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e*\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003efs\u003c/span\u003e,\u003cspan class=\"pl-c1\"\u003e2\u003c/span\u003e))\n\n\u003cspan class=\"pl-s1\"\u003efsout\u003c/span\u003e,\u003cspan class=\"pl-s1\"\u003ey\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eff\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eaudio\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003efilter\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e'anull'\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003efs\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003ex\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eac\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e1\u003c/span\u003e) \u003cspan class=\"pl-c\"\u003e# no explicit filtering, just implicit stereo-\u0026gt;mono conversion\u003c/span\u003e\n\n\u003cspan class=\"pl-s1\"\u003eplt\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eplot\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003ex\u003c/span\u003e)\n\u003cspan class=\"pl-s1\"\u003eplt\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eplot\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003ey\u003c/span\u003e)\n\u003cspan class=\"pl-s1\"\u003eplt\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eshow\u003c/span\u003e()\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eLet me know if this works for you\u003c/p\u003e","upvoteCount":2,"url":"https://github.com/python-ffmpegio/python-ffmpegio/discussions/13#discussioncomment-6231093"}}}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:eeb676f2-68c2-a9dc-9a75-af9d6dddf307 |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | 8446:27EE91:25D9B9:354AC8:6AFD7398 |
| html-safe-nonce | c18680e423ae8578fd7a2942afce05553c0d8959af950419e839881df7cc08f0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NDQ2OjI3RUU5MToyNUQ5Qjk6MzU0QUM4OjZBRkQ3Mzk4IiwidmlzaXRvcl9pZCI6IjQyNTU0NjM3Nzc3NDQyODY2MTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7506d21e7a60c673fa671c6666f6c76ea9f0f83b8a5c81ecb8f8cd0cfb3fc83f |
| hovercard-subject-tag | discussion:5319735 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/python-ffmpegio/python-ffmpegio/13/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/9b98aca9cb3e71d30273ad0475831c7d267c7debf32d30a63dd2c03af791178b/python-ffmpegio/python-ffmpegio/discussions/13 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9b98aca9cb3e71d30273ad0475831c7d267c7debf32d30a63dd2c03af791178b/python-ffmpegio/python-ffmpegio/discussions/13 |
| og:image:alt | Good afternoon thank you very much for sharing your great work!, it's very useful to have ffmpegio. Because ffmpeg has great audio-/video-processing features, I had this idea: Is it possible to use... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | e54006cf2b96d1ac260960edd10003132911469ccd1ec99c9803119fe2a4e032 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-ffmpegio/python-ffmpegio git https://github.com/python-ffmpegio/python-ffmpegio.git |
| octolytics-dimension-user_id | 98168493 |
| octolytics-dimension-user_login | python-ffmpegio |
| octolytics-dimension-repository_id | 355600490 |
| octolytics-dimension-repository_nwo | python-ffmpegio/python-ffmpegio |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 355600490 |
| octolytics-dimension-repository_network_root_nwo | python-ffmpegio/python-ffmpegio |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5be0bf2b8cf26f8897d31e6bc3c232d328b12a54 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width