MCPcopy Create free account
hub / github.com/davisking/dlib / test_muxer1

Function test_muxer1

dlib/test/ffmpeg.cpp:603–675  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601
602 template<class image_type>
603 void test_muxer1 (
604 const std::string& filepath,
605 AVCodecID image_codec
606 )
607 {
608 const std::string tmpfile = "dummy.avi";
609
610 // Load a video/audio as a source of frames
611 demuxer cap({filepath, video_enabled, audio_disabled});
612 DLIB_TEST(cap.is_open());
613 DLIB_TEST(cap.video_enabled());
614 DLIB_TEST(!cap.audio_enabled());
615 const int height = cap.height();
616 const int width = cap.width();
617
618 // Open muxer
619 muxer writer([&] {
620 muxer::args args;
621 args.filepath = tmpfile;
622 args.enable_audio = false;
623 args.args_image.codec = image_codec;
624 args.args_image.h = cap.height();
625 args.args_image.w = cap.width();
626 args.args_image.framerate = cap.fps();
627 args.args_image.fmt = AV_PIX_FMT_YUV420P;
628 return args;
629 }());
630
631 DLIB_TEST(writer.is_open());
632 DLIB_TEST(!writer.audio_enabled());
633 DLIB_TEST(writer.video_enabled());
634
635 DLIB_TEST(writer.get_video_codec_id() == image_codec);
636 DLIB_TEST(writer.height() == cap.height());
637 DLIB_TEST(writer.width() == cap.width());
638
639 // Demux then remux
640 int nimages_demuxed{0};
641 image_type img;
642
643 while (cap.read(img))
644 {
645 ++nimages_demuxed;
646 DLIB_TEST(img.nr() == height);
647 DLIB_TEST(img.nc() == width);
648 DLIB_TEST(writer.push(img));
649
650 if (nimages_demuxed % 10 == 0)
651 print_spinner();
652 }
653
654 writer.flush();
655
656 // Demux everything back
657 demuxer cap2(tmpfile);
658 DLIB_TEST(cap2.is_open());
659 DLIB_TEST(cap2.video_enabled());
660 DLIB_TEST(!cap2.audio_enabled());

Callers

nothing calls this directly

Calls 13

print_spinnerFunction · 0.85
is_openMethod · 0.45
video_enabledMethod · 0.45
audio_enabledMethod · 0.45
heightMethod · 0.45
widthMethod · 0.45
fpsMethod · 0.45
get_video_codec_idMethod · 0.45
readMethod · 0.45
nrMethod · 0.45
ncMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected