diff options
author | Johannes Mueller <github@johannes-mueller.org> | 2015-04-12 14:26:39 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2015-04-21 18:15:29 +0200 |
commit | acd1ee1989549ecd48ee896a3e1d2158c92d6609 (patch) | |
tree | fccdd4a4c9ecec915be36d00e7b129009fbffaa2 /libs/ardour/export_handler.cc | |
parent | 9241f581883ddcdd51560c56c83c6afa6dc3815a (diff) |
Added support for exporting mp4 chapter marks
The mp4 file format supports chapter marks using the so called
mp4chaps format to enable chapter wise navigation in an mp4 file. The
format is like
hh:mm:ss.sss Chapter Title
This commit adds the ability to export those kind of chapter marks
along with TOC and CUE marks. The filename extension for the chapter
mark file is "chapters.txt". The format specification description is
"MP4ch".
Diffstat (limited to 'libs/ardour/export_handler.cc')
-rw-r--r-- | libs/ardour/export_handler.cc | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/libs/ardour/export_handler.cc b/libs/ardour/export_handler.cc index b44c46e549..33e19d663f 100644 --- a/libs/ardour/export_handler.cc +++ b/libs/ardour/export_handler.cc @@ -305,6 +305,10 @@ ExportHandler::finish_timespan () export_cd_marker_file (current_timespan, fmt, filename, CDMarkerTOC); } + if (fmt->with_mp4chaps()) { + export_cd_marker_file (current_timespan, fmt, filename, MP4Chaps); + } + if (fmt->tag()) { AudiofileTagger::tag_file(filename, *SessionMetadata::Metadata()); } @@ -403,6 +407,11 @@ ExportHandler::export_cd_marker_file (ExportTimespanPtr timespan, ExportFormatSp track_func = &ExportHandler::write_track_info_cue; index_func = &ExportHandler::write_index_info_cue; break; + case MP4Chaps: + header_func = &ExportHandler::write_mp4ch_header; + track_func = &ExportHandler::write_track_info_mp4ch; + index_func = &ExportHandler::write_index_info_mp4ch; + break; default: return; } @@ -500,17 +509,19 @@ ExportHandler::export_cd_marker_file (ExportTimespanPtr timespan, ExportFormatSp string ExportHandler::get_cd_marker_filename(std::string filename, CDMarkerFormat format) { - /* do not strip file suffix because there may be more than one format, + /* do not strip file suffix because there may be more than one format, and we do not want the CD marker file from one format to overwrite another (e.g. foo.wav.cue > foo.aiff.cue) */ switch (format) { - case CDMarkerTOC: + case CDMarkerTOC: return filename + ".toc"; - case CDMarkerCUE: + case CDMarkerCUE: return filename + ".cue"; - default: + case MP4Chaps: + return filename + ".chapters.txt"; + default: return filename + ".marker"; // Should not be reached when actually creating a file } } @@ -590,6 +601,11 @@ ExportHandler::write_toc_header (CDMarkerStatus & status) } void +ExportHandler::write_mp4ch_header (CDMarkerStatus & status) +{ +} + +void ExportHandler::write_track_info_cue (CDMarkerStatus & status) { gchar buf[18]; @@ -693,6 +709,14 @@ ExportHandler::write_track_info_toc (CDMarkerStatus & status) status.out << "START" << buf << endl; } +void ExportHandler::write_track_info_mp4ch (CDMarkerStatus & status) +{ + gchar buf[18]; + + frames_to_chapter_marks_string(buf, status.track_start_frame); + status.out << buf << " " << status.marker->name() << endl; +} + void ExportHandler::write_index_info_cue (CDMarkerStatus & status) { @@ -716,6 +740,11 @@ ExportHandler::write_index_info_toc (CDMarkerStatus & status) } void +ExportHandler::write_index_info_mp4ch (CDMarkerStatus & status) +{ +} + +void ExportHandler::frames_to_cd_frames_string (char* buf, framepos_t when) { framecnt_t remainder; @@ -730,6 +759,23 @@ ExportHandler::frames_to_cd_frames_string (char* buf, framepos_t when) sprintf (buf, " %02d:%02d:%02d", mins, secs, frames); } +void +ExportHandler::frames_to_chapter_marks_string (char* buf, framepos_t when) +{ + framecnt_t remainder; + framecnt_t fr = session.nominal_frame_rate(); + int hours, mins, secs, msecs; + + hours = when / (3600 * fr); + remainder = when - (hours * 3600 * fr); + mins = remainder / (60 * fr); + remainder -= mins * 60 * fr; + secs = remainder / fr; + remainder -= secs * fr; + msecs = (remainder * 1000) / fr; + sprintf (buf, "%02d:%02d:%02d.%03d", hours, mins, secs, msecs); +} + std::string ExportHandler::toc_escape_cdtext (const std::string& txt) { |