http://blog.azuresky.ca/ azuresky.ca 2021-07-04T21:39:00Z Michael Chang http://azuresky.ca/ tag:blog.azuresky.ca,2021-07-04:/blog/2021/07/were-not-really-strangers/ We're Not Really Strangers 2021-07-04T21:39:00Z 2021-07-04T21:39:00Z <p>Someone brought <a href="https://www.werenotreallystrangers.com/">We’re Not Really Strangers</a> to a friend’s housewarming, and we tried it. I was skeptical after seeing it <a href="https://www.twitch.tv/videos/1064874264">played on Twitch</a> (seek to about nine minutes in), but it was fine.</p> <p>I happened to draw a card for everyone else to recommend me a book, so here’s the resulting book list:</p> <style> iframe { float: left; width: 100%; height: 50vh; margin-bottom: 16px } </style> <iframe width="50%" height="600" src="https://www.copybooks.app/embed/2e71e2c5-869c-4f94-a550-f4ba3ea972af" title="Copybooks book recommendations - 🇦🇺 We're Not Really Strangers Housewarming" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe> <div style="display:block; clear: left;"></div> tag:blog.azuresky.ca,2021-04-08:/blog/2021/04/boats-and-books/ Boats and Books 2021-04-08T05:42:00Z 2021-04-08T05:42:00Z <p>The human who built <a href="https://istheshipstillstuck.com">istheshipstillstuck.com</a> wrote a book-recommending app in a weekend and wrote about the experience: <a href="https://notfunatparties.substack.com/p/what-goodreads-could-have-been">What Goodreads could have been</a>.</p> <p>So here are some books I’ve read over the past year or two (in no particular order):</p> <style> iframe { float: left; width: 100%; height: 50vh; margin-bottom: 16px } </style> <iframe width="50%" height="600" src="https://www.copybooks.app/embed/b21a18eb-9a03-40de-a781-22f7f7d8fb0e" title="Copybooks book recommendations - 🤔 Truly Curious Club" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe> <iframe width="50%" height="600" src="https://www.copybooks.app/embed/f9657a59-a956-4e5a-bc46-841cdc9cd468" title="Copybooks book recommendations - 📖 Idea Club" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe> <div style="display:block; clear: left;"></div> tag:blog.azuresky.ca,2021-01-05:/blog/2021/01/happy-new-year/ Happy New Year! 2021-01-05T05:57:00Z 2021-01-05T05:57:00Z <p>I was using <a href="https://www.amazon.com/gp/product/B07FZ5FZPZ">this 80 cm x 39.4 cm study table</a> before, but discovered it is inconvenient to do Android development without a space to leave a development device attached to your setup. (I mean, if I was only going to be using it for a few months, why rearrange my whole apartment? Ha, ha.)</p> <p>So now I’m trying a <a href="https://www.amazon.com/gp/product/B082NY2LZW">folding corner desk</a> and a 25” USB-C monitor.</p> <p>I mean, sure, I could spend ~$1000 on a motorized standing desk, but I already have a counter-height table… I guess we’ll see in another 9 months.</p> tag:blog.azuresky.ca,2019-04-05:/blog/2019/04/libnvidia-encode1/ libnvidia-encode1 2019-04-05T21:57:00Z 2019-04-05T21:57:00Z <h2 id="how-it-all-started">How it all started…</h2> <blockquote> <p>“I just want to record my screen.”</p> <p>“Oh, you can use ffmpeg to do that.”</p> <p>(the next day)</p> <p>“My recording is flickering. Is it supposed to do that?”</p> <p>“Oh, hmm…”</p> </blockquote> <h2 id="prerequisites">Prerequisites</h2> <ul> <li>You have a Debian Linux computer with a supported NVidia GPU.</li> <li>You have the proprietary NVidia drivers installed.</li> </ul> <h2 id="hardware-accelerated-screen-recording-with-ffmpeg">Hardware-accelerated screen recording with ffmpeg</h2> <p><strong>tl;dr:</strong> Try installing <code>libnvidia-encode1</code>.</p> <p>From a Google search, the canonical article on the ffmpeg wiki appears to be here: <a href="https://trac.ffmpeg.org/wiki/Capture/Desktop">https://trac.ffmpeg.org/wiki/Capture/Desktop</a></p> <p>It include the following example:</p> <pre><code>$ ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 output.mp4 </code></pre> <p>Let’s try a minimal case:</p> <pre><code>$ ffmpeg -f x11grab -i :0.0 output.mp4 ... s speed=0.59x </code></pre> <p>Hmm, just outputting a 640x480 video with software encoding is not consistently real-time on this computer, when using software encoding.</p> <p>But I know this computer has a recent NVidia card and the proprietary driver, so maybe we can use hardware encoding?</p> <pre><code>$ ffmpeg -encoders ... V..... h264_nvenc NVIDIA NVENC H.264 encoder (codec h264) ... </code></pre> <p>Okay, looks like this <code>ffmpeg</code> was built with <code>h264_nvenc</code>. Let’s use it:</p> <p><img src="/images/2019/libnvidia-encode-error.png" alt="A screenshot of the following shell snippet."></p> <pre><code>$ ffmpeg -f x11grab -i :0.0 -c:v h264_nvenc output.mp4 ... [h264_nvenc @ 0x55a55bb9c360] The minimum required Nvidia driver for nvenc is 378.13 or newer Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed! </code></pre> <p>Huh? I’m pretty sure a more recent driver is installed. I have 390.87, and I’m pretty sure that’s newer than 378.13.</p> <p><img src="/images/2019/nvidia-version-390-87.png" alt="A screenshot of the NVidia X Server Settings app."></p> <p>Let’s look at that error message again…</p> <pre><code>Cannot load libnvidia-encode.so.1 [h264_nvenc @ 0x55a55bb9c360] The minimum required Nvidia driver for nvenc is 378.13 or newer Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed! </code></pre> <p><code>Failed to load libnvidia-encode.so.1</code>? What package provides that? Turns out it’s a separate package called <code>libnvidia-encode1</code>:</p> <pre><code>$ sudo apt-get install libnvidia-encode1 </code></pre> <p>And now our screen recording works:</p> <pre><code>$ ffmpeg -video_size 2560x1600 -f x11grab -i :0.0 -c:v h264_nvenc output.mp4 </code></pre> <h2 id="hardware-accelerated-screen-recording-with-obs">Hardware-accelerated screen recording with OBS</h2> <p>Install OBS, and <code>libnvidia-encode1</code>:</p> <pre><code>$ sudo apt-get install libnvidia-encode1 obs-studio </code></pre> <h3 id="configuring-obs-to-use-nvenc">Configuring OBS to use NVENC</h3> <p>Hardware (NVENC) should just show up in the list of Encoders after installing libnvidia-encode1. (You may need to restart Open Broadcaster Software.)</p> <p>If you don’t get the first-run wizard, delete <code>${HOME}/.config/obs-studio/</code>. (Obviously, make a backup before you go deleting your OBS configuration…)</p> <ol> <li>Select <em>optimize just for recording</em>. (Unless you plan to stream, in which case you might want the extra dialogs for setting up the service you want to stream to.) Click <em>Next</em>.</li> <li>Pick some video settings. Click <em>Next</em>.</li> <li>Verify <em>Recording Encoder: Hardware (NVENC)</em>. If it says Software, or tries to run an encoding benchmark, double-check that you installed libnvidia-encode1 and obs-studio. Click <em>Apply Settings</em>.</li> <li>Under Sources, click <em>+</em>, then <em>Screen Capture (XSHM)</em>.</li> <li>In <em>Create/Select Source</em> dialog, click <em>OK</em>. In the <em>Properties for ‘Screen Capture (XSHM)’</em> dialog, click <em>OK</em>. Your screen should now show in the preview area.</li> </ol> <h3 id="recording-only-part-of-the-screen-with-obs">Recording only part of the screen with OBS</h3> <ol> <li>Right-click the preview of the source you configured. Select <em>Transform &gt; Edit Transform…</em> </li> <li>Specify the <em>Crop</em> in the <em>Scene Item Transform</em> dialog. Click <em>Close</em>.</li> <li>Click the <em>Settings</em> button (or <em>File &gt; Settings</em>).</li> <li>Under <em>Video</em>, modify <em>Base Resolution</em> and <em>Output Resolution</em> as needed. You can type a custom resolution into the drop-down, like <code>1280x800</code>, for both. Click <em>OK</em>.</li> </ol> <h3 id="making-a-recording-with-obs">Making a recording with OBS.</h3> <ol> <li>Verify your screen capture source is selected.</li> <li>Click <em>Start Recording</em>. (You can also set a hotkey for this in Settings.)</li> <li>Perform the actions you want to record.</li> <li>Click <em>Stop Recording</em>. (You can also set a hotkey for this.)</li> <li>Recorded file will be created in the directory you set under <em>Settings &gt; Output &gt; Recording Path</em>. (By default, this is your home directory.)</li> </ol> tag:blog.azuresky.ca,2018-06-19:/blog/2018/06/peach-salad/ Peach Salad 2018-06-19T07:31:50Z 2018-06-19T07:31:50Z <p>Have you ever tried to define what is and isn’t a salad? The Wikipedia article basically comes down to “a mixture, usually vegetables, typically chilled, flavored with salad dressing, with notable exceptions”. You might as well say, “vegetables, except when it’s not”.</p> <p>After puzzling over this for a bit, I’ve found a definition I like better: a salad is <em>a mixture of things someone likes to eat</em>.</p> <p><strong>The true power of salad is realizing that someone could be you!</strong></p> <p>This salad is a recipe from my mom. The first time I saw this was when I was a kid. My mom had made it for herself, and still I remember being pleasantly surprised by how good it was when she let me try some of hers.</p> <p>I find that the contrast between the flavor of the fresh fruit and the dried plum makes everything taste better. Salt also draws out the water in fresh fruit, concentrating their flavour.</p> <p>I always do this recipe “by eye”, so you may need to adjust the amount of salt. But nectarines and tomatoes also come in different shapes and sizes, so, whatever. Add two or three if you like! The recipe also works with other kinds of stone fruit (such as peaches and fresh plums), either as a substitute for nectarines or in addition to them.</p> <h2 id="ingredients">Ingredients</h2> <ul> <li>about 1 Tomato</li> <li>about 1 Nectarine</li> <li>approximately 1 teaspoon salt</li> <li>approximately 3 Chinese dried salted plums (usually brown or red, and sold in clear bags at the Chinese grocery store, with or without pits)</li> </ul> <h2 id="utensils">Utensils</h2> <ul> <li>cutting board</li> <li>knife (preferably a paring knife, but a plastic knife will do in a pinch)</li> <li>two bowls</li> <li>a fork or toothpicks</li> </ul> <h2 id="directions">Directions</h2> <ol> <li>Coarsely chop the tomato and nectarine into a bowl. Discard the nectarine pit.</li> <li>Sprinkle the salt over the chopped tomato and nectarine.</li> <li>Tear the chinese plums into smaller pieces (discard the pits, or use them to make plum tea) and also sprinkle over the tomato and nectarine.</li> <li>Toss to combine. (I like to use the second bowl as a lid when tossing to combine.) Enjoy with a fork or toothpicks.</li> </ol>