]> git.sesse.net Git - nageru/blobdiff - nageru/mixer.cpp
When exporting interpolated files, make sure they are seekable.
[nageru] / nageru / mixer.cpp
index 953fd8133db59410ab2973d7592a05e5d133bc09..c25b22dc711fa528c2720493504f9bebcfe12f3b 100644 (file)
@@ -358,7 +358,9 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
        display_chain->finalize();
 
        video_encoder.reset(new VideoEncoder(resource_pool.get(), h264_encoder_surface, global_flags.va_display, global_flags.width, global_flags.height, &httpd, global_disk_space_estimator));
-       mjpeg_encoder.reset(new MJPEGEncoder(&httpd, global_flags.va_display));
+       if (!global_flags.card_to_mjpeg_stream_export.empty()) {
+               mjpeg_encoder.reset(new MJPEGEncoder(&httpd, global_flags.va_display));
+       }
 
        // Must be instantiated after VideoEncoder has initialized global_flags.use_zerocopy.
        theme.reset(new Theme(global_flags.theme_filename, global_flags.theme_dirs, resource_pool.get(), num_cards));
@@ -502,7 +504,9 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
 
 Mixer::~Mixer()
 {
-       mjpeg_encoder->stop();
+       if (mjpeg_encoder != nullptr) {
+               mjpeg_encoder->stop();
+       }
        httpd.stop();
        BMUSBCapture::stop_bm_thread();
 
@@ -794,7 +798,7 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode,
 
        size_t cbcr_width, cbcr_height, cbcr_offset, y_offset;
        size_t expected_length = video_format.stride * (video_format.height + video_format.extra_lines_top + video_format.extra_lines_bottom);
-       if (userdata != nullptr && userdata->pixel_format == PixelFormat_8BitYCbCrPlanar) {
+       if (userdata->pixel_format == PixelFormat_8BitYCbCrPlanar) {
                // The calculation above is wrong for planar Y'CbCr, so just override it.
                assert(card->type == CardType::FFMPEG_INPUT);
                assert(video_offset == 0);
@@ -1071,12 +1075,13 @@ void Mixer::thread_func()
                                new_frame->upload_func = nullptr;
                        }
 
-                       // There are situations where we could possibly want to
-                       // include FFmpeg inputs (CEF inputs are unlikely),
-                       // but they're not necessarily in 4:2:2 Y'CbCr, so it would
-                       // require more functionality the the JPEG encoder.
-                       if (card_index < num_cards) {
-                               mjpeg_encoder->upload_frame(pts_int, card_index, new_frame->frame, new_frame->video_format, new_frame->y_offset, new_frame->cbcr_offset);
+                       // Only bother doing MJPEG encoding if there are any connected clients
+                       // that want the stream.
+                       if (httpd.get_num_connected_multicam_clients() > 0) {
+                               auto stream_it = global_flags.card_to_mjpeg_stream_export.find(card_index);
+                               if (stream_it != global_flags.card_to_mjpeg_stream_export.end()) {
+                                       mjpeg_encoder->upload_frame(pts_int, stream_it->second, new_frame->frame, new_frame->video_format, new_frame->y_offset, new_frame->cbcr_offset);
+                               }
                        }
                }