# @kevingodell/node-red-pipe2jpeg

**URL:** https://discourse.nodered.org/t/kevingodell-node-red-pipe2jpeg/73378
**Category:** Share Your Nodes
**Created:** [8 January 2023 17:55 UTC](https://discourse.nodered.org/t/kevingodell-node-red-pipe2jpeg/73378 "2023-01-08T17:55:21Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![kevinGodell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kevingodell/32/27040_2.png) [@kevinGodell](https://discourse.nodered.org/u/kevinGodell)
#### Post date: [8 January 2023 17:55 UTC](https://discourse.nodered.org/t/kevingodell-node-red-pipe2jpeg/73378/1 "2023-01-08T17:55:21Z")

</div>

The **old unpublished** `node-red-contrib-pipe2jpeg` has been re-built as [@kevingodell/node-red-pipe2jpeg](https://flows.nodered.org/node/@kevingodell/node-red-pipe2jpeg).

This node is similar to @BartButenaers' [node-red-contrib-multipart-stream-encoder (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-multipart-stream-encoder), but serves a different purpose.

It is mostly a wrapper around the lib [pipe2jpeg](https://github.com/kevinGodell/pipe2jpeg), which handles jpeg chunks that are piped from ffmpeg. An extra option to host `image.jpeg` and `video.mjpeg `http routes was added for convenience.

If you have used `@kevingodell/node-red-mp4frag`, you may notice some similarities.

You may only need this node if you are piping jpegs from ffmpeg. The reason is that the jpeg can be broken into buffer chunks to fit within your system's pipe if it is too big to fit as a single piece. It can arrive in 2 or more chunks and need to be re-assembled in some situations. Other times, there may be more than 1 jpeg packed into a single chunk. The internal dependency `pipe2jpeg` handles that buffer marker searching. To get further into the weeds, the start marker `ff d8` and end marker`ff d9` may arrive at the beginning, middle, end of a chunk, or even have the `ff` arrive at the end of 1 chunk, with the `d8` arrive in the next chunk.

You can set the option to output the buffer as an array of buffers or a single concatenated buffer. **Array is preferred** so that there is no extra memory allocation. The http routes can handle either setting with no problem. Buffer concatenation should be avoided to prevent an increase in memory usage, but you can do whatever you prefer.

If you are using `@kevingodell/node-red-ui-mp4frag` to view fragmented mp4 video from `@kevingodell/node-red-mp4frag`, then you can set the ready poster url to be the http path to `/pipe2jpeg/<basePath>/image.jpeg` and you will see the most recent jpeg right before the mp4 video loads.

 ![Screen Shot 2023-01-08 at 11.22.10 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/c/4c7c84727b07189201c1f09e0f78d867990a8a52.png)

As always, the documents are sparse. Import the example:

 ![Screen Shot 2023-01-08 at 11.33.30 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/3/33f0d97705e0e4addce690c251fe6bbdec8f3771.png)

I would suggest that you do not directly send the jpegs to `node-red-dashboard`. The problem will be that even when you are not viewing a tab that is meant for showing the image, the jpeg will still be delivered and waste much bandwidth. Instead, send the `playlist` to the dashboard and have the front end widget request the jpegs on an interval.

 ![Screen Shot 2023-01-08 at 11.42.24 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/b/cba0052a7434d73950b7876c97a2c1df356bab91.png)

```auto
[{"id":"0c43334e64655a4c","type":"ui_template","z":"0eb5dd623a753eb1","group":"a33e942d5385de1d","name":"jpeg reloader widget","order":14,"width":"6","height":"4","format":"<img ng-src=\"{{src}}\" ng-on-load=\"onLoad()\" class=\"jpeg-img\"/>\n\n<script>\n((scope) => {\n\n scope.destroy = () => {\n\n clearInterval(scope.reloader);\n\n scope.src = ' '; // angular bug, give it some whitespace to clear img src\n\n }\n\n scope.$watch('msg', (msg) => {\n\n scope.destroy();\n\n if (msg && msg.payload && msg.payload.jpegImage) {\n\n const { jpegImage } = msg.payload;\n\n scope.src = jpegImage;\n\n scope.reloader = setInterval(() => {\n\n scope.src = `${jpegImage}?t=${Date.now()}`;\n\n },\n\n 2000\n\n );\n\n }\n\n });\n\n scope.$on('$destroy', scope.destroy);\n\n})(scope);\n</script>","storeOutMessages":true,"fwdInMessages":false,"resendOnRefresh":true,"templateScope":"local","className":"jpeg-widget","x":1680,"y":500,"wires":[[]]},{"id":"a33e942d5385de1d","type":"ui_group","name":"Group 1","tab":"8d2f4135ad04d074","order":1,"disp":true,"width":"6","collapse":false,"className":"jpeg-group"},{"id":"8d2f4135ad04d074","type":"ui_tab","name":"jpeg montage","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [8 January 2023 18:41 UTC](https://discourse.nodered.org/t/kevingodell-node-red-pipe2jpeg/73378/2 "2023-01-08T18:41:09Z")

</div>

> [@kevinGodell](#):
>
> `node-red-contrib-pipe2jpeg`

This node name followed the recommended scheme for naming nodes, the new node does not. You might consider renaming it to fit in with the accepted scheme.

---

<div class="post-metadata">

### Author: ![kevinGodell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kevingodell/32/27040_2.png) [@kevinGodell](https://discourse.nodered.org/u/kevinGodell)
#### Post date: [8 January 2023 19:10 UTC](https://discourse.nodered.org/t/kevingodell-node-red-pipe2jpeg/73378/3 "2023-01-08T19:10:53Z")

</div>

Thank you for your feedback.

[https://nodered.org/docs/creating-nodes/packaging](https://nodered.org/docs/creating-nodes/packaging)

from the docs:

Naming

**We [updated our naming requirements](https://nodered.org/blog/2022/01/31/introducing-scorecard) on 31st January 2022. The following applies to modules first published after that date.**

Packages should use a [scoped name](https://docs.npmjs.com/cli/v8/using-npm/scope) - such as `@myScope/node-red-sample`. That can be under a user scope or an organisation scope.

Nodes published under a scoped name have no further requirements on their name. They could use `@myScope/node-red-sample` or just `@myScope/sample` - although having `node-red` in the name does help to associate the module with the project.

If you are forking an existing package to provide a fix, you can keep the same name but released under your own scope. But please keep in mind, forking should always be a last resort if the original maintainer is not responsive to your contributions.

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [8 January 2023 19:29 UTC](https://discourse.nodered.org/t/kevingodell-node-red-pipe2jpeg/73378/4 "2023-01-08T19:29:21Z")

</div>

My apologies, I had missed the change!
