Video stream

Dear all,

I am trying using this code to get video from Esp32 Cam
and I have the following error: Undefined reference to “startCameraServer”
Could somebody help me with this?

#define BLYNK_TEMPLATE_ID     "hhhhhhhh"
#define BLYNK_TEMPLATE_NAME   "gfgfgfgfg"
#define BLYNK_AUTH_TOKEN      "rerererererererererrererer"
char auth[] =  "rererererererererererererere";

// Your WiFi credentials.
// Set password to "" for open networks.
#define WIFI_SSID             "xxxxx"
#define WIFI_PASS             "yyyyyyyy"

#define BLYNK_PRINT Serial  // Comment this out to disable serial monitor prints

// Adding the required libraries
#include "esp_camera.h"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>


#define CAMERA_MODEL_AI_THINKER // Has PSRAM


#include "camera_pins.h"

String local_IP;

void startCameraServer();

void setup() {
  Serial.begin(115200);
  Serial.setDebugOutput(true);
  Serial.println();

  camera_config_t config;
  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = Y2_GPIO_NUM;
  config.pin_d1 = Y3_GPIO_NUM;
  config.pin_d2 = Y4_GPIO_NUM;
  config.pin_d3 = Y5_GPIO_NUM;
  config.pin_d4 = Y6_GPIO_NUM;
  config.pin_d5 = Y7_GPIO_NUM;
  config.pin_d6 = Y8_GPIO_NUM;
  config.pin_d7 = Y9_GPIO_NUM;
  config.pin_xclk = XCLK_GPIO_NUM;
  config.pin_pclk = PCLK_GPIO_NUM;
  config.pin_vsync = VSYNC_GPIO_NUM;
  config.pin_href = HREF_GPIO_NUM;
  config.pin_sscb_sda = SIOD_GPIO_NUM;
  config.pin_sscb_scl = SIOC_GPIO_NUM;
  config.pin_pwdn = PWDN_GPIO_NUM;
  config.pin_reset = RESET_GPIO_NUM;
  config.xclk_freq_hz = 20000000;
  config.pixel_format = PIXFORMAT_JPEG;
  
  // if PSRAM IC present, init with UXGA resolution and higher JPEG quality
  //                      for larger pre-allocated frame buffer.
  if(psramFound()){
    config.frame_size = FRAMESIZE_UXGA;
    config.jpeg_quality = 10;
    config.fb_count = 2;
  } else {
    config.frame_size = FRAMESIZE_SVGA;
    config.jpeg_quality = 12;
    config.fb_count = 1;
  }

#if defined(CAMERA_MODEL_ESP_EYE)
  pinMode(13, INPUT_PULLUP);
  pinMode(14, INPUT_PULLUP);
#endif

  // camera init
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed with error 0x%x", err);
    return;
  }

  sensor_t * s = esp_camera_sensor_get();
  // initial sensors are flipped vertically and colors are a bit saturated
  if (s->id.PID == OV3660_PID) {
    s->set_vflip(s, 1); // flip it back
    s->set_brightness(s, 1); // up the brightness just a bit
    s->set_saturation(s, -2); // lower the saturation
  }
  // drop down frame size for higher initial frame rate
  s->set_framesize(s, FRAMESIZE_QVGA);

#if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM)
  s->set_vflip(s, 1);
  s->set_hmirror(s, 1);
#endif

  WiFi.begin(WIFI_SSID, WIFI_PASS);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  startCameraServer();

  Serial.print("Camera Ready! Use 'http://");
  Serial.print(WiFi.localIP());
  local_IP = WiFi.localIP().toString();
  Serial.println("' to connect");
  Blynk.begin(auth, WIFI_SSID, WIFI_PASS, "blynk.cloud");
}

BLYNK_CONNECTED()
{
  //Url with video streaming will set to V8 pin
 Blynk.setProperty(V8, "url", "http://"+local_IP+":81/stream");

}



void loop() {
  Blynk.run();  
  // put your main code here, to run repeatedly:  
}

You’ve declared a function prototype for the startCameraServer() function…

but you don’t actually have a startCameraServer() function.

Of course you have haven’t posted your camera_pins.h file, so we’re only seeing part of your code.

Pete.

You are correct, this is my camera_pins.h:


