diff --git a/ChangeLog b/ChangeLog index aacc137b2..3b7614f9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-05-07 Moritz Bunkus + + * mkvmerge, mmg: enhancement: Made mmg's "FPS" input field + available for all video tracks. mkvmerge's corresponding option + "--default-duration" now not only modifies the track header field + but affects the frame timecodes as well. + 2009-05-06 Moritz Bunkus * mkvmerge: bug fix: The VobSub reader was dropping the very last diff --git a/src/merge/pr_generic.cpp b/src/merge/pr_generic.cpp index 63d9e84c4..1eab4b470 100644 --- a/src/merge/pr_generic.cpp +++ b/src/merge/pr_generic.cpp @@ -236,6 +236,12 @@ generic_packetizer_c::generic_packetizer_c(generic_reader_c *p_reader, hserialno = create_track_number(reader, ti.id); timecode_factory = timecode_factory_c::create(ti.ext_timecodes, ti.fname, ti.id); + + // If no external timecode file but a default duration has been + // given then create a simple timecode factory that generates the + // timecodes for the given FPS. + if ((NULL == timecode_factory.get()) && (-1 != htrack_default_duration)) + timecode_factory = timecode_factory_c::create_fps_factory(htrack_default_duration, ti.fname, ti.id); } generic_packetizer_c::~generic_packetizer_c() { diff --git a/src/merge/timecode_factory.cpp b/src/merge/timecode_factory.cpp index b6819ff2d..cbc9793d7 100644 --- a/src/merge/timecode_factory.cpp +++ b/src/merge/timecode_factory.cpp @@ -18,6 +18,7 @@ #include "common/common.h" #include "common/mm_io.h" +#include "common/string_formatting.h" #include "common/string_parsing.h" #include "merge/pr_generic.h" #include "merge/timecode_factory.h" @@ -63,6 +64,21 @@ timecode_factory_c::create(const string &file_name, return timecode_factory_cptr(factory); } +timecode_factory_cptr +timecode_factory_c::create_fps_factory(int64_t default_duration, + const string &source_name, + int64_t tid) { + mm_text_io_c text_io(new mm_mem_io_c(NULL, 0, 1024)); + text_io.puts("# timecode format v1\n"); + text_io.puts(boost::format("assume %1%\n") % to_string(1000000000.0 / default_duration, 9)); + text_io.setFilePointer(0, seek_beginning); + + timecode_factory_cptr factory(new timecode_factory_v1_c("dummy", source_name, tid)); + factory->parse(text_io); + + return factory; +} + void timecode_factory_v1_c::parse(mm_io_c &in) { string line; diff --git a/src/merge/timecode_factory.h b/src/merge/timecode_factory.h index 94175da45..bfb5befbf 100644 --- a/src/merge/timecode_factory.h +++ b/src/merge/timecode_factory.h @@ -95,6 +95,7 @@ public: } static timecode_factory_cptr create(const string &file_name, const string &source_name, int64_t tid); + static timecode_factory_cptr create_fps_factory(int64_t default_duration, const string &source_name, int64_t tid); }; class timecode_factory_v1_c: public timecode_factory_c { diff --git a/src/mmg/tab_input_format.cpp b/src/mmg/tab_input_format.cpp index 39c72723d..d05018b34 100644 --- a/src/mmg/tab_input_format.cpp +++ b/src/mmg/tab_input_format.cpp @@ -256,8 +256,8 @@ tab_input_format::set_track_mode(mmg_track_t *t) { cob_fourcc->Enable(video); st_stereo_mode->Enable(video); cob_stereo_mode->Enable(video); - st_fps->Enable(avc_es); - cob_fps->Enable(avc_es); + st_fps->Enable(video); + cob_fps->Enable(video); st_nalu_size_length->Enable(avc || avc_es); cob_nalu_size_length->Enable(avc || avc_es); st_compression->Enable((ctype.Find(wxT("vobsub")) >= 0) && !appending); diff --git a/src/output/p_avc.cpp b/src/output/p_avc.cpp index 12912e7b4..72717ccfa 100644 --- a/src/output/p_avc.cpp +++ b/src/output/p_avc.cpp @@ -55,6 +55,14 @@ mpeg4_p10_es_video_packetizer_c(generic_reader_c *p_reader, set_codec_private(m_avcc->get(), m_avcc->get_size()); extract_aspect_ratio(); m_parser.set_keep_ar_info(false); + + // If no external timecode file has been specified then mkvmerge + // might have created a factory due to the --default-duration + // command line argument. This factory must be disabled for the AVC + // packetizer because it takes care of handling the default + // duration/FPS itself. + if (ti.ext_timecodes.empty()) + timecode_factory = timecode_factory_cptr(NULL); } void