{"id":4711,"date":"2022-05-02T19:34:38","date_gmt":"2022-05-02T17:34:38","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=4711"},"modified":"2025-09-24T12:52:02","modified_gmt":"2025-09-24T10:52:02","slug":"arduino-esp32-audio-streaming-with-rtsp","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/","title":{"rendered":"Arduino ESP32 Audio Streaming with RTSP!"},"content":{"rendered":"<p>Recently I discovered the <a href=\"https:\/\/github.com\/Tomp0801\/Micro-RTSP-Audio\">Micro-RTSP-Audio Project<\/a> from <a href=\"https:\/\/github.com\/Tomp0801\">Thomas Pfitzinger<\/a> which is based on <a href=\"https:\/\/github.com\/geeksville\/Micro-RTSP\">Micro-RTSP<\/a> from <a href=\"https:\/\/github.com\/geeksville\">Kevin Hester<\/a>.<\/p>\n<p>The <strong>Real Time Streaming Protocol<\/strong> (RTSP) is an application-level network communication system that transfers real-time data from multimedia to an endpoint device by communicating directly with the server streaming the data.<\/p>\n<p>I tried to adapt the library to make sure that it is also compiling in <strong>Arduino<\/strong> and converted the <strong>example<\/strong> to comply with the Arduino conventions. However when I started to test it, I was running into <strong>memory errors<\/strong> and I spent almost a full day looking at the source code trying to figure out what could be wrong and while doing this, I took the chance to perform some optimizations.<\/p>\n<p>In the end it turned out that the issue was not in the library code but in the provided example: some objects where allocated on the stack and after the setup method, these objects were not valid any more!<\/p>\n<p>My <a href=\"https:\/\/github.com\/pschatzmann\/Micro-RTSP-Audio\">updated Micro-RTSP-Audio Library<\/a> can be found on Github and the example is working now and I am providing an nice integration into my <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\">Audio Tools Library<\/a>:<\/p>\n<h3>Arduino Sketch<\/h3>\n<pre><code>#include \"AudioTools.h\"\n#include \"AudioLibs\/RTSPStream.h\"\n#include \"AudioStreamer.h\"\n#include \"RTSPServer.h\"\n\nint port = 554;\nint channels = 1;\nint sample_rate = 16000;\nint bits_per_sample = 16;\nconst char* wifi = \"wifi\";\nconst char* password = \"password\";\n\nSineFromTable&lt;int16_t&gt; sineWave(32000);                \/\/ subclass of SoundGenerator \nGeneratedSoundStream&lt;int16_t&gt; sound(sineWave);             \/\/ Stream generated from sine wave\nRTSPSourceAudioStream source(sound);                       \/\/ Stream sound via RTSP\nAudioStreamer streamer = AudioStreamer(&amp;source);\nRTSPServer rtsp = RTSPServer(&amp;streamer, port);\n\n\nvoid setup() {\n  Serial.begin(115200);\n  AudioLogger::instance().begin(Serial, AudioLogger::Info);\n\n  \/\/ Setup sine wave\n  auto cfgS = sineWave.defaultConfig();\n  cfgS.channels = channels;\n  cfgS.sample_rate = sample_rate;\n  cfgS.bits_per_sample = bits_per_sample;\n  sineWave.begin(cfgS, N_B4);\n\n  \/\/ Start Wifi &amp; RTSP\n  rtsp.begin(wifi, password);\n}\n\nvoid loop() { delay(1000); }\n<\/code><\/pre>\n<p>This (potentially updated) example can be found on <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\/blob\/main\/examples\/examples-communication\/rtsp\/communication-generator-rtsp\/communication-generator-rtsp.ino\">Github<\/a>.<\/p>\n<p>To listen to the generated sound you can use the <a href=\"https:\/\/www.videolan.org\/vlc\/\">VLC Media Player<\/a>. Goto -> File -> Open Network and enter the URL <strong>rtsp:\/\/server-address<\/strong><\/p>\n<p><strong>Caveat<\/strong>: Please note that currently <em>only the sampling rate 16000 with 1 channel is supported<\/em>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I discovered the Micro-RTSP-Audio Project from Thomas Pfitzinger which is based on Micro-RTSP from Kevin Hester. The Real Time Streaming Protocol (RTSP) is an application-level network communication system that transfers real-time data from multimedia to an endpoint device by communicating directly with the server streaming the data. I tried [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4712,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[20,22],"tags":[46,61],"class_list":["post-4711","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-machine-sound","tag-communications","tag-rtsp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Arduino ESP32 Audio Streaming with RTSP! - Phil Schatzmann<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Arduino ESP32 Audio Streaming with RTSP! - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"Recently I discovered the Micro-RTSP-Audio Project from Thomas Pfitzinger which is based on Micro-RTSP from Kevin Hester. The Real Time Streaming Protocol (RTSP) is an application-level network communication system that transfers real-time data from multimedia to an endpoint device by communicating directly with the server streaming the data. I tried [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-02T17:34:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-24T10:52:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/05\/images.png\" \/>\n\t<meta property=\"og:image:width\" content=\"260\" \/>\n\t<meta property=\"og:image:height\" content=\"194\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"pschatzmann\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"pschatzmann\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/02\\\/arduino-esp32-audio-streaming-with-rtsp\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/02\\\/arduino-esp32-audio-streaming-with-rtsp\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"Arduino ESP32 Audio Streaming with RTSP!\",\"datePublished\":\"2022-05-02T17:34:38+00:00\",\"dateModified\":\"2025-09-24T10:52:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/02\\\/arduino-esp32-audio-streaming-with-rtsp\\\/\"},\"wordCount\":240,\"commentCount\":22,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/02\\\/arduino-esp32-audio-streaming-with-rtsp\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/images.png\",\"keywords\":[\"Communications\",\"RTSP\"],\"articleSection\":[\"Arduino\",\"Machine Sound\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/02\\\/arduino-esp32-audio-streaming-with-rtsp\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/02\\\/arduino-esp32-audio-streaming-with-rtsp\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/02\\\/arduino-esp32-audio-streaming-with-rtsp\\\/\",\"name\":\"Arduino ESP32 Audio Streaming with RTSP! - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/02\\\/arduino-esp32-audio-streaming-with-rtsp\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/02\\\/arduino-esp32-audio-streaming-with-rtsp\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/images.png\",\"datePublished\":\"2022-05-02T17:34:38+00:00\",\"dateModified\":\"2025-09-24T10:52:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/02\\\/arduino-esp32-audio-streaming-with-rtsp\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/02\\\/arduino-esp32-audio-streaming-with-rtsp\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/02\\\/arduino-esp32-audio-streaming-with-rtsp\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/images.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/images.png\",\"width\":260,\"height\":194},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/05\\\/02\\\/arduino-esp32-audio-streaming-with-rtsp\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Arduino ESP32 Audio Streaming with RTSP!\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\",\"name\":\"Phil Schatzmann Consulting\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\",\"name\":\"pschatzmann\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"width\":305,\"height\":305,\"caption\":\"pschatzmann\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Arduino ESP32 Audio Streaming with RTSP! - Phil Schatzmann","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/","og_locale":"en_US","og_type":"article","og_title":"Arduino ESP32 Audio Streaming with RTSP! - Phil Schatzmann","og_description":"Recently I discovered the Micro-RTSP-Audio Project from Thomas Pfitzinger which is based on Micro-RTSP from Kevin Hester. The Real Time Streaming Protocol (RTSP) is an application-level network communication system that transfers real-time data from multimedia to an endpoint device by communicating directly with the server streaming the data. I tried [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/","og_site_name":"Phil Schatzmann","article_published_time":"2022-05-02T17:34:38+00:00","article_modified_time":"2025-09-24T10:52:02+00:00","og_image":[{"width":260,"height":194,"url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/05\/images.png","type":"image\/png"}],"author":"pschatzmann","twitter_card":"summary_large_image","twitter_misc":{"Written by":"pschatzmann","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"Arduino ESP32 Audio Streaming with RTSP!","datePublished":"2022-05-02T17:34:38+00:00","dateModified":"2025-09-24T10:52:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/"},"wordCount":240,"commentCount":22,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/05\/images.png","keywords":["Communications","RTSP"],"articleSection":["Arduino","Machine Sound"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/","url":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/","name":"Arduino ESP32 Audio Streaming with RTSP! - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/#primaryimage"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/05\/images.png","datePublished":"2022-05-02T17:34:38+00:00","dateModified":"2025-09-24T10:52:02+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/#primaryimage","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/05\/images.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/05\/images.png","width":260,"height":194},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/05\/02\/arduino-esp32-audio-streaming-with-rtsp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"Arduino ESP32 Audio Streaming with RTSP!"}]},{"@type":"WebSite","@id":"https:\/\/www.pschatzmann.ch\/home\/#website","url":"https:\/\/www.pschatzmann.ch\/home\/","name":"Phil Schatzmann Consulting","description":"","publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pschatzmann.ch\/home\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1","name":"pschatzmann","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","width":305,"height":305,"caption":"pschatzmann"},"logo":{"@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png"}}]}},"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/4711","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/comments?post=4711"}],"version-history":[{"count":19,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/4711\/revisions"}],"predecessor-version":[{"id":4715,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/4711\/revisions\/4715"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media\/4712"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=4711"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=4711"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=4711"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}