+/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
+
/*
Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
node->add_child("Type")->add_child_text ("FFmpeg");
Content::as_xml (node);
VideoContent::as_xml (node);
+ AudioContent::as_xml (node);
boost::mutex::scoped_lock lm (_mutex);
return 0;
}
- return video_frames_to_audio_frames (_video_length, audio_frame_rate(), video_frame_rate());
+ return video_frames_to_audio_frames (_video_length, content_audio_frame_rate(), video_frame_rate());
}
int
}
int
-FFmpegContent::audio_frame_rate () const
+FFmpegContent::content_audio_frame_rate () const
{
if (!_audio_stream) {
return 0;
return _audio_stream->frame_rate;
}
+int
+FFmpegContent::output_audio_frame_rate (shared_ptr<const Film> film) const
+{
+ /* Resample to a DCI-approved sample rate */
+ double t = dcp_audio_frame_rate (content_audio_frame_rate ());
+
+ FrameRateConversion frc (video_frame_rate(), film->dcp_video_frame_rate());
+
+ /* Compensate if the DCP is being run at a different frame rate
+ to the source; that is, if the video is run such that it will
+ look different in the DCP compared to the source (slower or faster).
+ skip/repeat doesn't come into effect here.
+ */
+
+ if (frc.change_speed) {
+ t *= video_frame_rate() * frc.factor() / film->dcp_video_frame_rate();
+ }
+
+ return rint (t);
+}
+
bool
operator== (FFmpegSubtitleStream const & a, FFmpegSubtitleStream const & b)
{
}
FFmpegAudioStream::FFmpegAudioStream (shared_ptr<const cxml::Node> node)
+ : mapping (node->node_child ("Mapping"))
{
name = node->string_child ("Name");
id = node->number_child<int> ("Id");
root->add_child("Id")->add_child_text (lexical_cast<string> (id));
root->add_child("FrameRate")->add_child_text (lexical_cast<string> (frame_rate));
root->add_child("Channels")->add_child_text (lexical_cast<string> (channels));
+ mapping.as_xml (root->add_child("Mapping"));
}
/** Construct a SubtitleStream from a value returned from to_string().
{
return shared_ptr<Content> (new FFmpegContent (*this));
}
+
+Time
+FFmpegContent::length (shared_ptr<const Film> film) const
+{
+ FrameRateConversion frc (video_frame_rate (), film->dcp_video_frame_rate ());
+ return video_length() * frc.factor() * TIME_HZ / film->dcp_video_frame_rate ();
+}
+
+AudioMapping
+FFmpegContent::audio_mapping () const
+{
+ if (!_audio_stream) {
+ return AudioMapping ();
+ }
+
+ return _audio_stream->mapping;
+}