<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by SAMUEL OLAMIDE on Medium]]></title>
        <description><![CDATA[Stories by SAMUEL OLAMIDE on Medium]]></description>
        <link>https://medium.com/@gold_olar?source=rss-6051b5e4320b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jFX_75hTWeRzAlrGxM1eHw.jpeg</url>
            <title>Stories by SAMUEL OLAMIDE on Medium</title>
            <link>https://medium.com/@gold_olar?source=rss-6051b5e4320b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 07:59:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gold_olar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Traffic Cameras to Web Applications: A Streaming Architecture Overview]]></title>
            <link>https://medium.com/@gold_olar/from-traffic-cameras-to-web-applications-a-streaming-architecture-overview-218759743d86?source=rss-6051b5e4320b------2</link>
            <guid isPermaLink="false">https://medium.com/p/218759743d86</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[webrtc]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[rtsp]]></category>
            <category><![CDATA[live-stream-online]]></category>
            <dc:creator><![CDATA[SAMUEL OLAMIDE]]></dc:creator>
            <pubDate>Sun, 26 Jan 2025 12:55:00 GMT</pubDate>
            <atom:updated>2025-01-26T17:12:54.983Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2gAQcLqksJW67Z4gHm5Wfg.png" /><figcaption>Sequence diagram showing the flow</figcaption></figure><p>Building a real-time video streaming pipeline is no small feat. It involves multiple components working in harmony to capture, process, and deliver video data seamlessly. In this article, I’ll walk you through the architecture I built to transform traffic camera feeds into RTSP streams, analyze them with AI, and deliver them to a web application via WebRTC. While I won’t dive into proprietary details, I’ll share the tools, techniques, and challenges I encountered along the way.</p><h3>The Problem: Real-Time Video Streaming and Analysis</h3><p>The goal was to create a system that:</p><ol><li>Captures live video from traffic cameras.</li><li>Converts the video into RTSP streams for processing.</li><li>Analyzes the video using an AI model for real-time insights.</li><li>Delivers the video to a web application for live viewing.</li></ol><p>This required a robust architecture that could handle video ingestion, transformation, analysis, and delivery with minimal latency.</p><h3>The Architecture</h3><p>Here’s a high-level overview of the architecture:</p><ol><li><strong>Traffic Camera Feed</strong>: The source of the live video.</li><li><strong>FFmpeg</strong>: Used to process and transform the video into RTSP streams.</li><li><strong>MediaMTX</strong>: Acts as an RTSP server and WebRTC gateway.</li><li><strong>AI Model</strong>: Analyzes the video stream for insights.</li><li><strong>Web Application</strong>: Displays the live video stream via WebRTC.</li></ol><p>Let’s break down each component.</p><h3>1. Capturing the Traffic Camera Feed</h3><p>Traffic cameras generally output video in formats like H.264 or H.265, often streaming over protocols such as RTSP or HTTP. However, finding freely available feeds that matched my exact requirements proved challenging. After some searching, I stumbled upon a traffic camera feed that used the MJPG format. While this wasn’t my first choice, I knew FFmpeg could handle the conversion, so it wasn’t a major issue.</p><p><strong>Example Video Stream URL</strong>:</p><pre>http://64.191.148.57/mjpg/video.mjpg</pre><p>If your camera doesn’t natively support RTSP, FFmpeg can be a lifesaver. It allows you to capture the feed and convert it into an RTSP stream, making it compatible with your streaming pipeline.</p><h3>2. Processing Video with FFmpeg</h3><p><a href="https://ffmpeg.org/">FFmpeg</a> is a powerful tool for video processing. I used it to:</p><ul><li>Transcode the video into a format suitable for streaming.</li><li>Package the video into an RTSP stream.</li></ul><p><strong>Example FFmpeg Command</strong>:</p><pre>ffmpeg -re -i &lt;http://64.191.148.57/mjpg/video.mjpg&gt; -c:v libx264 -preset ultrafast -tune zerolatency -g 30 -r 30 -f rtsp -rtsp_transport tcp rtsp://localhost:8554/[PATH_FOR_VIDEO_ON_MEDIA_MTX]</pre><h3>What This Command Does</h3><p>This FFmpeg command:</p><ol><li>Takes an MJPEG video stream as input.</li><li>Converts it to H.264 format using the libx264 codec.</li><li>Optimizes the encoding for low latency with ultrafast preset and zerolatency tuning.</li><li>Outputs the video as an RTSP stream over TCP.</li><li>Publishes the stream to the specified RTSP URL.</li></ol><h3>3. Streaming with MediaMTX</h3><p><a href="https://github.com/bluenviron/mediamtx">MediaMTX</a> is a lightweight server that supports RTSP, RTMP, and WebRTC. I used it to:</p><ul><li>Act as an RTSP server for the transformed video stream.</li><li>Convert the RTSP stream into WebRTC for browser-based streaming.</li></ul><p><strong>MediaMTX Configuration</strong>: Below is the MediaMTX configuration file I used:</p><pre>authMethod: jwt<br>authJWTClaimKey: mediamtx_permissions<br>authJWTJWKS: https://example.com/api/auth/fetch-public-key<br>logLevel: debug<br>logDestinations:<br>- stdout<br>api: true<br>apiAddress: &#39;:9997&#39;<br>rtsp: true<br>protocols:<br>- udp<br>- multicast<br>- tcp<br>encryption: &#39;no&#39;<br>rtspAddress: &#39;:8554&#39;<br>paths:<br>all:<br>source: publisher<br>webrtc: true<br>webrtcAddress: &#39;:8889&#39;<br>webrtcAllowOrigin: &#39;*&#39;<br>webrtcHandshakeTimeout: 100s</pre><h3>Key Features</h3><ol><li><strong>JWT Authentication</strong>:</li></ol><ul><li>Uses JWTs for secure access control.</li><li>Verifies tokens using a public key fetched from a JWKS endpoint.</li><li>Permissions are defined in the mediamtx_permissions claim.</li></ul><p><strong>2. Logging</strong>:</p><ul><li>Debug-level logs for troubleshooting.</li><li>Logs are output to the console (stdout).</li></ul><p><strong>3. API</strong>:</p><ul><li>Enables the MediaMTX API on port 9997 for programmatic control.</li></ul><p><strong>4. RTSP Streaming</strong>:</p><ul><li>Supports RTSP over UDP, multicast, and TCP.</li><li>Streams are available on port 8554.</li></ul><p><strong>5. WebRTC Streaming</strong>:</p><ul><li>Enables WebRTC for low-latency browser streaming.</li><li>Streams are available on port 8889.</li><li>Allows connections from any origin () with a 100-second handshake timeout.</li></ul><p>This configuration is just the tip of the iceberg! I will be making a detailed article on this section later on (So help me God.) I will link it here later. It would most likely be a deeper dive into topics like:</p><ul><li><strong>JWT Authentication</strong>: How to generate private/public keys and set up a JWKS endpoint.</li><li><strong>RTSP vs. WebRTC</strong>: Why I decided to use them, and how to set them up. Also would discuss challenges faced here.</li><li><strong>Security Best Practices</strong>: Protecting your streams and API endpoints.</li></ul><p>[Intentionally leaving this space for a link to the future article 🌚]</p><h3>4. Analyzing Video with AI</h3><p>The RTSP stream was fed into an AI model for real-time analysis. The model processed each frame to detect objects, count vehicles, or identify anomalies.</p><p>I will not be able to detail this part for a lot of reasons. 🌚</p><h3>5. Delivering Video to the Web Application with WebRTC</h3><p>To stream the video to a web application, I used WebRTC, which is ideal for low-latency, peer-to-peer communication. MediaMTX made this process straightforward by acting as a WebRTC gateway.</p><p><strong>WebRTC Setup</strong>:</p><ol><li>MediaMTX exposes a WebRTC endpoint at <a href="http://localhost:8889/stream/webrtc.">http://localhost:8889/stream/webrtc.</a></li><li>You can use WebRTC library to connect to this endpoint. Libraries like <a href="https://peerjs.com/">PeerJS</a> or <a href="https://simplewebrtc.com/">SimpleWebRTC</a>.</li></ol><h3>Challenges and Potential Solutions</h3><h3>1. Latency</h3><p>Achieving low latency is critical for real-time streaming. Here’s how I addressed it:</p><ul><li><strong>FFmpeg Optimization</strong>: Used the ultrafast preset to minimize encoding delays.</li><li><strong>MediaMTX Configuration</strong>: Fine-tuned MediaMTX settings for low-latency streaming.</li></ul><h3>2. Scalability</h3><p>Initially, my focus was on getting a single stream working. Now, I’m exploring ways to scale the system to handle multiple streams. Key considerations include:</p><ul><li><strong>Multiple FFmpeg Instances</strong>: Running multiple FFmpeg processes to handle concurrent streams and testing the limits of MediaMTX in terms of the number of streams it can support.</li><li><strong>Load Balancing</strong>: Potentially using a load balancer to distribute traffic across multiple MediaMTX instances, depending on the findings from stress testing.</li><li><strong>AI Scalability</strong>: While not an immediate priority, scaling the AI analysis component to handle multiple streams efficiently will be essential in the future.</li></ul><h3>3. Reliability</h3><p>Reliability hasn’t been a major focus yet. Key steps to improve reliability include:</p><ul><li><strong>Monitoring System</strong>: Implementing a monitoring solution to track the health of the streaming pipeline.</li><li><strong>Automatic Recovery</strong>: Adding logic to automatically restart failed components (e.g., FFmpeg or MediaMTX) and retry connections in case of interruptions.</li></ul><h3>Tools and Resources</h3><p>Here are the tools and documentation I found invaluable:</p><ul><li><a href="https://ffmpeg.org/documentation.html">FFmpeg Documentation</a></li><li><a href="https://github.com/bluenviron/mediamtx">MediaMTX GitHub Repository</a></li><li><a href="https://webrtc.org/">WebRTC API Documentation</a></li></ul><h3>Conclusion</h3><p>Building a real-time video streaming pipeline is a complex but rewarding task. By leveraging tools like FFmpeg, MediaMTX, and WebRTC, I was able to create a system that captures, processes, analyzes, and delivers live video with minimal latency. Whether you’re working with traffic cameras or any other video source, this architecture provides a solid foundation for real-time streaming applications.</p><p>If you’re embarking on a similar project, I hope this article provides a helpful starting point. Feel free to reach out if you have any questions or need further guidance!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=218759743d86" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2021, What a year !]]></title>
            <link>https://medium.com/@gold_olar/2021-what-a-year-f48d01bdd724?source=rss-6051b5e4320b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f48d01bdd724</guid>
            <dc:creator><![CDATA[SAMUEL OLAMIDE]]></dc:creator>
            <pubDate>Sat, 25 Dec 2021 07:26:16 GMT</pubDate>
            <atom:updated>2021-12-25T07:26:16.255Z</atom:updated>
            <content:encoded><![CDATA[<h3>2021, What a year !</h3><p>Here’s me in a car on my way to Ibadan wondering if writing a review this year is the rightest thing to do. First, i search the internet for my 2020 review which I’m sure I wrote but I can’t find it. <br> I either wrote it, and didn’t publish it because it was crap, or i did publish it and took it down when I realised it was crap. Lol.</p><p>Anyways, 2020 ended and I’m sure I was glad 2020 happened. 2021 was a whole lot, and trust me, I’m sure i cant even highlight all of the good things that happened during the year. I guess I’ll summarise it. Just know that the title of this summary is <strong>“2021, I F**KING WON”</strong>.</p><p><strong>THE SUMMARY</strong></p><p>Of course, i lost some things, but let’s start off with the good things in 2021. The year started off with little wins of course</p><ul><li>In January I was able to secure a nice apartment for myself. (This was an upgrade, because i remember I was always squatting with one of my closest guys, Precious Oyewole. (PS:- Precious if you’re reading this, i can never thank you enough for those times. I really appreciate everything)</li><li>Between February and March, i think i was able to furnish my bedroom and my little workspace 😅. (I took baby steps every month till i think it was a little comfy).</li><li>Still in January, I was called back to a startup i resigned from the previous year to come help them add some new features.( i call this a win because I think this gave me some validation that i was doing some things right)</li><li>In June, I and my brother was able to set up a small business for my mum (looking to expand it this coming year hopefully and retire her from teaching finally)</li><li>In August, i think i had my biggest win of the year, I got a SWE job at Bunny Studio after applying for the second time. (Inserts I something something times my monthly i come)</li><li>Yeah, somewhere during the year, I made my first million from writing code.</li><li>Got first class invites to join a team in building myStash.</li><li>Got wished “happy fathers day” by my mum and sisters. Felt absolutely strange, but felt like a win.</li><li>I paid bills effortlessly. (Realised that I went from saving a whole year to get a Mac, to waking up and deciding to buy a mac that morning and going ahead to buy it).</li><li>Made a lot of people happy one way or the other.</li><li>I survived, I won.</li></ul><p>Yep, let’s just get to the un-wins.</p><p><strong>“Ah. Mo ma jiya ni 2021 naa o “</strong></p><ul><li>First, i lost the most money in my life this year. From crypto, to Quintensential, to borrow me I go pay back (na this one pain pass after quintessential), 😹. I actually lost a lot of money this year.</li><li>Had a lot of plans to do a lot of things and i could not do them (things like — releasing articles frequently, taking on more courses, taking more time off work, meeting more people)</li><li>Had about 2 or 3 Japa offers that I declined, so that I can enjoy OAU more” 🥲</li><li>Ended a 4months shy of 5 years relationship. (PS — Don’t text me or her about this, there’s no gist. It’s been a while now and we’ve been healing 👉🏾👈🏾. All you might need to know is that it was kinda a mutual agreement to just go our separate ways. )</li><li>As usual, SAPA also CHOKE GAAAAAAN !!!</li></ul><p>Vote of thanks (Idupe)</p><p>Above all, I’m really grateful to God for everything and my Mum, and to a lot of people. Especially even you reading this.</p><ul><li>Ajayi Jeremiah was definitely my man of the year.</li><li>Doyinsola definitely was my woman of the year.</li><li>I’m greatful for Tairu Abdulmateen, Sushi my Guy !!, iMyke, Paul Amusan, Barakah my love💜, Rakamim (specially helped my EEE course this year), Hashcode for the distant constant motivation. Chief Bright, Please don’t be offended if I don’t mention your name here, you’re actually amazing.</li></ul><p>Now I’m honestly looking into 2022 and I can only see things getting better. I’m not sure if i can meet a target of reaching a half a million valuation next year, but we’ll see. Thanks for reading this boring piece of amazement.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f48d01bdd724" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Call, Apply and Bind in Javascript.]]></title>
            <link>https://medium.com/@gold_olar/understanding-call-apply-and-bind-in-javascript-f05622ff1e25?source=rss-6051b5e4320b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f05622ff1e25</guid>
            <category><![CDATA[call]]></category>
            <category><![CDATA[apply]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[olamide-samuel]]></category>
            <category><![CDATA[bind]]></category>
            <dc:creator><![CDATA[SAMUEL OLAMIDE]]></dc:creator>
            <pubDate>Tue, 19 Nov 2019 16:00:30 GMT</pubDate>
            <atom:updated>2019-11-19T16:00:30.853Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VH9A5D7z0BCZM4CgPGqcLA.png" /><figcaption>Understanding Call apply and bind.</figcaption></figure><p>In this article, I am going to be explaining the concept of using <strong>call(), apply() </strong>and<strong> bind().</strong><br> <br> I have previously explained the basics for determining the values of the <strong>this keyword</strong>. If you have not read that article, Please do so here <a href="https://medium.com/@gold_olar/understanding-the-this-keyword-7040ab48f161">here</a>.</p><p>Now, there are cases where we would want to explicitly set the value of this ourselves. Scenario:</p><figure><img alt="Broken Code" src="https://cdn-images-1.medium.com/max/670/1*r_ZzjBR8j3MKcavDPXBHow.png" /></figure><p>Now in this scenario painted above, the keyword this now refers to the “status object”, but just by reading the code, you know I intended to target the user Object. Now how do I explicitly set the value of this .</p><p>Javascript has three methods to do this using the <strong>call, apply, and bind methods.</strong></p><blockquote><strong>One thing special about this methods is that they can only be used on functions and not by any other data type</strong>.</blockquote><p>Lets take these methods Individually.</p><h3>Call</h3><p>The call method takes as many parameters, but it should be noted that the first parameter must be whatever you want to the value of the <strong>this keyword</strong> to be. The other parameters can be whatever parameters you want to pass into the function which you are changing the value of <strong>this </strong>for.</p><p>Also note that when the call method is used on a function, that method is called immediately.</p><h3>Apply</h3><p>The apply is almost similar to the call method. The only difference is that it takes only two arguments. The first should be whatever you want to the value of the <strong>this keyword</strong> to be and the second argument should be an array of parameters you want to pass into the function which you are changing the value of this for. The apply method also calls the function immediately it is used.</p><h3><strong>Bind</strong></h3><p>The bind method is similar to the call method. The only difference here is that bind does not call the function immediately. Instead, the bind method returns a new function.</p><p><strong>Now, lets fix our broken code using each of these methods.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*VQOPw33yFD-lGxK_jroz9w.png" /><figcaption>Fixing our broken code</figcaption></figure><p>Another interesting thing about these methods is , you can use them to refactor your code and avoid repetition. An instance is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*8bCS6LnTIzMpLsVu9BXuNg.png" /><figcaption>Refactoring our code with call method</figcaption></figure><p>Well , using thees methods seem all the same until we start adding arguments, so i might as well take an example where I pass in arguments into these methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*S4fG2qrK5Jxdb8jtaPA6kw.png" /><figcaption>Using the call and apply method with arguments</figcaption></figure><p>Now there’s something else about the bind method. We can use this bind method when we do not know all the arguments that would be passed into our function. This means we want to add some arguments into the function we are creating now and pass in the other arguments later when we want to call that function. A typical example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*DJcW0ToHXrrQuxa6iIUuKw.png" /></figure><p>I hope with this you have understood the call, apply and bind methods. It might be tricky and its fine to go over it a few more times before it sticks.</p><p>Please do not forget to give me a thumbs up. Bella Ciao.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f05622ff1e25" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the this keyword.]]></title>
            <link>https://medium.com/@gold_olar/understanding-the-this-keyword-7040ab48f161?source=rss-6051b5e4320b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7040ab48f161</guid>
            <category><![CDATA[this]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[olamide-samuel]]></category>
            <dc:creator><![CDATA[SAMUEL OLAMIDE]]></dc:creator>
            <pubDate>Mon, 18 Nov 2019 15:16:49 GMT</pubDate>
            <atom:updated>2020-06-20T23:36:19.381Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*rF3lrbcXjPNp19D5u_in_Q.png" /><figcaption>This in Javascript</figcaption></figure><p>Okay before I start , I’ll like to talk a little. So if you came strictly for business, jump to the next section. So this is my first article, I hope it turns out well. I was assigned to come up with daily quizzes in a Js community for a week. So I figured , why not write articles to explain each concept I set a question on. This means I might just be writing articles for every day this week. If you think I did good with this article, please give me a thumbs up. It would be encouraging.</p><p>In this article I am going to explain about Javascript keyword <strong>this</strong> and how the value of <strong>this</strong> is assigned in different cases.</p><p><strong>Okay Straight to business.</strong></p><p>The this keyword in Js has to be one of the tricky things I have had to understand. so i thought why not make an article to explain to others.</p><p>Understanding <strong>Execution Context.</strong></p><p>When you run a javascript code, the interpreter reads the code and executes it line by line. The scope in which the line is being executed is know as <strong>Execution Context</strong>. As you know, javascript represents almost everything as objects (everything asides primitive values like Strings, Booleans, Numbers), so the object that “this” refers changes every time execution context is changed.</p><p>On default, the execution context for an execution is global context. this means that in a simple function call, then <strong>this</strong> refers to the global object which is the window object when you run your code in a browser. Illustration below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*8qZqf_MM7_v4fQoE7jyXuw.png" /><figcaption>this referring to the window object</figcaption></figure><p><strong>this</strong> can also refer to the object in which it is in (the parent object).In Js, the properties of an object can either be a value, or a method(a function). When an Object’s method is called, then <strong>this</strong> refers to the object which contains the method being called.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*KBcob6wmzx5n1yTYNi6I5A.png" /><figcaption>this referring to parent object.</figcaption></figure><p>Now, as we all know constructor functions, while writing constructor functions, we make use of the <strong>this </strong>key word. In this case, the value of this refers to the object being created from the constructor function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*nD4C5QVV93gBTM3izyykdg.png" /><figcaption>this referring to object created from constructor function</figcaption></figure><p>However, there is something called strict mode in Javascript. If <strong>strict mode</strong> is enabled for any function then the value of <strong>this</strong> will be <strong>undefined. </strong>In strict mode, global object refers to <strong>undefined</strong> instead of the windows object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*XUer4wb3A9aOnFmeiaLvwg.png" /><figcaption>this referring to undefined in strict mode</figcaption></figure><p>With this, I hope you have been able to understand the basics of what the <strong>this</strong> keyword refers to by just observing the execution context.</p><p>In the nearest future, I hope to introduce more tricky concepts. Stay tuned. Don’t forget to give me a thumbs up.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7040ab48f161" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>