From fa5f60c44f4f38ec85a08fe14032e473b17755ca Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 9 Jun 2018 11:40:16 +0200 Subject: [PATCH] Add a script for grabbing some example multiangle data off of YouTube. --- main.cpp | 12 ++++++-- make-example-video.sh | 8 ++++++ ui_mainwindow.ui | 66 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 make-example-video.sh diff --git a/main.cpp b/main.cpp index 0a976c3..526ed57 100644 --- a/main.cpp +++ b/main.cpp @@ -53,12 +53,14 @@ int main(int argc, char **argv) int thread_func() { - auto format_ctx = avformat_open_input_unique("example.mp4", nullptr, nullptr); + auto format_ctx = avformat_open_input_unique("multiangle.mp4", nullptr, nullptr); if (format_ctx == nullptr) { fprintf(stderr, "%s: Error opening file\n", "example.mp4"); return 1; } + int64_t last_pts = -1; + for ( ;; ) { AVPacket pkt; unique_ptr pkt_cleanup( @@ -85,13 +87,19 @@ int thread_func() global_mainwindow->ui->input1_display->setFrame(pkt.stream_index, pkt.pts); } else if (pkt.stream_index == 1) { global_mainwindow->ui->input2_display->setFrame(pkt.stream_index, pkt.pts); + } else if (pkt.stream_index == 2) { + global_mainwindow->ui->input3_display->setFrame(pkt.stream_index, pkt.pts); } }); assert(pkt.stream_index < MAX_STREAMS); frames[pkt.stream_index].push_back(pkt.pts); - this_thread::sleep_for(milliseconds(1000) / 120); + // Hack. Assumes a given timebase. + if (last_pts != -1) { + this_thread::sleep_for(microseconds((pkt.pts - last_pts) * 1000000 / 12800)); + } + last_pts = pkt.pts; } return 0; diff --git a/make-example-video.sh b/make-example-video.sh new file mode 100644 index 0000000..975c7a4 --- /dev/null +++ b/make-example-video.sh @@ -0,0 +1,8 @@ +youtube-dl 'https://www.youtube.com/watch?v=Wa2fBiCEzTc' +FILE='MULTI ANGLE _ George Evans pops up with a 92nd-minute winner in Blackburn!-Wa2fBiCEzTc.mp4' +ffmpeg -y -ss 0:03.290 -t 0:37 -i "$FILE" -c:v mjpeg -an angle1.mp4 +ffmpeg -y -ss 0:40 -t 0:40 -i "$FILE" -c:v mjpeg -an angle2.mp4 +ffmpeg -y -ss 1:12.880 -i "$FILE" -c:v mjpeg -an angle3.mp4 +ffmpeg -y -ss 0:07 -i ./angle3.mp4 -c:v copy -copyts -start_at_zero angle3-cut.mp4 +ffmpeg -y -copyts -i angle1.mp4 -i angle2.mp4 -i angle3-cut.mp4 -map 0:0 -map 1:0 -map 2:0 -c:v copy multiangle.mp4 + diff --git a/ui_mainwindow.ui b/ui_mainwindow.ui index 778d19f..3d3f046 100644 --- a/ui_mainwindow.ui +++ b/ui_mainwindow.ui @@ -91,10 +91,72 @@ - + + + + In + + + + + Out + + + + + Duration + + + + + Camera 1 + + + + + Camera 2 + + + + + Camera 3 + + + + + Camera 4 + + + - + + + + In + + + + + Out + + + + + Duration + + + + + Camera + + + + + Description + + + -- 2.39.2