Title: How to terminate a running ffmpegio stream forcibly? · python-ffmpegio/python-ffmpegio · Discussion #7 · GitHub
Open Graph Title: How to terminate a running ffmpegio stream forcibly? · python-ffmpegio/python-ffmpegio · Discussion #7
X Title: How to terminate a running ffmpegio stream forcibly? · python-ffmpegio/python-ffmpegio · Discussion #7
Description: How to terminate a running ffmpegio stream forcibly?
Open Graph Description: Hello! Is there a way to terminate an ongoing ffmpegio stream like the one below, if it runs in its own thread: with ffmpegio.open('http://stream.url', 'ra', blocksize=5000, ac=2, sample_fmt='flt',...
X Description: Hello! Is there a way to terminate an ongoing ffmpegio stream like the one below, if it runs in its own thread: with ffmpegio.open('http://stream.url', 'ra', blocksize=5000, ac=2, s...
Opengraph URL: https://github.com/python-ffmpegio/python-ffmpegio/discussions/7
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"How to terminate a running ffmpegio stream forcibly?","text":"\u003cp dir=\"auto\"\u003eHello!\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIs there a way to terminate an ongoing ffmpegio stream like the one below, if it runs in its own thread:\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"with ffmpegio.open('http://stream.url', 'ra', blocksize=5000, ac=2, sample_fmt='flt', reconnect_at_eof=1,reconnect_streamed=1) as stream:\n for block in stream:\n process(block)\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode class=\"notranslate\"\u003ewith ffmpegio.open('http://stream.url', 'ra', blocksize=5000, ac=2, sample_fmt='flt', reconnect_at_eof=1,reconnect_streamed=1) as stream:\n for block in stream:\n process(block)\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eOne possibility could be to kill the ffmpeg by looking at its PPID, which is of course the PID of the main Python process the code is run from. But is there a more elegant way? I need to terminate the ffmpeg process and the thread in case they hang, but I have not found any robust method for that.\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/suurj/hovercard\" data-octo-click=\"hovercard-link-click\" data-octo-dimensions=\"link_type:self\" href=\"https://github.com/suurj\"\u003e@suurj\u003c/a\u003e - the code snippet will terminate the FFmpeg process if it's not dead when Python process exits the context. If FFmpeg process has not been terminated (i.e., all frames were read) it calls \u003ccode class=\"notranslate\"\u003ePopen.kill()\u003c/code\u003e on the FFmpeg process. If it is not behaving as such, I need to investigate into in (need more info).\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eYou can inspect how the stream closes here:\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003c/p\u003e\u003cdiv class=\"Box Box--condensed my-2\"\u003e\n \u003cdiv class=\"Box-header f6\"\u003e\n \u003cp class=\"mb-0 text-bold\"\u003e\n \u003ca href=\"https://github.com/python-ffmpegio/python-ffmpegio/blob/4fd16e1b914d0be18154caf1b06f7d046bed55b2/src/ffmpegio/streams/SimpleStreams.py#L91\"\u003epython-ffmpegio/src/ffmpegio/streams/SimpleStreams.py\u003c/a\u003e\n \u003c/p\u003e\n \u003cp class=\"mb-0 color-fg-muted\"\u003e\n Line 91\n in\n \u003ca data-pjax=\"true\" class=\"commit-tease-sha Link--inTextBlock\" href=\"/python-ffmpegio/python-ffmpegio/commit/4fd16e1b914d0be18154caf1b06f7d046bed55b2\"\u003e4fd16e1\u003c/a\u003e\n \u003c/p\u003e\n \u003c/div\u003e\n \u003cdiv itemprop=\"text\" class=\"Box-body p-0 blob-wrapper blob-wrapper-embedded data\"\u003e\n \u003ctable class=\"highlight tab-size mb-0 js-file-line-container\" data-tab-size=\"8\" data-paste-markdown-skip=\"\"\u003e\n\n \u003ctbody\u003e\u003ctr class=\"border-0\"\u003e\n \u003ctd id=\"L91\" class=\"blob-num border-0 tmp-px-3 py-0 color-bg-default\" data-line-number=\"91\"\u003e\u003c/td\u003e\n \u003ctd id=\"LC91\" class=\"blob-code border-0 tmp-px-3 py-0 color-bg-default blob-code-inner js-file-line\"\u003e \u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eclose\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e): \u003c/td\u003e\n \u003c/tr\u003e\n \u003c/tbody\u003e\u003c/table\u003e\n \u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003e\u003c/p\u003e","upvoteCount":1,"url":"https://github.com/python-ffmpegio/python-ffmpegio/discussions/7#discussioncomment-3881060"}}}
| 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:f474cdcb-6370-f86b-7375-f5e91579ee62 |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | AC8A:27B055:282571:37FE18:6AFD737D |
| html-safe-nonce | c4cf48bba7ad2dc85757d290d1b424d3884ca122722748c09e9611a55edb1abd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzhBOjI3QjA1NToyODI1NzE6MzdGRTE4OjZBRkQ3MzdEIiwidmlzaXRvcl9pZCI6IjY5Mzc1OTIwNzU4MDYxNDMzNTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f357ee5a08aa28f6f483b00f5781ae756bd4a7fef1ceeca20816c80fb71aa019 |
| hovercard-subject-tag | discussion:4474269 |
| 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/7/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/11d9e2a7f902805bdae9fb3f7d5485aeac7c1b6e6e6b158a8b1b0fdb3336b3a4/python-ffmpegio/python-ffmpegio/discussions/7 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/11d9e2a7f902805bdae9fb3f7d5485aeac7c1b6e6e6b158a8b1b0fdb3336b3a4/python-ffmpegio/python-ffmpegio/discussions/7 |
| og:image:alt | Hello! Is there a way to terminate an ongoing ffmpegio stream like the one below, if it runs in its own thread: with ffmpegio.open('http://stream.url', 'ra', blocksize=5000, ac=2, sample_fmt='flt',... |
| 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