diff --git a/matroska.h b/matroska.h index e5a5c62ee..aadf380af 100644 --- a/matroska.h +++ b/matroska.h @@ -13,7 +13,7 @@ /*! \file - \version \$Id: matroska.h,v 1.6 2003/04/23 08:16:39 mosu Exp $ + \version \$Id: matroska.h,v 1.7 2003/04/24 20:36:45 mosu Exp $ \brief Definitions for the various Codec IDs \author Moritz Bunkus */ @@ -32,5 +32,6 @@ #define MKV_V_MSCOMP "V_MS/VFW/FOURCC" #define MKV_S_TEXTASCII "S_TEXT/ASCII" +#define MKV_S_TEXTUTF8 "S_TEXT/UTF8" #endif // __MATROSKA_H diff --git a/mkvmerge.1 b/mkvmerge.1 index 79b9d833c..f6d197378 100644 --- a/mkvmerge.1 +++ b/mkvmerge.1 @@ -73,9 +73,6 @@ linear drifts. \fIp\fR defaults to 1000 if omitted. Both \fIo\fR and Defaults: no manual synch correction (which is the same as \fId\fR = 0 and \fIo\fR/\fIp\fR = 1.0). .TP -\fB\-f\fR, \fB\-\-fourcc\fR <\fIFourCC\fR> -Forces the FourCC to the specified value. Works only for video tracks. -.TP \fB\-\-cues\fR <\fInone\fR|\fIiframes\fR|\fIall\fR> Controls for which tracks cue (index) entries are created. \fInone\fR inhibits the creation of cue entries for all tracks contained in the following @@ -94,6 +91,20 @@ not explicitly select a track himself then the player should prefer the track that has his 'default' flag set. Only one track of each kind (audio, video, subttiles) can have his 'default' flag set. .LP +Options that only apply to video tracks: +.TP +\fB\-f\fR, \fB\-\-fourcc\fR <\fIFourCC\fR> +Forces the FourCC to the specified value. Works only for video tracks. +.LP +Options that only apply to text subtitle tracks: +.TP +\fB\-\-no\-utf8\-subs\fR +With this option text subtitles will not be recoded, and the track's +CodecId will be set to S_TEXT/ASCII. Without this option the text subtitles +will be converted to UTF\-8, and the track's CodecId will be set to +S_TEXT/UTF8. \fBmkvmerge\fR uses the value of \fILC_CTYPE\fR as the source +charset or ISO\-8859\-15 if \fILC_CTYPE\fR is not set. +.LP Other options: .TP \fB\-l\fR, \fB\-\-list\-types\fR diff --git a/mkvmerge.cpp b/mkvmerge.cpp index f077fc1f2..51862e20a 100644 --- a/mkvmerge.cpp +++ b/mkvmerge.cpp @@ -13,7 +13,7 @@ /*! \file - \version \$Id: mkvmerge.cpp,v 1.44 2003/04/23 14:38:53 mosu Exp $ + \version \$Id: mkvmerge.cpp,v 1.45 2003/04/24 20:36:45 mosu Exp $ \brief command line parameter parsing, looping, output handling \author Moritz Bunkus */ @@ -30,6 +30,7 @@ #endif #include +#include #ifdef LIBEBML_GCC2 #include @@ -51,6 +52,7 @@ #include "KaxCues.h" #include "KaxInfo.h" #include "KaxInfoData.h" +#include "KaxVersion.h" #include "mkvmerge.h" #include "cluster_helper.h" @@ -71,6 +73,7 @@ #endif using namespace LIBMATROSKA_NAMESPACE; +using namespace std; typedef struct { char *ext; @@ -170,13 +173,16 @@ static void usage(void) { " linear drifts. p defaults to 1000 if\n" " omitted. Both o and p can be floating point\n" " numbers.\n" - " -f, --fourcc Forces the FourCC to the specified value.\n" - " Works only for video tracks.\n" " --default-track Sets the 'default' flag for this track.\n" " --cues None at all, only for I frames, for all.\n" - "\n" - " Other options:\n" + "\n Options that only apply to video tracks:\n" + " -f, --fourcc Forces the FourCC to the specified value.\n" + " Works only for video tracks.\n" + "\n Options that only apply to text subtitle tracks:\n" + " --no-utf8-subs Outputs text subtitles unmodified and do not\n" + " convert the text to UTF-8.\n" + "\n\n Other options:\n" " -l, --list-types Lists supported input file types.\n" " -h, --help Show this help.\n" " -V, --version Show version information.\n" @@ -597,6 +603,8 @@ static void parse_args(int argc, char **argv) { i++; } else if (!strcmp(argv[i], "--default-track")) ti.default_track = 1; + else if (!strcmp(argv[i], "--no-utf8-subs")) + ti.no_utf8_subs = 1; // The argument is an input file. else { diff --git a/p_textsubs.cpp b/p_textsubs.cpp index a7a9e689c..546a448ad 100644 --- a/p_textsubs.cpp +++ b/p_textsubs.cpp @@ -13,7 +13,7 @@ /*! \file - \version \$Id: p_textsubs.cpp,v 1.8 2003/04/21 08:29:50 mosu Exp $ + \version \$Id: p_textsubs.cpp,v 1.9 2003/04/24 20:36:45 mosu Exp $ \brief Subripper subtitle reader \author Moritz Bunkus */ @@ -46,7 +46,10 @@ void textsubs_packetizer_c::set_header() { set_serial(-1); set_track_type(track_subtitle); - set_codec_id(MKV_S_TEXTASCII); + if (ti->no_utf8_subs) + set_codec_id(MKV_S_TEXTASCII); + else + set_codec_id(MKV_S_TEXTUTF8); if (ti->default_track) set_as_default_track('s'); @@ -117,7 +120,13 @@ int textsubs_packetizer_c::process(unsigned char *_subs, int, int64_t start, } *idx2 = 0; - add_packet((unsigned char *)subs, strlen(subs), start, -1, -1, length); + if (!ti->no_utf8_subs) { + char *utf8_subs = to_utf8(subs); + add_packet((unsigned char *)utf8_subs, strlen(utf8_subs), start, -1, -1, + length); + free(utf8_subs); + } else + add_packet((unsigned char *)subs, strlen(subs), start, -1, -1, length); free(subs); diff --git a/pr_generic.h b/pr_generic.h index cf5ec5d08..e57b8d681 100644 --- a/pr_generic.h +++ b/pr_generic.h @@ -13,7 +13,7 @@ /*! \file - \version \$Id: pr_generic.h,v 1.26 2003/04/21 08:29:50 mosu Exp $ + \version \$Id: pr_generic.h,v 1.27 2003/04/24 20:36:45 mosu Exp $ \brief class definition for the generic reader and packetizer \author Moritz Bunkus */ @@ -49,6 +49,7 @@ typedef struct { // Options used by the packetizers. unsigned char *private_data; int private_size; + int no_utf8_subs; char fourcc[5];