|
7 | 7 | #include <stdlib.h> |
8 | 8 | #include <string.h> |
9 | 9 | #include <string> |
| 10 | +#include <sstream> |
10 | 11 | #include <sys/types.h> |
11 | 12 | #include <sys/wait.h> |
12 | 13 | #include <thread> |
@@ -494,12 +495,22 @@ int main(int argc, char **argv) { |
494 | 495 | setenv("FPVUE_RESERVED_PLANE_IDS", reserved_planes, 1); |
495 | 496 | } |
496 | 497 |
|
497 | | - std::string pipeline_command = |
498 | | - std::string("gst-launch-1.0 -q filesrc location=") + debug_sample_path + |
499 | | - " ! qtdemux name=demux demux.video_0 ! h264parse config-interval=1 " |
500 | | - "! video/x-h264,stream-format=byte-stream,alignment=au ! queue ! omxh264dec ! " |
501 | | - "videoconvert ! video/x-raw,format=NV12,width=1280,height=720 ! queue ! fdsink fd=1 sync=false | " |
502 | | - "fpvue --screen-mode 1280x720@60 --stdin-nv12"; |
| 498 | + // Attempt to use platform-specific hardware decoders first and fall back to a |
| 499 | + // software decoder if negotiation keeps failing. |
| 500 | + std::ostringstream pipeline_builder; |
| 501 | + pipeline_builder << "run_decoder() {\n" |
| 502 | + << " decoder=\"$1\";\n" |
| 503 | + << " echo \"Attempting debug decode with $decoder\" >&2;\n" |
| 504 | + << " gst-launch-1.0 -q filesrc location=" << debug_sample_path |
| 505 | + << " ! qtdemux name=demux demux.video_0 ! h264parse config-interval=1" |
| 506 | + << " ! video/x-h264,stream-format=byte-stream,alignment=au ! queue ! \"$decoder\"" |
| 507 | + << " ! videoconvert ! video/x-raw,format=NV12,width=1280,height=720 ! queue ! fdsink fd=1 sync=false;\n" |
| 508 | + << "}\n" |
| 509 | + << "(run_decoder omxh264dec || run_decoder mppvideodec || run_decoder avdec_h264)"; |
| 510 | + |
| 511 | + std::string pipeline_command = "("; |
| 512 | + pipeline_command += pipeline_builder.str(); |
| 513 | + pipeline_command += ") | fpvue --screen-mode 1280x720@60 --stdin-nv12"; |
503 | 514 |
|
504 | 515 | execlp("sh", "sh", "-c", pipeline_command.c_str(), (char *)NULL); |
505 | 516 | perror("execlp sample video pipeline"); |
|
0 commit comments