From ef1360c5058fd741893cd60a28f2754dd997357f Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Sat, 16 May 2020 09:43:04 +0300
Subject: [PATCH] Fix ftl2mkv for h264

---
 applications/ftl2mkv/src/main.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/applications/ftl2mkv/src/main.cpp b/applications/ftl2mkv/src/main.cpp
index d86f32428..665de6562 100644
--- a/applications/ftl2mkv/src/main.cpp
+++ b/applications/ftl2mkv/src/main.cpp
@@ -4,6 +4,7 @@
 #include <ftl/codecs/packet.hpp>
 #include <ftl/rgbd/camera.hpp>
 #include <ftl/codecs/hevc.hpp>
+#include <ftl/codecs/h264.hpp>
 
 #include <fstream>
 
@@ -144,7 +145,7 @@ int main(int argc, char **argv) {
         if (spkt.channel != static_cast<ftl::codecs::Channel>(current_channel) && current_channel != -1) return;
         if (spkt.frame_number == current_stream || current_stream == 255) {
 
-            if (pkt.codec != codec_t::HEVC) {
+            if (pkt.codec != codec_t::HEVC && pkt.codec != codec_t::H264) {
                 return;
             }
 
@@ -175,7 +176,7 @@ int main(int argc, char **argv) {
         if (spkt.channel != static_cast<ftl::codecs::Channel>(current_channel) && current_channel != -1) return;
         if (spkt.frame_number == current_stream || current_stream == 255) {
 
-            if (pkt.codec != codec_t::HEVC) {
+            if (pkt.codec != codec_t::HEVC && pkt.codec != codec_t::H264) {
                 return;
             }
 
@@ -189,6 +190,11 @@ int main(int argc, char **argv) {
 					seen_key[spkt.frame_number] = true;
 					keyframe = true;
 				}
+			} else if (pkt.codec == codec_t::H264) {
+				if (ftl::codecs::h264::isIFrame(pkt.data.data(), pkt.data.size())) {
+					seen_key[spkt.frame_number] = true;
+					keyframe = true;
+				}
 			}
 			if (!seen_key[spkt.frame_number]) return;
 
-- 
GitLab