#include <libavformat/avformat.h>
}
#include <libcxml/cxml.h>
+#include <libdcp/raw_convert.h>
#include "ffmpeg_content.h"
#include "ffmpeg_examiner.h"
#include "compose.hpp"
#include "film.h"
#include "log.h"
#include "exceptions.h"
+#include "frame_rate_change.h"
+#include "safe_stringstream.h"
#include "i18n.h"
+#define LOG_GENERAL(...) film->log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL);
+
using std::string;
-using std::stringstream;
using std::vector;
using std::list;
using std::cout;
using std::pair;
using boost::shared_ptr;
-using boost::lexical_cast;
using boost::dynamic_pointer_cast;
+using libdcp::raw_convert;
int const FFmpegContentProperty::SUBTITLE_STREAMS = 100;
int const FFmpegContentProperty::SUBTITLE_STREAM = 101;
}
if (_first_video) {
- node->add_child("FirstVideo")->add_child_text (lexical_cast<string> (_first_video.get ()));
+ node->add_child("FirstVideo")->add_child_text (raw_convert<string> (_first_video.get ()));
}
}
VideoContent::Frame video_length = 0;
video_length = examiner->video_length ();
- film->log()->log (String::compose ("Video length obtained from header as %1 frames", video_length));
+ LOG_GENERAL ("Video length obtained from header as %1 frames", video_length);
{
boost::mutex::scoped_lock lm (_mutex);
return "";
}
- stringstream s;
+ SafeStringStream s;
- s << String::compose (_("%1 frames; %2 frames per second"), video_length(), video_frame_rate()) << "\n";
+ s << String::compose (_("%1 frames; %2 frames per second"), video_length_after_3d_combine(), video_frame_rate()) << "\n";
s << VideoContent::information ();
return s.str ();
FFmpegContent::audio_length () const
{
int const cafr = content_audio_frame_rate ();
- int const vfr = video_frame_rate ();
- VideoContent::Frame const vl = video_length ();
+ float const vfr = video_frame_rate ();
+ VideoContent::Frame const vl = video_length_after_3d_combine ();
boost::mutex::scoped_lock lm (_mutex);
if (!_audio_stream) {
return _audio_stream->frame_rate;
}
-int
-FFmpegContent::output_audio_frame_rate () const
-{
- shared_ptr<const Film> film = _film.lock ();
- assert (film);
-
- /* Resample to a DCI-approved sample rate */
- double t = dcp_audio_frame_rate (content_audio_frame_rate ());
-
- FrameRateConversion frc (video_frame_rate(), film->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->video_frame_rate();
- }
-
- return rint (t);
-}
-
bool
operator== (FFmpegStream const & a, FFmpegStream const & b)
{
FFmpegStream::as_xml (xmlpp::Node* root) const
{
root->add_child("Name")->add_child_text (name);
- root->add_child("Id")->add_child_text (lexical_cast<string> (_id));
+ root->add_child("Id")->add_child_text (raw_convert<string> (_id));
}
FFmpegAudioStream::FFmpegAudioStream (shared_ptr<const cxml::Node> node, int version)
FFmpegAudioStream::as_xml (xmlpp::Node* root) const
{
FFmpegStream::as_xml (root);
- root->add_child("FrameRate")->add_child_text (lexical_cast<string> (frame_rate));
- root->add_child("Channels")->add_child_text (lexical_cast<string> (channels));
+ root->add_child("FrameRate")->add_child_text (raw_convert<string> (frame_rate));
+ root->add_child("Channels")->add_child_text (raw_convert<string> (channels));
if (first_audio) {
- root->add_child("FirstAudio")->add_child_text (lexical_cast<string> (first_audio.get ()));
+ root->add_child("FirstAudio")->add_child_text (raw_convert<string> (first_audio.get ()));
}
mapping.as_xml (root->add_child("Mapping"));
}
shared_ptr<const Film> film = _film.lock ();
assert (film);
- FrameRateConversion frc (video_frame_rate (), film->video_frame_rate ());
- return video_length() * frc.factor() * TIME_HZ / film->video_frame_rate ();
+ FrameRateChange frc (video_frame_rate (), film->video_frame_rate ());
+ return video_length_after_3d_combine() * frc.factor() * TIME_HZ / film->video_frame_rate ();
}
AudioMapping
string
FFmpegContent::identifier () const
{
- stringstream s;
+ SafeStringStream s;
s << VideoContent::identifier();