Timing-Problem beim Aufzeichnen mehrerer RTSP-Streams über 720pC++

Programme in C++. Entwicklerforum
Guest
 Timing-Problem beim Aufzeichnen mehrerer RTSP-Streams über 720p

Post by Guest »

Suche nach Tipps zur Optimierung meines RTSP-Stream-Capture-Projekts.
Das Ziel: Den Stream kontinuierlich in 30-Sekunden-Blöcken erfassen.
Das Problem : Die Gesamtzeit ist inkonsistent, wenn die Last zunimmt. 1x Kamera mit 720p ist in Ordnung, mehr Kamera oder eine höhere Auflösung und das Problem beginnt.
Ich vermute, dass es video_output.write(frame); ist, was zu einem Stottern des Geräts führt. Ich bin gespannt auf Ideen oder Einblicke, wie dieses Problem gelöst werden könnte.
Vielleicht starte ich zu viele Threads? aber die Threadzahl liegt erst dann bei etwa 600, wenn alles in Gang ist. Oder vielleicht in einen Puffer schreiben und anschließend auf die Festplatte schreiben?
Dieser Codeblock initialisiert die Erfassung:

Code: Select all

    for (CameraConfig cam : config.cam_list)
{
threads.emplace_back([&, cam]()
{
int iteration = 1;
auto base_start_time = std::chrono::steady_clock::now();

while (true)
{
auto next_chunk_start_time = base_start_time + std::chrono::milliseconds(30000 * iteration);

std::thread recording_thread([&, next_chunk_start_time]()
{
long int start_time_epoch = std::chrono::duration_cast(
std::chrono::system_clock::now().time_since_epoch()
).count();

// record a chunk
auto result = rtsp_record(config, cam, start_time_epoch);

// if recording was interrupted then attempt to reconnect
if (std::get(result).empty())
{
// return and wait for the next iteration if disconnected
if (!reconnectCamera(cam))
{
return;
}

// there was another reason why the capture failed
return;
}
else
{
// recording was successful process the results
std::string video_file = std::get(result);
int frame_width = std::get(result);
int frame_height = std::get(result);
std::string ts_file = std::get(result);
double length  = std::get(result);

std::thread checksum_and_upload_thread([&]()
{
generate_checksum_and_upload(
video_file,
config,
cam,
availableBandwidth
);
});

checksum_and_upload_thread.join();
}
});

// testing
// recording_thread.join();
// break;

recording_thread.detach();

std::this_thread::sleep_until(next_chunk_start_time);
++iteration;
}
});
}

Der Codeblock, der die Erfassung durchführt

Code: Select all

    int frame_width = static_cast(cap.get(cv::CAP_PROP_FRAME_WIDTH));
int frame_height = static_cast(cap.get(cv::CAP_PROP_FRAME_HEIGHT));

cv::VideoWriter video_output(
construct_file_path,
cv::VideoWriter::fourcc('a', 'v', 'c', '1'),
15,
cv::Size(frame_width, frame_height),
true
);

std::cout

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post
  • Streaming über RTSP oder RTP in HTML5
    by Anonymous » » in HTML
    0 Replies
    9 Views
    Last post by Anonymous
  • Youtube to HTML5 Loader erzwingt 720p mit Audio
    by Guest » » in HTML
    0 Replies
    8 Views
    Last post by Guest
  • Konvertieren Sie 720p MP4 bis 480p mit PHP FFMPEG
    by Anonymous » » in Php
    0 Replies
    8 Views
    Last post by Anonymous
  • Python -Animations -Timing funktioniert nicht richtig
    by Anonymous » » in Python
    0 Replies
    6 Views
    Last post by Anonymous
  • Python -Animations -Timing funktioniert nicht richtig
    by Anonymous » » in Python
    0 Replies
    5 Views
    Last post by Anonymous