2 Copyright (C) 2017 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #include "lib/ffmpeg_encoder.h"
23 #include "lib/ffmpeg_content.h"
24 #include "lib/audio_content.h"
25 #include "lib/text_subtitle_content.h"
26 #include "lib/ratio.h"
27 #include "lib/transcode_job.h"
29 #include <boost/test/unit_test.hpp>
31 using boost::shared_ptr;
33 BOOST_AUTO_TEST_CASE (ffmpeg_encoder_basic_test_mov)
35 shared_ptr<Film> film = new_test_film ("ffmpeg_transcoder_basic_test_mov");
36 film->set_name ("ffmpeg_transcoder_basic_test");
37 shared_ptr<FFmpegContent> c (new FFmpegContent (film, "test/data/test.mp4"));
38 film->set_container (Ratio::from_id ("185"));
39 film->set_audio_channels (6);
41 film->examine_and_add_content (c);
42 BOOST_REQUIRE (!wait_for_jobs ());
44 shared_ptr<Job> job (new TranscodeJob (film));
45 FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_basic_test.mov", FFmpegEncoder::FORMAT_PRORES, false);
49 BOOST_AUTO_TEST_CASE (ffmpeg_encoder_basic_test_mp4)
51 shared_ptr<Film> film = new_test_film ("ffmpeg_transcoder_basic_test_mp4");
52 film->set_name ("ffmpeg_transcoder_basic_test");
53 shared_ptr<FFmpegContent> c (new FFmpegContent (film, "test/data/test.mp4"));
54 film->set_container (Ratio::from_id ("185"));
55 film->set_audio_channels (6);
57 film->examine_and_add_content (c);
58 BOOST_REQUIRE (!wait_for_jobs ());
60 shared_ptr<Job> job (new TranscodeJob (film));
61 FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_basic_test.mp4", FFmpegEncoder::FORMAT_H264, false);
65 BOOST_AUTO_TEST_CASE (ffmpeg_encoder_basic_test_subs)
67 shared_ptr<Film> film = new_test_film ("ffmpeg_transcoder_basic_test_subs");
68 film->set_name ("ffmpeg_transcoder_basic_test");
69 film->set_container (Ratio::from_id ("185"));
70 film->set_audio_channels (6);
72 shared_ptr<FFmpegContent> c (new FFmpegContent (film, "test/data/test.mp4"));
73 film->examine_and_add_content (c);
74 BOOST_REQUIRE (!wait_for_jobs ());
76 shared_ptr<TextSubtitleContent> s (new TextSubtitleContent (film, "test/data/subrip.srt"));
77 film->examine_and_add_content (s);
78 BOOST_REQUIRE (!wait_for_jobs ());
80 shared_ptr<Job> job (new TranscodeJob (film));
81 FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_basic_test_subs.mp4", FFmpegEncoder::FORMAT_H264, false);
85 BOOST_AUTO_TEST_CASE (ffmpeg_encoder_basic_test_mixdown)
87 shared_ptr<Film> film = new_test_film ("ffmpeg_transcoder_basic_test_mixdown");
88 film->set_name ("ffmpeg_transcoder_basic_test");
89 film->set_container (Ratio::from_id ("185"));
90 film->set_audio_channels (6);
92 shared_ptr<FFmpegContent> L (new FFmpegContent (film, "test/data/L.wav"));
93 film->examine_and_add_content (L);
94 shared_ptr<FFmpegContent> R (new FFmpegContent (film, "test/data/R.wav"));
95 film->examine_and_add_content (R);
96 shared_ptr<FFmpegContent> C (new FFmpegContent (film, "test/data/C.wav"));
97 film->examine_and_add_content (C);
98 shared_ptr<FFmpegContent> Ls (new FFmpegContent (film, "test/data/Ls.wav"));
99 film->examine_and_add_content (Ls);
100 shared_ptr<FFmpegContent> Rs (new FFmpegContent (film, "test/data/Rs.wav"));
101 film->examine_and_add_content (Rs);
102 shared_ptr<FFmpegContent> Lfe (new FFmpegContent (film, "test/data/Lfe.wav"));
103 film->examine_and_add_content (Lfe);
104 BOOST_REQUIRE (!wait_for_jobs ());
106 AudioMapping map (1, MAX_DCP_AUDIO_CHANNELS);
108 L->set_position (DCPTime::from_seconds (0));
111 L->audio->set_mapping (map);
112 R->set_position (DCPTime::from_seconds (1));
115 R->audio->set_mapping (map);
116 C->set_position (DCPTime::from_seconds (2));
119 C->audio->set_mapping (map);
120 Lfe->set_position (DCPTime::from_seconds (3));
123 Lfe->audio->set_mapping (map);
124 Ls->set_position (DCPTime::from_seconds (4));
127 Ls->audio->set_mapping (map);
128 Rs->set_position (DCPTime::from_seconds (5));
131 Rs->audio->set_mapping (map);
133 shared_ptr<Job> job (new TranscodeJob (film));
134 FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_basic_test_mixdown.mp4", FFmpegEncoder::FORMAT_H264, true);
137 /* Skip the first video packet when checking as it contains x264 options which can vary between machines
138 (e.g. number of threads used for encoding).
140 check_ffmpeg ("build/test/ffmpeg_encoder_basic_test_mixdown.mp4", "test/data/ffmpeg_encoder_basic_test_mixdown.mp4", 0);