| 675 | } |
| 676 | |
| 677 | void test_muxer2 ( |
| 678 | const std::string& filepath, |
| 679 | AVCodecID image_codec, |
| 680 | AVCodecID audio_codec |
| 681 | ) |
| 682 | { |
| 683 | const std::string tmpfile = "dummy.avi"; |
| 684 | |
| 685 | // Load a video/audio as a source of frames |
| 686 | demuxer cap(filepath); |
| 687 | DLIB_TEST(cap.is_open()); |
| 688 | const bool has_video = cap.video_enabled(); |
| 689 | const bool has_audio = cap.audio_enabled(); |
| 690 | const int height = cap.height(); |
| 691 | const int width = cap.width(); |
| 692 | const auto pixfmt = cap.pixel_fmt(); |
| 693 | const auto fps = cap.fps(); |
| 694 | const int rate = cap.sample_rate(); |
| 695 | const auto samplefmt = cap.sample_fmt(); |
| 696 | const auto layout = cap.channel_layout(); |
| 697 | |
| 698 | std::vector<frame> frames; |
| 699 | frame f; |
| 700 | int nimages{0}; |
| 701 | int nsamples{0}; |
| 702 | |
| 703 | while (cap.read(f)) |
| 704 | { |
| 705 | if (f.is_image()) |
| 706 | ++nimages; |
| 707 | if (f.is_audio()) |
| 708 | nsamples += f.nsamples(); |
| 709 | frames.push_back(std::move(f)); |
| 710 | } |
| 711 | |
| 712 | print_spinner(); |
| 713 | |
| 714 | // Muxer configured using parameters in video |
| 715 | { |
| 716 | muxer writer([&] { |
| 717 | muxer::args args; |
| 718 | args.filepath = tmpfile; |
| 719 | args.enable_image = has_video; |
| 720 | args.enable_audio = has_audio; |
| 721 | |
| 722 | if (has_video) |
| 723 | { |
| 724 | args.args_image.codec = image_codec; |
| 725 | args.args_image.h = height; |
| 726 | args.args_image.w = width; |
| 727 | args.args_image.framerate = fps; |
| 728 | args.args_image.fmt = AV_PIX_FMT_YUV420P; |
| 729 | } |
| 730 | |
| 731 | if (has_audio) |
| 732 | { |
| 733 | args.args_audio.codec = audio_codec; |
| 734 | args.args_audio.sample_rate = rate; |
no test coverage detected