#if defined(CAMERA_MODEL_WROVER_KIT)
#define PWDN_GPIO_NUM    -1
#define RESET_GPIO_NUM   -1
#define XCLK_GPIO_NUM    21
#define SIOD_GPIO_NUM    26
#define SIOC_GPIO_NUM    27

#define Y9_GPIO_NUM      35
#define Y8_GPIO_NUM      34
#define Y7_GPIO_NUM      39
#define Y6_GPIO_NUM      36
#define Y5_GPIO_NUM      19
#define Y4_GPIO_NUM      18
#define Y3_GPIO_NUM       5
#define Y2_GPIO_NUM       4
#define VSYNC_GPIO_NUM   25
#define HREF_GPIO_NUM    23
#define PCLK_GPIO_NUM    22

#elif defined(CAMERA_MODEL_ESP_EYE)
#define PWDN_GPIO_NUM    -1
#define RESET_GPIO_NUM   -1
#define XCLK_GPIO_NUM    4
#define SIOD_GPIO_NUM    18
#define SIOC_GPIO_NUM    23

#define Y9_GPIO_NUM      36
#define Y8_GPIO_NUM      37
#define Y7_GPIO_NUM      38
#define Y6_GPIO_NUM      39
#define Y5_GPIO_NUM      35
#define Y4_GPIO_NUM      14
#define Y3_GPIO_NUM      13
#define Y2_GPIO_NUM      34
#define VSYNC_GPIO_NUM   5
#define HREF_GPIO_NUM    27
#define PCLK_GPIO_NUM    25

#elif defined(CAMERA_MODEL_M5STACK_PSRAM)
#define PWDN_GPIO_NUM     -1
#define RESET_GPIO_NUM    15
#define XCLK_GPIO_NUM     27
#define SIOD_GPIO_NUM     25
#define SIOC_GPIO_NUM     23

#define Y9_GPIO_NUM       19
#define Y8_GPIO_NUM       36
#define Y7_GPIO_NUM       18
#define Y6_GPIO_NUM       39
#define Y5_GPIO_NUM        5
#define Y4_GPIO_NUM       34
#define Y3_GPIO_NUM       35
#define Y2_GPIO_NUM       32
#define VSYNC_GPIO_NUM    22
#define HREF_GPIO_NUM     26
#define PCLK_GPIO_NUM     21

#elif defined(CAMERA_MODEL_M5STACK_WIDE)
#define PWDN_GPIO_NUM     -1
#define RESET_GPIO_NUM    15
#define XCLK_GPIO_NUM     27
#define SIOD_GPIO_NUM     22
#define SIOC_GPIO_NUM     23

#define Y9_GPIO_NUM       19
#define Y8_GPIO_NUM       36
#define Y7_GPIO_NUM       18
#define Y6_GPIO_NUM       39
#define Y5_GPIO_NUM        5
#define Y4_GPIO_NUM       34
#define Y3_GPIO_NUM       35
#define Y2_GPIO_NUM       32
#define VSYNC_GPIO_NUM    25
#define HREF_GPIO_NUM     26
#define PCLK_GPIO_NUM     21

#elif defined(CAMERA_MODEL_AI_THINKER)
#define PWDN_GPIO_NUM     32
#define RESET_GPIO_NUM    -1
#define XCLK_GPIO_NUM      0
#define SIOD_GPIO_NUM     26
#define SIOC_GPIO_NUM     27

#define Y9_GPIO_NUM       35
#define Y8_GPIO_NUM       34
#define Y7_GPIO_NUM       39
#define Y6_GPIO_NUM       36
#define Y5_GPIO_NUM       21
#define Y4_GPIO_NUM       19
#define Y3_GPIO_NUM       18
#define Y2_GPIO_NUM        5
#define VSYNC_GPIO_NUM    25
#define HREF_GPIO_NUM     23
#define PCLK_GPIO_NUM     22

#else
#error "Camera model not selected"
#endif

So you’re still missing the startCameraServer() function.

You should go back to the original place where you found this sketch and see what you’ve missed-out.

Pete.

Obviously I’m completely lost with this project. There are almost no examples available with Blynk 2.0. I copied sketch described in: How can I connect to bylnk with esp32 cam? - #5 by Oleksii-QA
Where can I get startCameraServer() function?
Thanks in advance

TBH, you don’t need any Blynk code in the sketch running on the ESP32 CAM, as its only purpose is to provide a video stream.

Once you have this working it’s just the beginning of your problem, as you need to make the video stream publicly resolvable. Which most likely requires a DDNS service and DDNS updater client, and port-forwarding set-up in your router.
The solution will depend on a number of factors including your ISP and router, so there isn’t a simple set of instructions that you can follow.

Pete.

Ok, I already understand the complexity of the whole thing. What I don’t understand is how some people make it look easy. Even with the old Blynk I never got video images following examples still available today on YouTube. It never worked for me, it always gave an error.

It’s not that easy, but it’s straightforward when you understand what needs to be done.
I display video from CCTV camera on my home network in the Blynk video streaming widget, but as I said I use DDNS, an update client and have port forwarding set-up to allow this to work.

Pete.

Just one more thing,
Is there some simple post to help me put a simple video M3U8 format to work with Blynk?

Thanks

M3U8 is an audio playlist format. How do you envisage that working with Blynk?

Pete.

I would like to see this video stream working, even if it is in the simplest way possible. So from what I saw in Blynk documentation, the URL must be of the M3U8 format type. So I simply tried putting a video with this format on the web dasboard, choosing a virtual pin for stream and then repeating the same thing on the iPhone. It seems like I did everything right but the device remains offline.

That’s not what the documentation says. It says that it allows you to play videos contained within an M3U8 playlist, but that’s making the whole process far more complex from your point of view.

How have you placed a video playlist on the web dashboard?

What you’ve described isn’t right as far as I’m concerned.

I think you’d be better off going back to basics and explaining if your goal is still to stream video from your ESP32 CAM, and if it is then work on DDNS and an updater and port forwarding.

Pete.

My ultimate goal is to transmit video from the Esp32 Cam. However, I want to do something simpler first. For example, transmitting a simple video to be watched on the iPhone. This should be very simple and easy, right?

If the video is coming from within your home network then it’s just as complex as the ESP32 CAM stream.
If you’re hosting the video somewhere in the cloud then a lot depends on whether the URL to that video is useable by the widget. I know some file sharing sites aren’t useable by the widget.

Pete.

I understand the situation perfectly. I’m not using home video. I am using a video available on the Internet in M3U8 format. When I put it on the Blynk web dashboard it works perfectly. But I can’t make it work on the iPhone. The Blynk device simply remains offline.
I don’t understand why it’s not working. This should be the simplest procedure for using video streaming. You don’t need any physical device. I just want to start selling a video available on the internet.

The device will never appear online in either the web dashboard or the mobile dashboard simply by pointing a widget to a video stream. The on/offline status comes from having a board running Blynk code with the auth token and template ID used to negotiate a connection with the server.

The web dashboard widget works differently from the app widget.

I don’t see how any of this is going to help you with your ESP32 CAM project.

Pete.

ok, now I’m going to learn something: Are you telling me that without a board directed to an autotoken there isn’t one online?
In this case, how about just transmitting a simple video available on the internet? Shouldn’t this be possible without any physical device?
In fact, this doesn’t help much with the Esp32 Cam. It has become more of an adjacent curiosity.

Yes

Correct. As I said here…

The device is simply a way to broadcast a video stream…

Obviously these cameras don’t run any Blynk code and don’t have a Blynk auth token or template ID.

Getting the ESP32 CAM to output a video stream that you can view in a web browser is easy - just find some example (non Blynk) code and get ot working.
Getting that video to display in the mobile widget requires much more work with DDNS and port forwarding, as I’ve already said.

Pete.

Ok, I think I’m clear on a lot of things now. I can already get the Esp cam video via the local server. I’m ready to move on to the second part. Do you suggest any tutorials or posts?
Thanks for your patience…

None of this is Blynk related, so there are plenty of guides out there.
I have posted several explanations of what needs to be done (in general terms) so searching for post by me with the keywords ESP32 CAM or video streaming widget will point you in the right direction.

I use DuckDNS which is a free DDNS service, but NoIP.com is also okay.
Your router may be able to do DDNS updates, but personally I prefer to run an update client on a device within my network.

This website attempts to provide an overview of port forwarding, along with details of many popular routers and how to configure them…

Pete.