[FFmpeg-devel] [PATCH 1/1] Extended ASF functionality

Vadim Belov vadim.belov at gmail.com
Wed Jul 1 17:33:52 CEST 2015


---
 libavformat/Makefile             |   2 +-
 libavformat/asf.c                |   4 +
 libavformat/asf.h                |  12 ++-
 libavformat/asf_ex.h             |  58 ++++++++++
 libavformat/asf_trim.c           | 228 +++++++++++++++++++++++++++++++++++++++
 libavformat/asf_trim.h           |  95 ++++++++++++++++
 libavformat/asfdec.c             |  17 ++-
 libavformat/asfenc.c             |  64 ++++++++++-
 8 files changed, 954 insertions(+), 485 deletions(-)
 create mode 100644 libavformat/asf_ex.h
 create mode 100644 libavformat/asf_trim.c
 create mode 100644 libavformat/asf_trim.h

 1.9.5.msysgit.1

diff --git a/ffmpeg.c b/ffmpeg.c
index a89ae39..a3cca09 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -36,9 +36,6 @@
 #if HAVE_IO_H
 #include <io.h>
 #endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #endif
 
 #include "libavformat/avformat.h"
@@ -75,6 +72,10 @@
 #elif HAVE_GETPROCESSTIMES
 #include <windows.h>
 #endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
 #if HAVE_GETPROCESSMEMORYINFO
 #include <windows.h>
 #include <psapi.h>
diff --git a/libavformat/Makefile b/libavformat/Makefile
index bca9d5b..2743467 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -84,7 +84,7 @@ OBJS-$(CONFIG_APNG_MUXER)                += apngenc.o
 OBJS-$(CONFIG_AQTITLE_DEMUXER)           += aqtitledec.o subtitles.o
 OBJS-$(CONFIG_ASF_DEMUXER)               += asfdec.o asf.o asfcrypt.o \
                                             avlanguage.o
-OBJS-$(CONFIG_ASF_MUXER)                 += asfenc.o asf.o
+OBJS-$(CONFIG_ASF_MUXER)                 += asfenc.o asf.o asf_trim.o
 OBJS-$(CONFIG_ASS_DEMUXER)               += assdec.o subtitles.o
 OBJS-$(CONFIG_ASS_MUXER)                 += assenc.o
 OBJS-$(CONFIG_AST_DEMUXER)               += ast.o astdec.o
diff --git a/libavformat/asf.c b/libavformat/asf.c
index 80d24db..d2a0a8f 100644
--- a/libavformat/asf.c
+++ b/libavformat/asf.c
@@ -143,6 +143,10 @@ const ff_asf_guid ff_asf_digital_signature = {
     0xfc, 0xb3, 0x11, 0x22, 0x23, 0xbd, 0xd2, 0x11, 0xb4, 0xb7, 0x00, 0xa0, 0xc9, 0x55, 0xfc, 0x6e
 };
 
+const ff_asf_guid ff_asf_index_header = {
+    0xd3, 0x29, 0xe2, 0xd6, 0xda, 0x35, 0xd1, 0x11, 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe
+};
+
 /* List of official tags at http://msdn.microsoft.com/en-us/library/dd743066(VS.85).aspx */
 const AVMetadataConv ff_asf_metadata_conv[] = {
     { "WM/AlbumArtist",          "album_artist"     },
diff --git a/libavformat/asf.h b/libavformat/asf.h
index 0c9598a..1ea848d 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2015 Vadim Belov
  *
  * This file is part of FFmpeg.
  *
@@ -25,6 +26,7 @@
 #include "avformat.h"
 #include "metadata.h"
 #include "riff.h"
+#include "asf_ex.h"
 
 #define PACKET_SIZE 3200
 
@@ -57,7 +59,9 @@ typedef struct ASFStream {
     uint32_t palette[256];
 
     int payload_ext_ct;
-    ASFPayload payload[8];
+    ASFPayload payload[8];	
+
+    ASFIndexData idx_data;
 } ASFStream;
 
 typedef struct ASFMainHeader {
@@ -123,7 +127,7 @@ extern const ff_asf_guid ff_asf_language_guid;
 extern const ff_asf_guid ff_asf_content_encryption;
 extern const ff_asf_guid ff_asf_ext_content_encryption;
 extern const ff_asf_guid ff_asf_digital_signature;
-
+extern const ff_asf_guid ff_asf_index_header;
 extern const AVMetadataConv ff_asf_metadata_conv[];
 
 #define ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT 0x80 //1000 0000
diff --git a/libavformat/asf_ex.h b/libavformat/asf_ex.h
new file mode 100644
index 0000000..5e46a2b
--- /dev/null
+++ b/libavformat/asf_ex.h
@@ -0,0 +1,47 @@
+/**
+ * @file asf_ex.h
+ * Extensions to ASF handling
+ * @author Vadim Belov
+ *
+ * Copyright (c) 2015 Vadim Belov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVFORMAT_ASF_EX_H
+#define AVFORMAT_ASF_EX_H
+
+#include <stdint.h>
+
+#define STREAM_DIRECTION_STR "streamDirection"
+#define DIRECTION_DICT_KEY "direction"
+#define NO_STREAM_DIRECTION -1
+#define ASF_MAX_STREAMS_NUM 128
+
+typedef struct ASFStreamIndex { // Index Entry value 
+    uint64_t offset;
+} ASFStreamIndex;
+
+typedef struct ASFIndexData {
+    ASFStreamIndex* indices;	// array of ASFStreamIndex
+    uint32_t indices_max_count; // allocated size
+    uint32_t next_duration_mark; // for next index
+    uint32_t indices_count;		 // current index 
+    int64_t  duration_overall;
+} ASFIndexData;
+
+#endif /* AVFORMAT_ASF_EX_H */
diff --git a/libavformat/asf_trim.c b/libavformat/asf_trim.c
new file mode 100644
index 0000000..c6dc545
--- /dev/null
+++ b/libavformat/asf_trim.c
@@ -0,0 +1,228 @@
+/*
+ * @file asf_trim.c
+ * Extensions to ASF handling
+ * @author Vadim Belov
+ *
+ * Copyright (c) 2015 Vadim Belov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "asf_trim.h"
+
+#define ASF_INDEX_ENTRY_TIME_INTERVAL 10000
+#define SPECIFIER_INDEX_TYPE 3
+
+#define BLOCK_PART      0xFFFFFFFF00000000
+#define OFFSET_PART     0x00000000FFFFFFFF
+#define INVALID_OFFSET  0xFFFFFFFF
+
+int asf_get_streams_direction(AVFormatContext *s)
+{
+    int ret = 0;
+    int n;
+    for (n = 0; n < s->nb_streams; n++) {
+        AVDictionaryEntry *t = av_dict_get(
+            s->streams[n]->metadata, DIRECTION_DICT_KEY, NULL, 0);
+        
+        av_log(s, AV_LOG_DEBUG, "direction metadata ptr is %p\n", t);
+
+        if (t) ret++;
+    }
+    return ret;
+}
+
+void ff_set_stream_direction(
+    AVFormatContext *s,
+    int direction[ASF_MAX_STREAMS_NUM],
+    AVStream *st,
+    int i)
+{
+    if(direction[i] != NO_STREAM_DIRECTION) {
+        char buffer[32];                                
+        sprintf(buffer, "%d %d", i, direction[i]);              
+        av_dict_set(&st->metadata, DIRECTION_DICT_KEY, buffer, 0);
+    }           
+}
+
+int asf_alloc_streams_index(
+    ASFStream streams[ASF_MAX_STREAMS_NUM],
+    int num_streams,
+    int block_size)
+{
+    int i;
+    for (i = 0; i < num_streams; ++i){
+        ASFIndexData *idx = &streams[i].idx_data;
+
+        idx->indices = av_malloc(sizeof(ASFStreamIndex)* block_size);
+        if (!idx->indices) return AVERROR(ENOMEM);
+
+        idx->indices_max_count = block_size;
+        idx->duration_overall = 0;
+        idx->next_duration_mark = 0;
+        idx->indices_count = 0;
+    }
+
+    return 0;
+}
+
+void asf_free_streams_index(
+    ASFStream streams[ASF_MAX_STREAMS_NUM],
+    int num_streams)
+{
+    int i;  
+    for (i = 0; i < num_streams; ++i) {
+        av_freep(&streams[i].idx_data.indices);
+    }
+}
+
+int ff_upadte_indices(
+    ASFStream streams[ASF_MAX_STREAMS_NUM],
+    uint64_t pkt_time,
+    uint64_t packet_offset,
+    int stream_index,
+    int64_t pkt_duration,
+    uint32_t asf_index_block,
+    uint64_t asf_data_start)
+{
+    ASFIndexData *idx = &streams[stream_index].idx_data;
+
+    // reallocate if size too small
+    if (idx->indices_count > idx->indices_max_count) {
+        int err;
+        idx->indices_max_count = (pkt_time + asf_index_block) & ~(asf_index_block - 1);
+        if ((err = av_reallocp_array(&idx,
+            idx->indices_max_count,
+            sizeof(*idx->indices))) < 0) {
+            idx->indices_max_count = 0;
+            return err;
+        }
+    }
+
+    // update offset if reached the duration mark
+    idx->duration_overall += pkt_duration;
+    if (idx->duration_overall > idx->next_duration_mark) {
+        idx->indices[idx->indices_count].offset = packet_offset - asf_data_start;
+        idx->indices_count++;
+        idx->next_duration_mark += ASF_INDEX_ENTRY_TIME_INTERVAL;
+    }
+
+    return 0;
+}
+
+static int get_num_entries(
+    ASFStream streams[ASF_MAX_STREAMS_NUM], 
+    int num_streams)
+{
+    int i;
+    int ret = 0;
+    for (i = 0; i < num_streams; ++i){
+        ASFIndexData *idx = &(streams[i].idx_data);
+        ret = FFMAX(ret, idx->indices_count);
+    }
+    return ret;
+}
+
+static int should_iterate_block(int i, ASFIndexData *idx, uint64_t curr_offset)
+{
+    if (i + 1 < idx->indices_count) {
+        uint64_t next_offset = idx->indices[i + 1].offset;
+        uint64_t curr_block = curr_offset & BLOCK_PART;
+        uint64_t next_block = next_offset & BLOCK_PART;
+        return curr_block != next_block;
+    }
+
+    return 0;
+}
+
+int asf_write_indices(
+    AVFormatContext *s,
+    ASFStream streams[ASF_MAX_STREAMS_NUM],
+    int num_streams)
+{
+    AVIOContext *pb = s->pb;
+    
+    int i, j;
+    int num_blocks = 0;
+    int num_entries = get_num_entries(streams, num_streams);
+
+    int64_t blocks_pos, end_of_indices;
+
+    char write_index = 1;
+    char iterate_block = 1;
+
+    av_log(s, AV_LOG_DEBUG, "Write Index object for %d streams with %d entries.\n",
+        num_streams, num_entries);
+
+    ff_put_guid(pb, &ff_asf_index_header);
+    avio_wl64(pb, 34 + 4 * num_streams + 4 + 8 * num_streams + 4 * num_entries*num_streams);
+    avio_wl32(pb, ASF_INDEX_ENTRY_TIME_INTERVAL); // interval
+    avio_wl16(pb, num_streams); // specifiers count
+
+    blocks_pos = avio_tell(pb);
+    avio_wl32(pb, 0); // rewrite later
+    
+    // write specifiers
+    for (i = 0; i < num_streams; i++) {
+        avio_wl16(pb, i + 1);
+        avio_wl16(pb, SPECIFIER_INDEX_TYPE);
+    }
+
+    avio_wl32(pb, num_entries); // Index Entry Count
+
+    for (i = 0; write_index && i < num_entries; ++i) {
+
+        // block header
+        if (iterate_block) {
+            ++num_blocks;
+
+            for (j = 0; j < num_streams; ++j) {
+                avio_wl64(pb, 0);
+            }
+            iterate_block = 0;
+        }
+
+        // block content
+        for (j = 0; j < num_streams; ++j) {
+            ASFIndexData *idx = &(streams[j].idx_data);
+            uint32_t offset = INVALID_OFFSET;
+            if (i < idx->indices_count) {
+                uint64_t full_offset = idx->indices[i].offset;
+                offset = (uint32_t)full_offset & OFFSET_PART;
+                iterate_block = should_iterate_block(i, idx, full_offset);
+            }
+            else {
+                write_index = 0;
+                offset = INVALID_OFFSET;
+                av_log(s, AV_LOG_WARNING, "Index: invalid offset (%d,%d)\n", i, j);
+            }
+            avio_wl32(pb, offset);
+        }
+    }
+
+    end_of_indices = avio_tell(pb);
+    
+    // rewrite blocks count and return file descriptor to end
+    avio_seek(pb, blocks_pos, SEEK_SET);
+    avio_wl32(pb, num_blocks);
+    avio_seek(pb, end_of_indices, SEEK_SET);
+
+    av_log(s, AV_LOG_DEBUG, "Write Index object for %d streams with %d entries done.\n",
+        num_streams, num_entries);
+
+    return 0;
+}
diff --git a/libavformat/asf_trim.h b/libavformat/asf_trim.h
new file mode 100644
index 0000000..ecfbf97
--- /dev/null
+++ b/libavformat/asf_trim.h
@@ -0,0 +1,95 @@
+/*
+ * @file asf_trim.c
+ * Extensions to ASF handling
+ * @author Vadim Belov
+ *
+ * Copyright (c) 2015 Vadim Belov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef ASF_TRIM_H
+#define ASF_TRIM_H
+
+#include "asf.h"
+#include "avformat.h"
+
+/**
+* Get stream direction attributes values from input ASF file
+*
+* @return  number of stream direction attributes in all streams
+*/
+int asf_get_streams_direction(AVFormatContext *s);
+
+
+/**
+* Set stream direction attributes in output ASF file
+*/
+void ff_set_stream_direction(
+    AVFormatContext *s,
+    int direction[ASF_MAX_STREAMS_NUM],
+    AVStream *st,
+    int i);
+
+
+/**
+* Allocate index object for a stream
+*
+* @return error code: 0 iff success
+*/
+int asf_alloc_streams_index(
+    ASFStream streams[ASF_MAX_STREAMS_NUM],
+    int num_streams,
+    int block_size);
+
+
+/**
+* Free index object for a stream
+*/
+void asf_free_streams_index(
+    ASFStream streams[ASF_MAX_STREAMS_NUM],
+    int num_streams);
+
+
+/**
+* Update index object of the packet's stream if necessary:
+* when packet time has reached the defined interval between 
+* the indices
+*
+* @return error code: 0 iff success
+*/
+int ff_upadte_indices(
+    ASFStream streams[ASF_MAX_STREAMS_NUM],
+    uint64_t pkt_time,
+    uint64_t packet_offset,
+    int stream_index,
+    int64_t pkt_duration,
+    uint32_t asf_index_block,
+    uint64_t asf_data_start);
+
+
+/**
+* Allocate index object for a stream
+*
+* @return error code: 0 iff success
+*/
+int asf_write_indices(
+    AVFormatContext *s,
+    ASFStream streams[ASF_MAX_STREAMS_NUM],
+    int num_streams);
+
+#endif /* ASF_TRIM_H */
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 359ee8b..873b789 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -1,6 +1,7 @@
 /*
  * ASF compatible demuxer
  * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2015 Vadim Belov
  *
  * This file is part of FFmpeg.
  *
@@ -38,6 +39,7 @@
 #include "riff.h"
 #include "asf.h"
 #include "asfcrypt.h"
+#include "asf_trim.h"
 
 typedef struct ASFContext {
     const AVClass *class;
@@ -81,6 +83,7 @@ typedef struct ASFContext {
 
     int no_resync_search;
     int export_xmp;
+    int direction[ASF_MAX_STREAMS_NUM];
 } ASFContext;
 
 static const AVOption options[] = {
@@ -672,6 +675,8 @@ static int asf_read_metadata(AVFormatContext *s, int64_t size)
         av_log(s, AV_LOG_TRACE, "%d stream %d name_len %2d type %d len %4d <%s>\n",
                 i, stream_num, name_len, value_type, value_len, name);
 
+        asf->direction[stream_num] = NO_STREAM_DIRECTION;
+        
         if (!strcmp(name, "AspectRatioX")){
             int aspect_x = get_value(s->pb, value_type, 16);
             if(stream_num < 128)
@@ -680,7 +685,15 @@ static int asf_read_metadata(AVFormatContext *s, int64_t size)
             int aspect_y = get_value(s->pb, value_type, 16);
             if(stream_num < 128)
                 asf->dar[stream_num].den = aspect_y;
-        } else {
+        } else if(!strcmp(name, STREAM_DIRECTION_STR) &&
+                    0 < stream_num && stream_num < 128){
+            int direction = get_value(s->pb, value_type, value_len);
+            
+            av_log(s, AV_LOG_DEBUG, "stream %d Direction is %d\n",
+                stream_num, direction);
+            
+            asf->direction[stream_num] = direction;
+        } else {            
             get_tag(s, name, value_type, value_len, 16);
         }
     }
@@ -855,6 +868,8 @@ static int asf_read_header(AVFormatContext *s)
                           &st->sample_aspect_ratio.den,
                           asf->dar[0].num, asf->dar[0].den, INT_MAX);
 
+			ff_set_stream_direction(s, asf->direction, st, i);
+            
             av_log(s, AV_LOG_TRACE, "i=%d, st->codec->codec_type:%d, asf->dar %d:%d sar=%d:%d\n",
                     i, st->codec->codec_type, asf->dar[i].num, asf->dar[i].den,
                     st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 015c731..c8ff8f8 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -1,6 +1,7 @@
 /*
  * ASF muxer
  * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2015 Vadim Belov
  *
  * This file is part of FFmpeg.
  *
@@ -27,6 +28,7 @@
 #include "internal.h"
 #include "riff.h"
 #include "asf.h"
+#include "asf_trim.h"
 
 #define ASF_INDEXED_INTERVAL    10000000
 #define ASF_INDEX_BLOCK         (1<<9)
@@ -218,7 +220,12 @@ static const AVCodecTag codec_asf_bmp_tags[] = {
     { AV_CODEC_ID_NONE,      0 },
 };
 
-#define PREROLL_TIME 3100
+/**
+ * Preroll must be 0 in order to be consistent with player
+ * instead of:
+ * #define PREROLL_TIME 3100
+ */
+#define PREROLL_TIME 0
 
 static void put_str16(AVIOContext *s, const char *tag)
 {
@@ -350,6 +357,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
     AVDictionaryEntry *tags[5];
     int header_size, n, extra_size, extra_size2, wav_extra_size, file_time;
     int has_title, has_aspect_ratio = 0;
+    int has_direction = 0; 
     int metadata_count;
     AVCodecContext *enc;
     int64_t header_offset, cur_pos, hpos;
@@ -381,6 +389,8 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
             has_aspect_ratio++;
     }
 
+    has_direction = asf_get_streams_direction(s);
+
     if (asf->is_streamed) {
         put_chunk(s, 0x4824, 0, 0xc00); /* start of stream (length will be patched later) */
     }
@@ -412,7 +422,36 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
     hpos = put_header(pb, &ff_asf_head1_guid);
     ff_put_guid(pb, &ff_asf_head2_guid);
     avio_wl16(pb, 6);
-    if (has_aspect_ratio) {
+    
+    if (has_direction) {
+        int64_t hpos2;
+        avio_wl32(pb, 26 + has_direction * 46);
+        hpos2 = put_header(pb, &ff_asf_metadata_header);        
+        avio_wl16(pb, has_direction);
+        for (n = 0; n < s->nb_streams; n++) {
+            int streamId;
+            int direction;
+
+            AVDictionaryEntry *t = av_dict_get(
+                s->streams[n]->metadata, DIRECTION_DICT_KEY, NULL, 0);
+
+            sscanf(t->value, "%d %d", &streamId, &direction);
+
+            av_log(s, AV_LOG_DEBUG, "Writing stream[%d] direction of stream %d, (%d)\n",
+                n + 1, streamId, direction);
+
+            avio_wl16(pb, 0);       // Reserved
+            avio_wl16(pb, streamId);// Stream Number
+            avio_wl16(pb, 32);      // Name Length
+            avio_wl16(pb, 5);       // Data Type 
+            avio_wl32(pb, 2);       // Data Length
+            avio_put_str16le(pb, STREAM_DIRECTION_STR);  // 32
+            avio_wl16(pb, direction);
+        }
+        end_header(pb, hpos2);
+
+    } else if (has_aspect_ratio) {
+    
         int64_t hpos2;
         avio_wl32(pb, 26 + has_aspect_ratio * 84);
         hpos2 = put_header(pb, &ff_asf_metadata_header);
@@ -657,12 +696,16 @@ static int asf_write_header(AVFormatContext *s)
     asf->nb_index_memory_alloc = ASF_INDEX_BLOCK;
     asf->maximum_packet        = 0;
 
+    if (asf_alloc_streams_index(asf->streams, s->nb_streams, ASF_INDEX_BLOCK) 
+        != 0) return -1;
+    
     /* the data-chunk-size has to be 50 (DATA_HEADER_SIZE), which is
      * data_size - asf->data_offset at the moment this function is done.
      * It is needed to use asf as a streamable format. */
     if (asf_write_header1(s, 0, DATA_HEADER_SIZE) < 0) {
         //av_free(asf);
         av_freep(&asf->index_ptr);
+        asf_free_streams_index(asf->streams, s->nb_streams);
         return -1;
     }
 
@@ -945,7 +988,17 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
             return ret;
     }
     asf->end_sec = start_sec;
-
+    
+	ret = ff_upadte_indices(
+        asf->streams,
+        pts,
+        offset, 
+        pkt->stream_index, 
+        pkt->duration,
+        ASF_INDEX_BLOCK,
+        asf->data_offset + DATA_HEADER_SIZE);
+    if (ret < 0) return ret;
+    
     return 0;
 }
 
@@ -988,6 +1041,10 @@ static int asf_write_trailer(AVFormatContext *s)
     }
     avio_flush(s->pb);
 
+    /* write indices with duration */
+    asf_write_indices(s, asf->streams, s->nb_streams);
+    avio_flush(s->pb);
+
     if (asf->is_streamed || !s->pb->seekable) {
         put_chunk(s, 0x4524, 0, 0); /* end of stream */
     } else {
@@ -997,6 +1054,7 @@ static int asf_write_trailer(AVFormatContext *s)
         asf_write_header1(s, file_size, data_size - asf->data_offset);
     }
 
+    asf_free_streams_index(asf->streams, s->nb_streams);
     av_freep(&asf->index_ptr);
     return 0;
 }
diff --git a/libavformat/cache.c b/libavformat/cache.c
index d3d12bb..b4d2835 100644
--- a/libavformat/cache.c
+++ b/libavformat/cache.c
@@ -37,13 +37,13 @@
 #if HAVE_IO_H
 #include <io.h>
 #endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <sys/stat.h>
 #include <stdlib.h>
 #include "os_support.h"
 #include "url.h"
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 typedef struct CacheEntry {
     int64_t logical_pos;
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index f07cfd7..a66035b 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -172,6 +172,8 @@ static int copy_stream_props(AVStream *st, AVStream *source_st)
     st->avg_frame_rate      = source_st->avg_frame_rate;
     st->time_base           = source_st->time_base;
     st->sample_aspect_ratio = source_st->sample_aspect_ratio;
+
+    av_dict_copy(&st->metadata, source_st->metadata, 0);
     return 0;
 }
 
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 7a93214..5d4b511 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -20,9 +20,6 @@
  */
 
 #include "config.h"
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
@@ -37,6 +34,9 @@
 #include "isom.h"
 #include "os_support.h"
 #include "url.h"
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 // See ISO/IEC 23009-1:2014 5.3.9.4.4
 typedef enum {
diff --git a/libavformat/file.c b/libavformat/file.c
index 6511328..de6745e 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -27,13 +27,13 @@
 #if HAVE_IO_H
 #include <io.h>
 #endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <sys/stat.h>
 #include <stdlib.h>
 #include "os_support.h"
 #include "url.h"
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 /* Some systems may not have S_ISFIFO */
 #ifndef S_ISFIFO
diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index 48810a9..e89be43 100644
--- a/libavformat/hdsenc.c
+++ b/libavformat/hdsenc.c
@@ -21,9 +21,6 @@
 
 #include "config.h"
 #include <float.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 
 #include "avformat.h"
 #include "internal.h"
@@ -34,6 +31,9 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 typedef struct Fragment {
     char file[1024];
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 4d9466c..2b56d4a 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -22,9 +22,6 @@
 #include "config.h"
 #include <float.h>
 #include <stdint.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 
 #include "libavutil/avassert.h"
 #include "libavutil/mathematics.h"
@@ -36,6 +33,9 @@
 #include "avformat.h"
 #include "internal.h"
 #include "os_support.h"
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 typedef struct HLSSegment {
     char filename[1024];
diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index 07173a9..1cf58fd 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -21,9 +21,6 @@
 
 #include "config.h"
 #include <float.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 
 #include "avformat.h"
 #include "internal.h"
@@ -37,6 +34,9 @@
 #include "libavutil/file.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/intreadwrite.h"
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 typedef struct Fragment {
     char file[1024];
diff --git a/libavutil/file.c b/libavutil/file.c
index 2a06be4..c9625ed 100644
--- a/libavutil/file.c
+++ b/libavutil/file.c
@@ -23,9 +23,6 @@
 #include "mem.h"
 #include <fcntl.h>
 #include <sys/stat.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #if HAVE_IO_H
 #include <io.h>
 #endif
@@ -33,6 +30,9 @@
 #include <sys/mman.h>
 #elif HAVE_MAPVIEWOFFILE
 #include <windows.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #endif
 
 typedef struct FileLogContext {
diff --git a/libavutil/file_open.c b/libavutil/file_open.c
index 3f9a67c..4c5e72b 100644
--- a/libavutil/file_open.c
+++ b/libavutil/file_open.c
@@ -22,9 +22,6 @@
 #include <stdarg.h>
 #include <fcntl.h>
 #include <sys/stat.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #if HAVE_IO_H
 #include <io.h>
 #endif
@@ -35,6 +32,9 @@
 #undef stat
 #undef fstat
 #include <windows.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <share.h>
 #include <errno.h>
 #include "wchar_filename.h"
diff --git a/libavutil/log.c b/libavutil/log.c
index b2bc65c..9b49eae 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -26,9 +26,6 @@
 
 #include "config.h"
 
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #if HAVE_IO_H
 #include <io.h>
 #endif
@@ -59,6 +56,9 @@ static int flags;
 #define NB_LEVELS 8
 #if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE
 #include <windows.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 static const uint8_t color[16 + AV_CLASS_CATEGORY_NB] = {
     [AV_LOG_PANIC  /8] = 12,
     [AV_LOG_FATAL  /8] = 12,
diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c
index 8aa8c38..31482a3 100644
--- a/libavutil/random_seed.c
+++ b/libavutil/random_seed.c
@@ -20,9 +20,6 @@
 
 #include "config.h"
 
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #if HAVE_IO_H
 #include <io.h>
 #endif
@@ -30,6 +27,9 @@
 #include <windows.h>
 #include <wincrypt.h>
 #endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <fcntl.h>
 #include <math.h>
 #include <time.h>
diff --git a/libavutil/time.c b/libavutil/time.c
index dbaee02..a337f31 100644
--- a/libavutil/time.c
+++ b/libavutil/time.c
@@ -26,12 +26,12 @@
 #if HAVE_GETTIMEOFDAY
 #include <sys/time.h>
 #endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #if HAVE_WINDOWS_H
 #include <windows.h>
 #endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 #include "time.h"
 #include "error.h"
diff --git a/tests/ref/fate/sub-aqtitle b/tests/ref/fate/sub-aqtitle
index 87253c9..417779b 100644
--- a/tests/ref/fate/sub-aqtitle
+++ b/tests/ref/fate/sub-aqtitle
@@ -1,45 +1,45 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:03:29.92,0:03:31.28,Default,,0,0,0,,Dougu?
-Dialogue: 0,0:03:33.36,0:03:35.76,Default,,0,0,0,,Zlato, jseš v pořádku?
-Dialogue: 0,0:03:37.72,0:03:39.12,Default,,0,0,0,,Měl jsi sny.
-Dialogue: 0,0:03:41.44,0:03:43.32,Default,,0,0,0,,Byly o Marsu?
-Dialogue: 0,0:03:48.92,0:03:50.52,Default,,0,0,0,,Je to lepší?
-Dialogue: 0,0:03:53.12,0:03:54.72,Default,,0,0,0,,Chudinko moje.
-Dialogue: 0,0:03:55.76,0:03:58.08,Default,,0,0,0,,Začíná to být\Nposedlost.
-Dialogue: 0,0:04:05.92,0:04:07.16,Default,,0,0,0,,Byla tam i ona?
-Dialogue: 0,0:04:09.12,0:04:10.48,Default,,0,0,0,,Kdo?
-Dialogue: 0,0:04:12.44,0:04:15.16,Default,,0,0,0,,Ta, o které jsi mi vyprávěl.\NTa bruneta.
-Dialogue: 0,0:04:16.32,0:04:17.52,Default,,0,0,0,,Lori.
-Dialogue: 0,0:04:20.32,0:04:23.16,Default,,0,0,0,,Nemůžu uvěřit\Nže žárlíš na sen.
-Dialogue: 0,0:04:23.84,0:04:26.60,Default,,0,0,0,,- Kdo je ona?\N- Nikdo.
-Dialogue: 0,0:04:26.60,0:04:28.80,Default,,0,0,0,,"Nikdo"? Jak se jmenuje?
-Dialogue: 0,0:04:28.80,0:04:30.24,Default,,0,0,0,,Nevím.
-Dialogue: 0,0:04:31.52,0:04:33.20,Default,,0,0,0,,- Pověz!\N- Nevím!
-Dialogue: 0,0:04:33.20,0:04:35.48,Default,,0,0,0,,Radši bys mi to měl říct!
-Dialogue: 0,0:04:35.48,0:04:39.16,Default,,0,0,0,,To není legrace Dougu.\NZdá se ti o ní každou noc.
-Dialogue: 0,0:04:39.16,0:04:41.84,Default,,0,0,0,,Ale vždy se ráno probudím.
-Dialogue: 0,0:04:41.84,0:04:43.28,Default,,0,0,0,,Nech mě být!
-Dialogue: 0,0:04:45.72,0:04:47.76,Default,,0,0,0,,No tak, zlato.
-Dialogue: 0,0:04:47.76,0:04:50.72,Default,,0,0,0,,Ty víš, že jsi dívkou\Nmých snů.
-Dialogue: 0,0:04:50.72,0:04:52.40,Default,,0,0,0,,Myslíš to vážně?
-Dialogue: 0,0:04:53.48,0:04:55.32,Default,,0,0,0,,To víš že ano.
-Dialogue: 0,0:05:04.40,0:05:07.20,Default,,0,0,0,,Dám ti něco\No čem budeš snít.
-Dialogue: 0,0:05:16.76,0:05:16.92,Default,,0,0,0,,Premiér se útoku ubránil\Na řekl, že zbraně založené na vesmírných...
-Dialogue: 0,0:05:16.92,0:05:20.36,Default,,0,0,0,,Premiér se útoku ubránil\Na řekl, že zbraně založené na vesmírných...
-Dialogue: 0,0:05:20.36,0:05:24.36,Default,,0,0,0,,jsou naše jediná obrana proti\Npočetní převaze z jižního bloku.
-Dialogue: 0,0:05:24.36,0:05:26.76,Default,,0,0,0,,A další násilí na Marsu...
-Dialogue: 0,0:05:26.76,1:44:16.00,Default,,0,0,0,,[...]
-Dialogue: 0,1:44:16.00,1:44:17.60,Default,,0,0,0,,Co se děje?
-Dialogue: 0,1:44:17.60,1:44:21.28,Default,,0,0,0,,Měl jsem jenom hroznou představu.\NCo když tohle je jenom sen?
-Dialogue: 0,1:44:22.76,1:44:25.68,Default,,0,0,0,,Tak mi dej ryhcle pusu\Nnež se probudíš.
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:03:29.92,0:03:31.28,Default,,0,0,0,,Dougu?
+Dialogue: 0,0:03:33.36,0:03:35.76,Default,,0,0,0,,Zlato, jseš v pořádku?
+Dialogue: 0,0:03:37.72,0:03:39.12,Default,,0,0,0,,Měl jsi sny.
+Dialogue: 0,0:03:41.44,0:03:43.32,Default,,0,0,0,,Byly o Marsu?
+Dialogue: 0,0:03:48.92,0:03:50.52,Default,,0,0,0,,Je to lepší?
+Dialogue: 0,0:03:53.12,0:03:54.72,Default,,0,0,0,,Chudinko moje.
+Dialogue: 0,0:03:55.76,0:03:58.08,Default,,0,0,0,,Začíná to být\Nposedlost.
+Dialogue: 0,0:04:05.92,0:04:07.16,Default,,0,0,0,,Byla tam i ona?
+Dialogue: 0,0:04:09.12,0:04:10.48,Default,,0,0,0,,Kdo?
+Dialogue: 0,0:04:12.44,0:04:15.16,Default,,0,0,0,,Ta, o které jsi mi vyprávěl.\NTa bruneta.
+Dialogue: 0,0:04:16.32,0:04:17.52,Default,,0,0,0,,Lori.
+Dialogue: 0,0:04:20.32,0:04:23.16,Default,,0,0,0,,Nemůžu uvěřit\Nže žárlíš na sen.
+Dialogue: 0,0:04:23.84,0:04:26.60,Default,,0,0,0,,- Kdo je ona?\N- Nikdo.
+Dialogue: 0,0:04:26.60,0:04:28.80,Default,,0,0,0,,"Nikdo"? Jak se jmenuje?
+Dialogue: 0,0:04:28.80,0:04:30.24,Default,,0,0,0,,Nevím.
+Dialogue: 0,0:04:31.52,0:04:33.20,Default,,0,0,0,,- Pověz!\N- Nevím!
+Dialogue: 0,0:04:33.20,0:04:35.48,Default,,0,0,0,,Radši bys mi to měl říct!
+Dialogue: 0,0:04:35.48,0:04:39.16,Default,,0,0,0,,To není legrace Dougu.\NZdá se ti o ní každou noc.
+Dialogue: 0,0:04:39.16,0:04:41.84,Default,,0,0,0,,Ale vždy se ráno probudím.
+Dialogue: 0,0:04:41.84,0:04:43.28,Default,,0,0,0,,Nech mě být!
+Dialogue: 0,0:04:45.72,0:04:47.76,Default,,0,0,0,,No tak, zlato.
+Dialogue: 0,0:04:47.76,0:04:50.72,Default,,0,0,0,,Ty víš, že jsi dívkou\Nmých snů.
+Dialogue: 0,0:04:50.72,0:04:52.40,Default,,0,0,0,,Myslíš to vážně?
+Dialogue: 0,0:04:53.48,0:04:55.32,Default,,0,0,0,,To víš že ano.
+Dialogue: 0,0:05:04.40,0:05:07.20,Default,,0,0,0,,Dám ti něco\No čem budeš snít.
+Dialogue: 0,0:05:16.76,0:05:16.92,Default,,0,0,0,,Premiér se útoku ubránil\Na řekl, že zbraně založené na vesmírných...
+Dialogue: 0,0:05:16.92,0:05:20.36,Default,,0,0,0,,Premiér se útoku ubránil\Na řekl, že zbraně založené na vesmírných...
+Dialogue: 0,0:05:20.36,0:05:24.36,Default,,0,0,0,,jsou naše jediná obrana proti\Npočetní převaze z jižního bloku.
+Dialogue: 0,0:05:24.36,0:05:26.76,Default,,0,0,0,,A další násilí na Marsu...
+Dialogue: 0,0:05:26.76,1:44:16.00,Default,,0,0,0,,[...]
+Dialogue: 0,1:44:16.00,1:44:17.60,Default,,0,0,0,,Co se děje?
+Dialogue: 0,1:44:17.60,1:44:21.28,Default,,0,0,0,,Měl jsem jenom hroznou představu.\NCo když tohle je jenom sen?
+Dialogue: 0,1:44:22.76,1:44:25.68,Default,,0,0,0,,Tak mi dej ryhcle pusu\Nnež se probudíš.
diff --git a/tests/ref/fate/sub-charenc b/tests/ref/fate/sub-charenc
index ed5cdbe..9051e28 100644
--- a/tests/ref/fate/sub-charenc
+++ b/tests/ref/fate/sub-charenc
@@ -1,62 +1,62 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:32.95,0:00:38.25,Default,,0,0,0,,КОЛУМБИА ПИКЧЪРС - АЗИЯ\NСОНИ ПИКЧЪРС и Е.Е. Co.\Nпредставят
-Dialogue: 0,0:00:52.76,0:00:58.60,Default,,0,0,0,,Т И Г Ъ Р   И   Д Р А К О Н
-Dialogue: 0,0:01:22.17,0:01:24.05,Default,,0,0,0,,Учителят Ли е тук.
-Dialogue: 0,0:01:45.48,0:01:47.32,Default,,0,0,0,,Шу Лиен!
-Dialogue: 0,0:01:54.53,0:01:57.24,Default,,0,0,0,,Ли Му Бай е тук.
-Dialogue: 0,0:02:05.83,0:02:09.00,Default,,0,0,0,,- Как вървят нещата?\N- Добре. Моля, влезте!
-Dialogue: 0,0:02:23.48,0:02:26.52,Default,,0,0,0,,Му Бай...\NМина много време.
-Dialogue: 0,0:02:26.73,0:02:28.11,Default,,0,0,0,,Така е.
-Dialogue: 0,0:02:28.57,0:02:31.41,Default,,0,0,0,,- Как върви бизнесът?\N- Добре.
-Dialogue: 0,0:02:31.61,0:02:33.90,Default,,0,0,0,,- А ти как си?\N- Добре.
-Dialogue: 0,0:02:40.16,0:02:42.79,Default,,0,0,0,,Монахът Дзенг каза,\Nче си в планината Удан.
-Dialogue: 0,0:02:43.04,0:02:46.54,Default,,0,0,0,,Каза, че практикуваш\Nдълбока медитация.
-Dialogue: 0,0:02:48.84,0:02:50.68,Default,,0,0,0,,Сигурно в планината\Nе много спокойно.
-Dialogue: 0,0:02:51.25,0:02:53.46,Default,,0,0,0,,Завиждам ти.
-Dialogue: 0,0:02:53.67,0:02:58.34,Default,,0,0,0,,Имам толкова много работа,\Nпочти не ми остава\Nвреме за почивка.
-Dialogue: 0,0:03:00.26,0:03:03.89,Default,,0,0,0,,Оставих обучението рано.
-Dialogue: 0,0:03:05.69,0:03:11.28,Default,,0,0,0,,Защо? Ти си боец на Удан.\NОбучението е всичко.
-Dialogue: 0,0:03:11.90,0:03:14.86,Default,,0,0,0,,По време на медитация…
-Dialogue: 0,0:03:15.07,0:03:18.49,Default,,0,0,0,,стигнах до място,\Nкъдето имаше дълбока тишина...
-Dialogue: 0,0:03:19.87,0:03:22.79,Default,,0,0,0,,бях обграден от светлина...
-Dialogue: 0,0:03:23.41,0:03:28.08,Default,,0,0,0,,времето и пространството изчезнаха.
-Dialogue: 0,0:03:28.71,0:03:34.09,Default,,0,0,0,,Достигнах до състояние, за което\Nучителят не ми беше казвал.
-Dialogue: 0,0:03:37.05,0:03:39.14,Default,,0,0,0,,Постигнал си просветление?
-Dialogue: 0,0:03:39.34,0:03:41.22,Default,,0,0,0,,Не.
-Dialogue: 0,0:03:41.72,0:03:45.81,Default,,0,0,0,,Не почувствах блаженството\Nна просветлението.
-Dialogue: 0,0:03:46.02,0:03:52.86,Default,,0,0,0,,Вместо това... ме обгърна\Nбезкрайна мъка.
-Dialogue: 0,0:03:53.40,0:03:56.57,Default,,0,0,0,,Не можах да издържа.
-Dialogue: 0,0:03:57.49,0:03:59.74,Default,,0,0,0,,Прекъснах медитацията си.
-Dialogue: 0,0:03:59.95,0:04:02.24,Default,,0,0,0,,Не можах да продължа.
-Dialogue: 0,0:04:03.20,0:04:07.79,Default,,0,0,0,,Нещо...\Nме дърпаше назад.
-Dialogue: 0,0:04:09.62,0:04:10.91,Default,,0,0,0,,Какво беше?
-Dialogue: 0,0:04:15.46,0:04:18.00,Default,,0,0,0,,Нещо, от което не\Nмога да се освободя.
-Dialogue: 0,0:04:23.39,0:04:24.68,Default,,0,0,0,,Скоро ли ще тръгваш?
-Dialogue: 0,0:04:26.77,0:04:30.27,Default,,0,0,0,,Подготвяме охрана\Nза една доставка...
-Dialogue: 0,0:04:30.48,0:04:31.94,Default,,0,0,0,,за Пекин.
-Dialogue: 0,0:04:32.56,0:04:34.10,Default,,0,0,0,,Мога ли да те помоля...
-Dialogue: 0,0:04:35.07,0:04:38.82,Default,,0,0,0,,да занесеш нещо на господин Те.
-Dialogue: 0,0:04:44.28,0:04:48.12,Default,,0,0,0,,Зеленият меч на Съдбата!?\NДаваш го на господин Те!?
-Dialogue: 0,0:04:48.37,0:04:52.67,Default,,0,0,0,,Да. Той винаги е бил\Nнашият най-голям покровител.
-Dialogue: 0,0:04:52.88,0:04:56.55,Default,,0,0,0,,Не разбирам.\NКак можеш да се разделиш с него?
-Dialogue: 0,0:04:56.76,0:04:59.93,Default,,0,0,0,,Той винаги е бил с теб.
-Dialogue: 0,0:05:01.18,0:05:05.52,Default,,0,0,0,,Твърде много хора са\Nзагинали от това острие.
-Dialogue: 0,0:05:09.68,0:05:14.52,Default,,0,0,0,,Чисто е единствено защото\Nкръвта се отмива лесно.
-Dialogue: 0,0:05:15.40,0:05:20.61,Default,,0,0,0,,Ти го използваш справедливо.\NДостоен си за него.
-Dialogue: 0,0:05:23.66,0:05:27.37,Default,,0,0,0,,Дойде време\Nда го оставя.
-Dialogue: 0,0:05:27.58,0:05:31.21,Default,,0,0,0,,Е, какво ще правиш\Nот сега нататък?
-Dialogue: 0,0:05:34.71,0:05:37.50,Default,,0,0,0,,Ела с мен в Пекин.
-Dialogue: 0,0:05:37.71,0:05:41.42,Default,,0,0,0,,Лично ще дадеш меча\Nна господин Те.
-Dialogue: 0,0:05:41.68,0:05:44.89,Default,,0,0,0,,Ще бъде както преди.
-Dialogue: 0,0:05:47.01,0:05:51.68,Default,,0,0,0,,Първо трябва да отида\Nна гроба на учителя си.
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:00:32.95,0:00:38.25,Default,,0,0,0,,КОЛУМБИА ПИКЧЪРС - АЗИЯ\NСОНИ ПИКЧЪРС и Е.Е. Co.\Nпредставят
+Dialogue: 0,0:00:52.76,0:00:58.60,Default,,0,0,0,,Т И Г Ъ Р   И   Д Р А К О Н
+Dialogue: 0,0:01:22.17,0:01:24.05,Default,,0,0,0,,Учителят Ли е тук.
+Dialogue: 0,0:01:45.48,0:01:47.32,Default,,0,0,0,,Шу Лиен!
+Dialogue: 0,0:01:54.53,0:01:57.24,Default,,0,0,0,,Ли Му Бай е тук.
+Dialogue: 0,0:02:05.83,0:02:09.00,Default,,0,0,0,,- Как вървят нещата?\N- Добре. Моля, влезте!
+Dialogue: 0,0:02:23.48,0:02:26.52,Default,,0,0,0,,Му Бай...\NМина много време.
+Dialogue: 0,0:02:26.73,0:02:28.11,Default,,0,0,0,,Така е.
+Dialogue: 0,0:02:28.57,0:02:31.41,Default,,0,0,0,,- Как върви бизнесът?\N- Добре.
+Dialogue: 0,0:02:31.61,0:02:33.90,Default,,0,0,0,,- А ти как си?\N- Добре.
+Dialogue: 0,0:02:40.16,0:02:42.79,Default,,0,0,0,,Монахът Дзенг каза,\Nче си в планината Удан.
+Dialogue: 0,0:02:43.04,0:02:46.54,Default,,0,0,0,,Каза, че практикуваш\Nдълбока медитация.
+Dialogue: 0,0:02:48.84,0:02:50.68,Default,,0,0,0,,Сигурно в планината\Nе много спокойно.
+Dialogue: 0,0:02:51.25,0:02:53.46,Default,,0,0,0,,Завиждам ти.
+Dialogue: 0,0:02:53.67,0:02:58.34,Default,,0,0,0,,Имам толкова много работа,\Nпочти не ми остава\Nвреме за почивка.
+Dialogue: 0,0:03:00.26,0:03:03.89,Default,,0,0,0,,Оставих обучението рано.
+Dialogue: 0,0:03:05.69,0:03:11.28,Default,,0,0,0,,Защо? Ти си боец на Удан.\NОбучението е всичко.
+Dialogue: 0,0:03:11.90,0:03:14.86,Default,,0,0,0,,По време на медитация…
+Dialogue: 0,0:03:15.07,0:03:18.49,Default,,0,0,0,,стигнах до място,\Nкъдето имаше дълбока тишина...
+Dialogue: 0,0:03:19.87,0:03:22.79,Default,,0,0,0,,бях обграден от светлина...
+Dialogue: 0,0:03:23.41,0:03:28.08,Default,,0,0,0,,времето и пространството изчезнаха.
+Dialogue: 0,0:03:28.71,0:03:34.09,Default,,0,0,0,,Достигнах до състояние, за което\Nучителят не ми беше казвал.
+Dialogue: 0,0:03:37.05,0:03:39.14,Default,,0,0,0,,Постигнал си просветление?
+Dialogue: 0,0:03:39.34,0:03:41.22,Default,,0,0,0,,Не.
+Dialogue: 0,0:03:41.72,0:03:45.81,Default,,0,0,0,,Не почувствах блаженството\Nна просветлението.
+Dialogue: 0,0:03:46.02,0:03:52.86,Default,,0,0,0,,Вместо това... ме обгърна\Nбезкрайна мъка.
+Dialogue: 0,0:03:53.40,0:03:56.57,Default,,0,0,0,,Не можах да издържа.
+Dialogue: 0,0:03:57.49,0:03:59.74,Default,,0,0,0,,Прекъснах медитацията си.
+Dialogue: 0,0:03:59.95,0:04:02.24,Default,,0,0,0,,Не можах да продължа.
+Dialogue: 0,0:04:03.20,0:04:07.79,Default,,0,0,0,,Нещо...\Nме дърпаше назад.
+Dialogue: 0,0:04:09.62,0:04:10.91,Default,,0,0,0,,Какво беше?
+Dialogue: 0,0:04:15.46,0:04:18.00,Default,,0,0,0,,Нещо, от което не\Nмога да се освободя.
+Dialogue: 0,0:04:23.39,0:04:24.68,Default,,0,0,0,,Скоро ли ще тръгваш?
+Dialogue: 0,0:04:26.77,0:04:30.27,Default,,0,0,0,,Подготвяме охрана\Nза една доставка...
+Dialogue: 0,0:04:30.48,0:04:31.94,Default,,0,0,0,,за Пекин.
+Dialogue: 0,0:04:32.56,0:04:34.10,Default,,0,0,0,,Мога ли да те помоля...
+Dialogue: 0,0:04:35.07,0:04:38.82,Default,,0,0,0,,да занесеш нещо на господин Те.
+Dialogue: 0,0:04:44.28,0:04:48.12,Default,,0,0,0,,Зеленият меч на Съдбата!?\NДаваш го на господин Те!?
+Dialogue: 0,0:04:48.37,0:04:52.67,Default,,0,0,0,,Да. Той винаги е бил\Nнашият най-голям покровител.
+Dialogue: 0,0:04:52.88,0:04:56.55,Default,,0,0,0,,Не разбирам.\NКак можеш да се разделиш с него?
+Dialogue: 0,0:04:56.76,0:04:59.93,Default,,0,0,0,,Той винаги е бил с теб.
+Dialogue: 0,0:05:01.18,0:05:05.52,Default,,0,0,0,,Твърде много хора са\Nзагинали от това острие.
+Dialogue: 0,0:05:09.68,0:05:14.52,Default,,0,0,0,,Чисто е единствено защото\Nкръвта се отмива лесно.
+Dialogue: 0,0:05:15.40,0:05:20.61,Default,,0,0,0,,Ти го използваш справедливо.\NДостоен си за него.
+Dialogue: 0,0:05:23.66,0:05:27.37,Default,,0,0,0,,Дойде време\Nда го оставя.
+Dialogue: 0,0:05:27.58,0:05:31.21,Default,,0,0,0,,Е, какво ще правиш\Nот сега нататък?
+Dialogue: 0,0:05:34.71,0:05:37.50,Default,,0,0,0,,Ела с мен в Пекин.
+Dialogue: 0,0:05:37.71,0:05:41.42,Default,,0,0,0,,Лично ще дадеш меча\Nна господин Те.
+Dialogue: 0,0:05:41.68,0:05:44.89,Default,,0,0,0,,Ще бъде както преди.
+Dialogue: 0,0:05:47.01,0:05:51.68,Default,,0,0,0,,Първо трябва да отида\Nна гроба на учителя си.
diff --git a/tests/ref/fate/sub-jacosub b/tests/ref/fate/sub-jacosub
index a30fe4a..4bdc5e6 100644
--- a/tests/ref/fate/sub-jacosub
+++ b/tests/ref/fate/sub-jacosub
@@ -1,23 +1,23 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:00.12,0:00:04.36,Default,,0,0,0,,{\an5}JACOsub\N\NThis script demonstrates some of the capabilities of JACOsub.
-Dialogue: 0,0:00:04.12,0:00:14.86,Default,,0,0,0,,{\an8}Text may be positioned at the top,
-Dialogue: 0,0:00:05.12,0:00:17.46,Default,,0,0,0,,{\an5}middle,
-Dialogue: 0,0:00:06.12,0:00:20.06,Default,,0,0,0,,{\an2}or bottom of the screen.
-Dialogue: 0,0:00:08.12,0:00:27.36,Default,,0,0,0,,{\an5}{this is a comment} (And, you just saw, {another comment} timing ranges for different lines of text.
-Dialogue: 0,0:00:11.12,0:00:35.86,Default,,0,0,0,,{\an1}Within margin constraints\Nthat you set, text may be\Nleft justified,
-Dialogue: 0,0:00:13.62,0:00:42.11,Default,,0,0,0,,{\an2}{the JC is redundant - it's the default}center\Njustified,
-Dialogue: 0,0:00:14.87,0:00:45.86,Default,,0,0,0,,{\an3}and also\Nright justified.
-Dialogue: 0,0:00:22.42,0:01:12.76,Default,,0,0,0,,Text may appear in different styles\N(Normal, {\b1}Bold{\r}, {\i1}Italic{\r})
-Dialogue: 0,0:01:16.12,0:03:53.36,Default,,0,0,0,,{\an5}\N\NAt that time, you may press any key to return to the Editor.
-Dialogue: 0,0:01:16.12,0:03:53.36,Default,,0,0,0,,OK, this script will be finished when the screen goes blank.
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:00:00.12,0:00:04.36,Default,,0,0,0,,{\an5}JACOsub\N\NThis script demonstrates some of the capabilities of JACOsub.
+Dialogue: 0,0:00:04.12,0:00:14.86,Default,,0,0,0,,{\an8}Text may be positioned at the top,
+Dialogue: 0,0:00:05.12,0:00:17.46,Default,,0,0,0,,{\an5}middle,
+Dialogue: 0,0:00:06.12,0:00:20.06,Default,,0,0,0,,{\an2}or bottom of the screen.
+Dialogue: 0,0:00:08.12,0:00:27.36,Default,,0,0,0,,{\an5}{this is a comment} (And, you just saw, {another comment} timing ranges for different lines of text.
+Dialogue: 0,0:00:11.12,0:00:35.86,Default,,0,0,0,,{\an1}Within margin constraints\Nthat you set, text may be\Nleft justified,
+Dialogue: 0,0:00:13.62,0:00:42.11,Default,,0,0,0,,{\an2}{the JC is redundant - it's the default}center\Njustified,
+Dialogue: 0,0:00:14.87,0:00:45.86,Default,,0,0,0,,{\an3}and also\Nright justified.
+Dialogue: 0,0:00:22.42,0:01:12.76,Default,,0,0,0,,Text may appear in different styles\N(Normal, {\b1}Bold{\r}, {\i1}Italic{\r})
+Dialogue: 0,0:01:16.12,0:03:53.36,Default,,0,0,0,,{\an5}\N\NAt that time, you may press any key to return to the Editor.
+Dialogue: 0,0:01:16.12,0:03:53.36,Default,,0,0,0,,OK, this script will be finished when the screen goes blank.
diff --git a/tests/ref/fate/sub-microdvd b/tests/ref/fate/sub-microdvd
index d2170bc..0332da9 100644
--- a/tests/ref/fate/sub-microdvd
+++ b/tests/ref/fate/sub-microdvd
@@ -1,22 +1,22 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Comic Sans MS,30,&H123456,&H123456,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:40.00,0:00:52.00,Default,,0,0,0,,{\c&H345678&}foo{\c}\N{\c&HABCDEF&}bar{\c}\Nbla
-Dialogue: 0,0:00:52.00,0:00:56.00,Default,,0,0,0,,{\u1}{\s1}{\i1}{\b1}italic bold underline strike{\s0}{\u0}\Nitalic bold no-underline no-strike
-Dialogue: 0,0:00:56.00,0:01:00.00,Default,,0,0,0,,back to
-Dialogue: 0,0:01:00.00,0:01:04.00,Default,,0,0,0,,the future
-Dialogue: 0,0:01:20.00,0:01:24.92,Default,,0,0,0,,{\pos(10,20)}Some more crazy stuff
-Dialogue: 0,0:02:14.00,0:02:15.60,Default,,0,0,0,,this subtitle...
-Dialogue: 0,0:02:15.60,0:02:40.00,Default,,0,0,0,,...continues up to...
-Dialogue: 0,0:02:40.00,0:03:00.00,Default,,0,0,0,,this one.
-Dialogue: 0,0:03:04.00,0:03:12.00,Default,,0,0,0,,and now...
-Dialogue: 0,0:03:12.00,9:59:59.99,Default,,0,0,0,,...to the end of the presentation
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Comic Sans MS,30,&H123456,&H123456,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:00:40.00,0:00:52.00,Default,,0,0,0,,{\c&H345678&}foo{\c}\N{\c&HABCDEF&}bar{\c}\Nbla
+Dialogue: 0,0:00:52.00,0:00:56.00,Default,,0,0,0,,{\u1}{\s1}{\i1}{\b1}italic bold underline strike{\s0}{\u0}\Nitalic bold no-underline no-strike
+Dialogue: 0,0:00:56.00,0:01:00.00,Default,,0,0,0,,back to
+Dialogue: 0,0:01:00.00,0:01:04.00,Default,,0,0,0,,the future
+Dialogue: 0,0:01:20.00,0:01:24.92,Default,,0,0,0,,{\pos(10,20)}Some more crazy stuff
+Dialogue: 0,0:02:14.00,0:02:15.60,Default,,0,0,0,,this subtitle...
+Dialogue: 0,0:02:15.60,0:02:40.00,Default,,0,0,0,,...continues up to...
+Dialogue: 0,0:02:40.00,0:03:00.00,Default,,0,0,0,,this one.
+Dialogue: 0,0:03:04.00,0:03:12.00,Default,,0,0,0,,and now...
+Dialogue: 0,0:03:12.00,9:59:59.99,Default,,0,0,0,,...to the end of the presentation
diff --git a/tests/ref/fate/sub-movtext b/tests/ref/fate/sub-movtext
index 6a90e96..8b46501 100644
--- a/tests/ref/fate/sub-movtext
+++ b/tests/ref/fate/sub-movtext
@@ -1,15 +1,15 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:00.97,0:00:02.54,Default,,0,0,0,,- Test 1.\N- Test 2.
-Dialogue: 0,0:00:03.05,0:00:04.74,Default,,0,0,0,,Test 3.
-Dialogue: 0,0:00:05.85,0:00:08.14,Default,,0,0,0,,- Test 4.\N- Test 5.
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:00:00.97,0:00:02.54,Default,,0,0,0,,- Test 1.\N- Test 2.
+Dialogue: 0,0:00:03.05,0:00:04.74,Default,,0,0,0,,Test 3.
+Dialogue: 0,0:00:05.85,0:00:08.14,Default,,0,0,0,,- Test 4.\N- Test 5.
diff --git a/tests/ref/fate/sub-mpl2 b/tests/ref/fate/sub-mpl2
index 72fc0fc..a985760 100644
--- a/tests/ref/fate/sub-mpl2
+++ b/tests/ref/fate/sub-mpl2
@@ -1,16 +1,16 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:00.00,0:00:01.20,Default,,0,0,0,,Foo\Nbar\Nbla
-Dialogue: 0,0:00:04.10,0:00:05.30,Default,,0,0,0,,{\i1}italic{\r}\N{\b1}bold{\r}\N{\b1}{\i1}italicbold
-Dialogue: 0,0:00:05.30,0:00:07.20,Default,,0,0,0,,{\u1}underline{\r}\Nnormal
-Dialogue: 0,0:00:08.40,0:00:12.80,Default,,0,0,0,,hello
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:00:00.00,0:00:01.20,Default,,0,0,0,,Foo\Nbar\Nbla
+Dialogue: 0,0:00:04.10,0:00:05.30,Default,,0,0,0,,{\i1}italic{\r}\N{\b1}bold{\r}\N{\b1}{\i1}italicbold
+Dialogue: 0,0:00:05.30,0:00:07.20,Default,,0,0,0,,{\u1}underline{\r}\Nnormal
+Dialogue: 0,0:00:08.40,0:00:12.80,Default,,0,0,0,,hello
diff --git a/tests/ref/fate/sub-mpsub b/tests/ref/fate/sub-mpsub
index 890ceb0..9fc2267 100644
--- a/tests/ref/fate/sub-mpsub
+++ b/tests/ref/fate/sub-mpsub
@@ -1,33 +1,33 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:15.00,0:00:18.00,Default,,0,0,0,,A long, long time ago...
-Dialogue: 0,0:00:18.00,0:00:21.00,Default,,0,0,0,,in a galaxy far away...
-Dialogue: 0,0:00:21.00,0:00:24.00,Default,,0,0,0,,Naboo was under an attack.
-Dialogue: 0,0:00:25.00,0:00:27.50,Default,,0,0,0,,And I thought me and\NQui-Gon Jinn could
-Dialogue: 0,0:00:27.50,0:00:30.00,Default,,0,0,0,,talk the Federation into
-Dialogue: 0,0:00:30.00,0:00:34.00,Default,,0,0,0,,...maybe cutting them a\Nlittle slack.
-Dialogue: 0,0:00:36.00,0:00:39.00,Default,,0,0,0,,But their response, it\Ndidn't thrill us,
-Dialogue: 0,0:00:39.00,0:00:42.00,Default,,0,0,0,,They locked the doors,\Nand tried to kill us.
-Dialogue: 0,0:00:42.00,0:00:44.50,Default,,0,0,0,,We escaped from that gas,
-Dialogue: 0,0:00:44.50,0:00:48.00,Default,,0,0,0,,then met Jar-jar and\NBoss-Nass.
-Dialogue: 0,0:00:49.00,0:00:55.00,Default,,0,0,0,,We took a bongo from the\Nscene and we went to\NTheed to see the Queen.
-Dialogue: 0,0:00:55.00,0:01:00.00,Default,,0,0,0,,We all wound' up on\NTatooine.
-Dialogue: 0,0:01:00.00,0:01:06.00,Default,,0,0,0,,That's where, we've found\Nthis boy.
-Dialogue: 0,0:01:06.00,0:01:10.00,Default,,0,0,0,,Oh my, my this here\NAnakin guy,
-Dialogue: 0,0:01:10.00,0:01:15.00,Default,,0,0,0,,maybe Vader someday\Nlater now he's just\Na small fry.
-Dialogue: 0,0:01:15.00,0:01:19.00,Default,,0,0,0,,And he left his home and\Nkissed his mommy goodbye,
-Dialogue: 0,0:01:19.00,0:01:24.00,Default,,0,0,0,,singing "Soon I'm gonna be\Na Jedi!"
-Dialogue: 0,0:01:30.00,0:01:36.00,Default,,0,0,0,,Did you know this junkyard\Nslave isn't even old enough\Nto shave,
-Dialogue: 0,0:01:36.00,0:01:39.00,Default,,0,0,0,,but he can use the Force,\Nthey say.
-Dialogue: 0,0:01:40.00,0:01:46.00,Default,,0,0,0,,Ahh, do you see him hitting\Non the queen though he's\Njust nine and she's fourteen
-Dialogue: 0,0:01:46.00,0:01:52.00,Default,,0,0,0,,yeah, he's probably gonna\Nmarry her, someday!
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:00:15.00,0:00:18.00,Default,,0,0,0,,A long, long time ago...
+Dialogue: 0,0:00:18.00,0:00:21.00,Default,,0,0,0,,in a galaxy far away...
+Dialogue: 0,0:00:21.00,0:00:24.00,Default,,0,0,0,,Naboo was under an attack.
+Dialogue: 0,0:00:25.00,0:00:27.50,Default,,0,0,0,,And I thought me and\NQui-Gon Jinn could
+Dialogue: 0,0:00:27.50,0:00:30.00,Default,,0,0,0,,talk the Federation into
+Dialogue: 0,0:00:30.00,0:00:34.00,Default,,0,0,0,,...maybe cutting them a\Nlittle slack.
+Dialogue: 0,0:00:36.00,0:00:39.00,Default,,0,0,0,,But their response, it\Ndidn't thrill us,
+Dialogue: 0,0:00:39.00,0:00:42.00,Default,,0,0,0,,They locked the doors,\Nand tried to kill us.
+Dialogue: 0,0:00:42.00,0:00:44.50,Default,,0,0,0,,We escaped from that gas,
+Dialogue: 0,0:00:44.50,0:00:48.00,Default,,0,0,0,,then met Jar-jar and\NBoss-Nass.
+Dialogue: 0,0:00:49.00,0:00:55.00,Default,,0,0,0,,We took a bongo from the\Nscene and we went to\NTheed to see the Queen.
+Dialogue: 0,0:00:55.00,0:01:00.00,Default,,0,0,0,,We all wound' up on\NTatooine.
+Dialogue: 0,0:01:00.00,0:01:06.00,Default,,0,0,0,,That's where, we've found\Nthis boy.
+Dialogue: 0,0:01:06.00,0:01:10.00,Default,,0,0,0,,Oh my, my this here\NAnakin guy,
+Dialogue: 0,0:01:10.00,0:01:15.00,Default,,0,0,0,,maybe Vader someday\Nlater now he's just\Na small fry.
+Dialogue: 0,0:01:15.00,0:01:19.00,Default,,0,0,0,,And he left his home and\Nkissed his mommy goodbye,
+Dialogue: 0,0:01:19.00,0:01:24.00,Default,,0,0,0,,singing "Soon I'm gonna be\Na Jedi!"
+Dialogue: 0,0:01:30.00,0:01:36.00,Default,,0,0,0,,Did you know this junkyard\Nslave isn't even old enough\Nto shave,
+Dialogue: 0,0:01:36.00,0:01:39.00,Default,,0,0,0,,but he can use the Force,\Nthey say.
+Dialogue: 0,0:01:40.00,0:01:46.00,Default,,0,0,0,,Ahh, do you see him hitting\Non the queen though he's\Njust nine and she's fourteen
+Dialogue: 0,0:01:46.00,0:01:52.00,Default,,0,0,0,,yeah, he's probably gonna\Nmarry her, someday!
diff --git a/tests/ref/fate/sub-mpsub-frames b/tests/ref/fate/sub-mpsub-frames
index 64528ec..613037b 100644
--- a/tests/ref/fate/sub-mpsub-frames
+++ b/tests/ref/fate/sub-mpsub-frames
@@ -1,14 +1,14 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:01.00,0:00:02.48,Default,,0,0,0,,Start at 1sec,\Nlast 1.5 seconds
-Dialogue: 0,0:00:02.52,0:00:11.52,Default,,0,0,0,,One frame later,\Nduring 9 seconds
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:00:01.00,0:00:02.48,Default,,0,0,0,,Start at 1sec,\Nlast 1.5 seconds
+Dialogue: 0,0:00:02.52,0:00:11.52,Default,,0,0,0,,One frame later,\Nduring 9 seconds
diff --git a/tests/ref/fate/sub-pjs b/tests/ref/fate/sub-pjs
index 799c62b..6ece423 100644
--- a/tests/ref/fate/sub-pjs
+++ b/tests/ref/fate/sub-pjs
@@ -1,15 +1,15 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:04:04.70,0:04:11.30,Default,,0,0,0,,You should come to the Drama Club, too.
-Dialogue: 0,0:04:11.30,0:04:19.40,Default,,0,0,0,,Yeah. The Drama Club is worried\Nthat you haven't been coming.
-Dialogue: 0,0:04:20.30,0:04:27.50,Default,,0,0,0,,I see. Sorry, I'll drop by next time.
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:04:04.70,0:04:11.30,Default,,0,0,0,,You should come to the Drama Club, too.
+Dialogue: 0,0:04:11.30,0:04:19.40,Default,,0,0,0,,Yeah. The Drama Club is worried\Nthat you haven't been coming.
+Dialogue: 0,0:04:20.30,0:04:27.50,Default,,0,0,0,,I see. Sorry, I'll drop by next time.
diff --git a/tests/ref/fate/sub-realtext b/tests/ref/fate/sub-realtext
index cd9aa5a..e37b200 100644
--- a/tests/ref/fate/sub-realtext
+++ b/tests/ref/fate/sub-realtext
@@ -1,17 +1,17 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,,Mary had a little lamb, \N
-Dialogue: 0,0:00:03.00,0:00:18.00,Default,,0,0,0,,little lamb, \N
-Dialogue: 0,0:00:06.99,0:00:21.99,Default,,0,0,0,,little lamb, \N
-Dialogue: 0,0:00:09.00,0:00:23.00,Default,,0,0,0,,Mary had a little lamb \N
-Dialogue: 0,0:00:12.34,0:00:27.34,Default,,0,0,0,,whose fleece was white as snow. 
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,,Mary had a little lamb, \N
+Dialogue: 0,0:00:03.00,0:00:18.00,Default,,0,0,0,,little lamb, \N
+Dialogue: 0,0:00:06.99,0:00:21.99,Default,,0,0,0,,little lamb, \N
+Dialogue: 0,0:00:09.00,0:00:23.00,Default,,0,0,0,,Mary had a little lamb \N
+Dialogue: 0,0:00:12.34,0:00:27.34,Default,,0,0,0,,whose fleece was white as snow. 
diff --git a/tests/ref/fate/sub-sami b/tests/ref/fate/sub-sami
index caa85a2..b97db46 100644
--- a/tests/ref/fate/sub-sami
+++ b/tests/ref/fate/sub-sami
@@ -1,21 +1,21 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:00.00,0:00:00.01,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\N
-Dialogue: 0,0:00:00.01,0:00:08.80,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\NLet the word go forth, from this time and place to friend and foe alike that the torch 
-Dialogue: 0,0:00:08.80,0:00:19.50,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\Nhas been passed to a new generation of Americans, born in this century, tempered by war, 
-Dialogue: 0,0:00:19.50,0:00:28.00,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\Ndisciplined by a hard and bitter peace, proud of our ancient heritage, and unwilling to witness 
-Dialogue: 0,0:00:28.00,0:00:38.00,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\Nor permit the slow undoing of those human rights to which this nation has always 
-Dialogue: 0,0:00:38.00,0:00:46.00,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\Nbeen committed and to which we are committed today at home and around the world. 
-Dialogue: 0,0:00:46.00,0:01:01.00,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\NLet every nation know, whether it wishes us well or ill, that we shall pay any price, bear any burden, 
-Dialogue: 0,0:01:01.00,0:01:13.00,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\Nmeet any hardship, support any friend, oppose any foe, to ensure the survival and success of liberty. 
-Dialogue: 0,0:01:13.00,9:59:59.99,Default,,0,0,0,,{\i1}End of: {\i0}\NPresident John F. Kennedy Speech 
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:00:00.00,0:00:00.01,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\N
+Dialogue: 0,0:00:00.01,0:00:08.80,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\NLet the word go forth, from this time and place to friend and foe alike that the torch 
+Dialogue: 0,0:00:08.80,0:00:19.50,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\Nhas been passed to a new generation of Americans, born in this century, tempered by war, 
+Dialogue: 0,0:00:19.50,0:00:28.00,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\Ndisciplined by a hard and bitter peace, proud of our ancient heritage, and unwilling to witness 
+Dialogue: 0,0:00:28.00,0:00:38.00,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\Nor permit the slow undoing of those human rights to which this nation has always 
+Dialogue: 0,0:00:38.00,0:00:46.00,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\Nbeen committed and to which we are committed today at home and around the world. 
+Dialogue: 0,0:00:46.00,0:01:01.00,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\NLet every nation know, whether it wishes us well or ill, that we shall pay any price, bear any burden, 
+Dialogue: 0,0:01:01.00,0:01:13.00,Default,,0,0,0,,{\i1}Pres. John F. Kennedy {\i0}\Nmeet any hardship, support any friend, oppose any foe, to ensure the survival and success of liberty. 
+Dialogue: 0,0:01:13.00,9:59:59.99,Default,,0,0,0,,{\i1}End of: {\i0}\NPresident John F. Kennedy Speech 
diff --git a/tests/ref/fate/sub-srt b/tests/ref/fate/sub-srt
index 40b20cd..4801372 100644
--- a/tests/ref/fate/sub-srt
+++ b/tests/ref/fate/sub-srt
@@ -1,49 +1,49 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,,Don't show this text it may be used to insert hidden data
-Dialogue: 0,0:00:01.50,0:00:04.50,Default,,0,0,0,,SubRip subtitles capability tester 1.3o by ale5000\N{\b1}{\i1}Use VLC 1.1 or higher as reference for most things and MPC Home Cinema for others{\i0}{\b0}\N{\c&HFF0000&}This text should be blue{\c}\N{\c&HFF&}This text should be red{\c}\N{\c&H0&}This text should be black{\c}\N{\fnWebdings}If you see this with the normal font, the player don't (fully) support font face{\fn}
-Dialogue: 0,0:00:04.50,0:00:04.50,Default,,0,0,0,,Hidden
-Dialogue: 0,0:00:04.50,0:00:07.50,Default,,0,0,0,,{\fs8}This text should be small{\fs}\NThis text should be normal\N{\fs35}This text should be big{\fs}
-Dialogue: 0,0:00:07.50,0:00:11.50,Default,,0,0,0,,This should be an E with an accent: È\N日本語\N{\fs30}{\b1}{\i1}{\u1}This text should be bold, italics and underline{\u0}{\i0}{\b0}{\fs}\N{\fs9}{\c&HFF00&}This text should be small and green{\c}{\fs}\N{\fs9}{\c&HFF&}This text should be small and red{\c}{\fs}\N{\fs24}{\c&H2A2AA5&}This text should be big and brown{\c}{\fs}
-Dialogue: 0,0:00:11.50,0:00:14.50,Default,,0,0,0,,{\b1}This line should be bold{\b0}\N{\i1}This line should be italics{\i0}\N{\u1}This line should be underline{\u0}\N{\s1}This line should be strikethrough{\s0}\N{\u1}Both lines\Nshould be underline{\u0}
-Dialogue: 0,0:00:14.50,0:00:17.50,Default,,0,0,0,,>\NIt would be a good thing to\Nhide invalid html tags that are closed and show the text in them\N<invalid_tag_unclosed>but show un-closed invalid html tags\NShow not opened tags</invalid_tag_not_opened>\N<
-Dialogue: 0,0:00:17.50,0:00:20.50,Default,,0,0,0,,and also\Nhide invalid html tags with parameters that are closed and show the text in them\N<invalid_tag_uc par=5>but show un-closed invalid html tags\N{\u1}This text should be showed underlined without problems also: 2<3,5>1,4<6{\u0}\NThis shouldn't be underlined
-Dialogue: 0,0:00:20.50,0:00:21.50,Default,,0,0,0,,This text should be in the normal position...
-Dialogue: 0,0:00:21.50,0:00:22.50,Default,,0,0,0,,{\an5}{\pos(0,45)}This text should NOT be in the normal position
-Dialogue: 0,0:00:22.50,0:00:24.50,Default,,0,0,0,,Implementation is the same of the ASS tag\N{\an8}This text should be at the\Ntop and horizontally centered
-Dialogue: 0,0:00:22.50,0:00:24.50,Default,,0,0,0,,{\an5}This text should be at the\Nmiddle and horizontally centered
-Dialogue: 0,0:00:22.50,0:00:24.50,Default,,0,0,0,,{\an2}This text should be at the\Nbottom and horizontally centered
-Dialogue: 0,0:00:24.50,0:00:26.50,Default,,0,0,0,,This text should be at the\Ntop and horizontally at the left{\an7}
-Dialogue: 0,0:00:24.50,0:00:26.50,Default,,0,0,0,,{\an4}This text should be at the\Nmiddle and horizontally at the left\N(The second position must be ignored)
-Dialogue: 0,0:00:24.50,0:00:26.50,Default,,0,0,0,,{\an1}This text should be at the\Nbottom and horizontally at the left
-Dialogue: 0,0:00:26.50,0:00:28.50,Default,,0,0,0,,{\an9}This text should be at the\Ntop and horizontally at the right
-Dialogue: 0,0:00:26.50,0:00:28.50,Default,,0,0,0,,{\an6}This text should be at the\Nmiddle and horizontally at the right
-Dialogue: 0,0:00:26.50,0:00:28.50,Default,,0,0,0,,{\an3}This text should be at the\Nbottom and horizontally at the right
-Dialogue: 0,0:00:28.50,0:00:31.50,Default,,0,0,0,,{\fs6}{\c&HFF00&}This could be the {\fs35}m{\c&H0&}o{\c&HFF00&}st{\fs6} difficult thing to implement{\c}{\fs}
-Dialogue: 0,0:00:31.50,0:00:50.50,Default,,0,0,0,,First text
-Dialogue: 0,0:00:33.50,0:00:35.50,Default,,0,0,0,,Second, it shouldn't overlap first
-Dialogue: 0,0:00:35.50,0:00:37.50,Default,,0,0,0,,Third, it should replace second
-Dialogue: 0,0:00:36.50,0:00:50.50,Default,,0,0,0,,Fourth, it shouldn't overlap first and third
-Dialogue: 0,0:00:40.50,0:00:45.50,Default,,0,0,0,,Fifth, it should replace third
-Dialogue: 0,0:00:45.50,0:00:50.50,Default,,0,0,0,,Sixth, it shouldn't be\Nshowed overlapped
-Dialogue: 0,0:00:50.50,0:00:52.50,Default,,0,0,0,,TEXT 1 (bottom)
-Dialogue: 0,0:00:50.50,0:00:52.50,Default,,0,0,0,,text 2
-Dialogue: 0,0:00:52.50,0:00:54.50,Default,,0,0,0,,Hide these tags:\Nalso hide these tags:\Nbut show this: {normal text}
-Dialogue: 0,0:00:54.50,0:01:00.50,Default,,0,0,0,,{\an8}\N\ N is a forced line break\N\ h is a hard space\NNormal spaces at the start and at the end of the line are trimmed while hard spaces are not trimmed.\NThe\hline\hwill\hnever\hbreak\hautomatically\hright\hbefore\hor\hafter\ha\hhard\hspace.\h:-D
-Dialogue: 0,0:00:54.50,0:00:56.50,Default,,0,0,0,,{\an1}\N\h\h\h\h\hA (05 hard spaces followed by a letter)\NA (Normal  spaces followed by a letter)\NA (No hard spaces followed by a letter)
-Dialogue: 0,0:00:56.50,0:00:58.50,Default,,0,0,0,,\h\h\h\h\hA (05 hard spaces followed by a letter)\NA (Normal  spaces followed by a letter)\NA (No hard spaces followed by a letter)\NShow this: \TEST and this: \-)
-Dialogue: 0,0:00:58.50,0:01:00.50,Default,,0,0,0,,{\an3}\NA letter followed by 05 hard spaces: A\h\h\h\h\h\NA letter followed by normal  spaces: A\NA letter followed by no hard spaces: A\N05 hard  spaces between letters: A\h\h\h\h\hA\N5 normal spaces between letters: A     A\N\N^--Forced line break
-Dialogue: 0,0:01:00.50,0:01:02.50,Default,,0,0,0,,{\s1}Both line should be strikethrough,\Nyes.{\s0}\NCorrectly closed tags\Nshould be hidden.
-Dialogue: 0,0:01:02.50,0:01:04.50,Default,,0,0,0,,It shouldn't be strikethrough,\Nnot opened tag showed as text.</s>\NNot opened tag showed as text.</xxxxx>
-Dialogue: 0,0:01:04.50,0:01:06.50,Default,,0,0,0,,{\s1}Three lines should be strikethrough,\Nyes.\N<yyyy>Not closed tags showed as text
-Dialogue: 0,0:01:06.50,0:01:08.50,Default,,0,0,0,,{\s1}Both line should be strikethrough but\Nthe wrong closing tag should be showed</b>
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,,Don't show this text it may be used to insert hidden data
+Dialogue: 0,0:00:01.50,0:00:04.50,Default,,0,0,0,,SubRip subtitles capability tester 1.3o by ale5000\N{\b1}{\i1}Use VLC 1.1 or higher as reference for most things and MPC Home Cinema for others{\i0}{\b0}\N{\c&HFF0000&}This text should be blue{\c}\N{\c&HFF&}This text should be red{\c}\N{\c&H0&}This text should be black{\c}\N{\fnWebdings}If you see this with the normal font, the player don't (fully) support font face{\fn}
+Dialogue: 0,0:00:04.50,0:00:04.50,Default,,0,0,0,,Hidden
+Dialogue: 0,0:00:04.50,0:00:07.50,Default,,0,0,0,,{\fs8}This text should be small{\fs}\NThis text should be normal\N{\fs35}This text should be big{\fs}
+Dialogue: 0,0:00:07.50,0:00:11.50,Default,,0,0,0,,This should be an E with an accent: È\N日本語\N{\fs30}{\b1}{\i1}{\u1}This text should be bold, italics and underline{\u0}{\i0}{\b0}{\fs}\N{\fs9}{\c&HFF00&}This text should be small and green{\c}{\fs}\N{\fs9}{\c&HFF&}This text should be small and red{\c}{\fs}\N{\fs24}{\c&H2A2AA5&}This text should be big and brown{\c}{\fs}
+Dialogue: 0,0:00:11.50,0:00:14.50,Default,,0,0,0,,{\b1}This line should be bold{\b0}\N{\i1}This line should be italics{\i0}\N{\u1}This line should be underline{\u0}\N{\s1}This line should be strikethrough{\s0}\N{\u1}Both lines\Nshould be underline{\u0}
+Dialogue: 0,0:00:14.50,0:00:17.50,Default,,0,0,0,,>\NIt would be a good thing to\Nhide invalid html tags that are closed and show the text in them\N<invalid_tag_unclosed>but show un-closed invalid html tags\NShow not opened tags</invalid_tag_not_opened>\N<
+Dialogue: 0,0:00:17.50,0:00:20.50,Default,,0,0,0,,and also\Nhide invalid html tags with parameters that are closed and show the text in them\N<invalid_tag_uc par=5>but show un-closed invalid html tags\N{\u1}This text should be showed underlined without problems also: 2<3,5>1,4<6{\u0}\NThis shouldn't be underlined
+Dialogue: 0,0:00:20.50,0:00:21.50,Default,,0,0,0,,This text should be in the normal position...
+Dialogue: 0,0:00:21.50,0:00:22.50,Default,,0,0,0,,{\an5}{\pos(0,45)}This text should NOT be in the normal position
+Dialogue: 0,0:00:22.50,0:00:24.50,Default,,0,0,0,,Implementation is the same of the ASS tag\N{\an8}This text should be at the\Ntop and horizontally centered
+Dialogue: 0,0:00:22.50,0:00:24.50,Default,,0,0,0,,{\an5}This text should be at the\Nmiddle and horizontally centered
+Dialogue: 0,0:00:22.50,0:00:24.50,Default,,0,0,0,,{\an2}This text should be at the\Nbottom and horizontally centered
+Dialogue: 0,0:00:24.50,0:00:26.50,Default,,0,0,0,,This text should be at the\Ntop and horizontally at the left{\an7}
+Dialogue: 0,0:00:24.50,0:00:26.50,Default,,0,0,0,,{\an4}This text should be at the\Nmiddle and horizontally at the left\N(The second position must be ignored)
+Dialogue: 0,0:00:24.50,0:00:26.50,Default,,0,0,0,,{\an1}This text should be at the\Nbottom and horizontally at the left
+Dialogue: 0,0:00:26.50,0:00:28.50,Default,,0,0,0,,{\an9}This text should be at the\Ntop and horizontally at the right
+Dialogue: 0,0:00:26.50,0:00:28.50,Default,,0,0,0,,{\an6}This text should be at the\Nmiddle and horizontally at the right
+Dialogue: 0,0:00:26.50,0:00:28.50,Default,,0,0,0,,{\an3}This text should be at the\Nbottom and horizontally at the right
+Dialogue: 0,0:00:28.50,0:00:31.50,Default,,0,0,0,,{\fs6}{\c&HFF00&}This could be the {\fs35}m{\c&H0&}o{\c&HFF00&}st{\fs6} difficult thing to implement{\c}{\fs}
+Dialogue: 0,0:00:31.50,0:00:50.50,Default,,0,0,0,,First text
+Dialogue: 0,0:00:33.50,0:00:35.50,Default,,0,0,0,,Second, it shouldn't overlap first
+Dialogue: 0,0:00:35.50,0:00:37.50,Default,,0,0,0,,Third, it should replace second
+Dialogue: 0,0:00:36.50,0:00:50.50,Default,,0,0,0,,Fourth, it shouldn't overlap first and third
+Dialogue: 0,0:00:40.50,0:00:45.50,Default,,0,0,0,,Fifth, it should replace third
+Dialogue: 0,0:00:45.50,0:00:50.50,Default,,0,0,0,,Sixth, it shouldn't be\Nshowed overlapped
+Dialogue: 0,0:00:50.50,0:00:52.50,Default,,0,0,0,,TEXT 1 (bottom)
+Dialogue: 0,0:00:50.50,0:00:52.50,Default,,0,0,0,,text 2
+Dialogue: 0,0:00:52.50,0:00:54.50,Default,,0,0,0,,Hide these tags:\Nalso hide these tags:\Nbut show this: {normal text}
+Dialogue: 0,0:00:54.50,0:01:00.50,Default,,0,0,0,,{\an8}\N\ N is a forced line break\N\ h is a hard space\NNormal spaces at the start and at the end of the line are trimmed while hard spaces are not trimmed.\NThe\hline\hwill\hnever\hbreak\hautomatically\hright\hbefore\hor\hafter\ha\hhard\hspace.\h:-D
+Dialogue: 0,0:00:54.50,0:00:56.50,Default,,0,0,0,,{\an1}\N\h\h\h\h\hA (05 hard spaces followed by a letter)\NA (Normal  spaces followed by a letter)\NA (No hard spaces followed by a letter)
+Dialogue: 0,0:00:56.50,0:00:58.50,Default,,0,0,0,,\h\h\h\h\hA (05 hard spaces followed by a letter)\NA (Normal  spaces followed by a letter)\NA (No hard spaces followed by a letter)\NShow this: \TEST and this: \-)
+Dialogue: 0,0:00:58.50,0:01:00.50,Default,,0,0,0,,{\an3}\NA letter followed by 05 hard spaces: A\h\h\h\h\h\NA letter followed by normal  spaces: A\NA letter followed by no hard spaces: A\N05 hard  spaces between letters: A\h\h\h\h\hA\N5 normal spaces between letters: A     A\N\N^--Forced line break
+Dialogue: 0,0:01:00.50,0:01:02.50,Default,,0,0,0,,{\s1}Both line should be strikethrough,\Nyes.{\s0}\NCorrectly closed tags\Nshould be hidden.
+Dialogue: 0,0:01:02.50,0:01:04.50,Default,,0,0,0,,It shouldn't be strikethrough,\Nnot opened tag showed as text.</s>\NNot opened tag showed as text.</xxxxx>
+Dialogue: 0,0:01:04.50,0:01:06.50,Default,,0,0,0,,{\s1}Three lines should be strikethrough,\Nyes.\N<yyyy>Not closed tags showed as text
+Dialogue: 0,0:01:06.50,0:01:08.50,Default,,0,0,0,,{\s1}Both line should be strikethrough but\Nthe wrong closing tag should be showed</b>
diff --git a/tests/ref/fate/sub-stl b/tests/ref/fate/sub-stl
index cde33cd..5c74850 100644
--- a/tests/ref/fate/sub-stl
+++ b/tests/ref/fate/sub-stl
@@ -1,29 +1,29 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:31.02,0:00:33.00,Default,,0,0,0,,Hello, my name is Axel Kornmesser.
-Dialogue: 0,0:00:45.02,0:00:49.13,Default,,0,0,0,,It is always a pleasure to work with ESA astronomers.
-Dialogue: 0,0:00:49.13,0:00:52.03,Default,,0,0,0,,The "Eyes on The Skies" documentary
-Dialogue: 0,0:00:52.03,0:00:55.09,Default,,0,0,0,,was our second collaboration
-Dialogue: 0,0:00:55.09,0:00:58.07,Default,,0,0,0,,after a great \Nexperience in 2005,
-Dialogue: 0,0:00:58.07,0:00:59.20,Default,,0,0,0,,when \Nwe did the story about the
-Dialogue: 0,0:00:59.20,0:01:04.01,Default,,0,0,0,,Hubble Telescope "15 Years of Discovery".
-Dialogue: 0,0:01:04.16,0:01:07.04,Default,,0,0,0,,It was a lot of fun again.
-Dialogue: 0,0:01:15.04,0:01:18.16,Default,,0,0,0,,We usually \N don't get the final film \Nbefore we start composing
-Dialogue: 0,0:01:18.21,0:01:22.02,Default,,0,0,0,,We had a script and many details about the story,
-Dialogue: 0,0:01:22.10,0:01:26.08,Default,,0,0,0,,and so we worked\N in parallel \Nin the movie production
-Dialogue: 0,0:01:27.04,0:01:30.17,Default,,0,0,0,,The largest part of \N the soundtrack \Nwas done without seeing a movie
-Dialogue: 0,0:01:30.17,0:01:36.06,Default,,0,0,0,,It was no problem, but very inspiring \Nand a free working process.
-Dialogue: 0,0:02:08.13,0:02:10.23,Default,,0,0,0,,Galileo's theme is one of my favourites.
-Dialogue: 0,0:02:10.23,0:02:14.10,Default,,0,0,0,,We did a lot of different versions \Nabout the central theme.
-Dialogue: 0,0:02:14.10,0:02:18.02,Default,,0,0,0,,For the 17th century \N we used a nice harpsichord
-Dialogue: 0,0:02:19.05,0:02:22.09,Default,,0,0,0,,and so we landed directly into Galileo's time.
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:00:31.02,0:00:33.00,Default,,0,0,0,,Hello, my name is Axel Kornmesser.
+Dialogue: 0,0:00:45.02,0:00:49.13,Default,,0,0,0,,It is always a pleasure to work with ESA astronomers.
+Dialogue: 0,0:00:49.13,0:00:52.03,Default,,0,0,0,,The "Eyes on The Skies" documentary
+Dialogue: 0,0:00:52.03,0:00:55.09,Default,,0,0,0,,was our second collaboration
+Dialogue: 0,0:00:55.09,0:00:58.07,Default,,0,0,0,,after a great \Nexperience in 2005,
+Dialogue: 0,0:00:58.07,0:00:59.20,Default,,0,0,0,,when \Nwe did the story about the
+Dialogue: 0,0:00:59.20,0:01:04.01,Default,,0,0,0,,Hubble Telescope "15 Years of Discovery".
+Dialogue: 0,0:01:04.16,0:01:07.04,Default,,0,0,0,,It was a lot of fun again.
+Dialogue: 0,0:01:15.04,0:01:18.16,Default,,0,0,0,,We usually \N don't get the final film \Nbefore we start composing
+Dialogue: 0,0:01:18.21,0:01:22.02,Default,,0,0,0,,We had a script and many details about the story,
+Dialogue: 0,0:01:22.10,0:01:26.08,Default,,0,0,0,,and so we worked\N in parallel \Nin the movie production
+Dialogue: 0,0:01:27.04,0:01:30.17,Default,,0,0,0,,The largest part of \N the soundtrack \Nwas done without seeing a movie
+Dialogue: 0,0:01:30.17,0:01:36.06,Default,,0,0,0,,It was no problem, but very inspiring \Nand a free working process.
+Dialogue: 0,0:02:08.13,0:02:10.23,Default,,0,0,0,,Galileo's theme is one of my favourites.
+Dialogue: 0,0:02:10.23,0:02:14.10,Default,,0,0,0,,We did a lot of different versions \Nabout the central theme.
+Dialogue: 0,0:02:14.10,0:02:18.02,Default,,0,0,0,,For the 17th century \N we used a nice harpsichord
+Dialogue: 0,0:02:19.05,0:02:22.09,Default,,0,0,0,,and so we landed directly into Galileo's time.
diff --git a/tests/ref/fate/sub-subripenc b/tests/ref/fate/sub-subripenc
index 1f1e031..937e198 100644
--- a/tests/ref/fate/sub-subripenc
+++ b/tests/ref/fate/sub-subripenc
@@ -1,6 +1,6 @@
 1
 00:00:00,970 --> 00:00:02,540
-- Test 1.
+- Test 1.
 - Test 2.
 
 2
@@ -9,6 +9,6 @@ Test 3.
 
 3
 00:00:05,850 --> 00:00:08,140
-- Test 4.
+- Test 4.
 - Test 5.
 
diff --git a/tests/ref/fate/sub-subviewer b/tests/ref/fate/sub-subviewer
index 19944f6..363b2e3 100644
--- a/tests/ref/fate/sub-subviewer
+++ b/tests/ref/fate/sub-subviewer
@@ -1,15 +1,15 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:01:00.10,0:02:00.20,Default,,0,0,0,,Hello.\NWorld!
-Dialogue: 0,0:02:00.30,0:03:00.40,Default,,0,0,0,,\Nfoo\Nbar\Nbla\Nmixed with br
-Dialogue: 0,0:03:04.12,0:03:10.20,Default,,0,0,0,,Another event.
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:01:00.10,0:02:00.20,Default,,0,0,0,,Hello.\NWorld!
+Dialogue: 0,0:02:00.30,0:03:00.40,Default,,0,0,0,,\Nfoo\Nbar\Nbla\Nmixed with br
+Dialogue: 0,0:03:04.12,0:03:10.20,Default,,0,0,0,,Another event.
diff --git a/tests/ref/fate/sub-subviewer1 b/tests/ref/fate/sub-subviewer1
index a75406b..d510ce4 100644
--- a/tests/ref/fate/sub-subviewer1
+++ b/tests/ref/fate/sub-subviewer1
@@ -1,22 +1,22 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:03:45.00,0:03:48.00,Default,,0,0,0,,- ToIerábiIis?\N- Azt jeIenti: tűrhető.
-Dialogue: 0,0:03:48.00,0:03:51.00,Default,,0,0,0,,Tudom, mit jeIent. Megnézhetem?
-Dialogue: 0,0:03:52.00,0:03:54.00,Default,,0,0,0,,TiszteIt bírónő.
-Dialogue: 0,0:03:57.00,0:04:00.00,Default,,0,0,0,,KépzeIje magát\Na környékbeIi gyermekek heIyébe.
-Dialogue: 0,0:04:01.00,0:04:05.00,Default,,0,0,0,,Naphosszat monoton, döngöIő zaj\Nszaggatja a dobhártyájukat.
-Dialogue: 0,0:04:05.00,0:04:10.00,Default,,0,0,0,,Ahogy egyre föIébük tornyosuI,\Nrájuk veti sötét árnyékát.
-Dialogue: 0,0:04:10.00,0:04:15.00,Default,,0,0,0,,Ez a feIhőkarcoIó, az emberi\Nmohóság újabb emIékműve.
-Dialogue: 0,1:50:38.00,1:50:41.00,Default,,0,0,0,,készen áIIok.
-Dialogue: 0,1:51:00.00,1:51:03.00,Default,,0,0,0,,Joe ... Miguel keres.
-Dialogue: 0,2:00:18.00,9:59:59.99,Default,,0,0,0,,Magyar szöveg: Nikowvitz Oszkár
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:03:45.00,0:03:48.00,Default,,0,0,0,,- ToIerábiIis?\N- Azt jeIenti: tűrhető.
+Dialogue: 0,0:03:48.00,0:03:51.00,Default,,0,0,0,,Tudom, mit jeIent. Megnézhetem?
+Dialogue: 0,0:03:52.00,0:03:54.00,Default,,0,0,0,,TiszteIt bírónő.
+Dialogue: 0,0:03:57.00,0:04:00.00,Default,,0,0,0,,KépzeIje magát\Na környékbeIi gyermekek heIyébe.
+Dialogue: 0,0:04:01.00,0:04:05.00,Default,,0,0,0,,Naphosszat monoton, döngöIő zaj\Nszaggatja a dobhártyájukat.
+Dialogue: 0,0:04:05.00,0:04:10.00,Default,,0,0,0,,Ahogy egyre föIébük tornyosuI,\Nrájuk veti sötét árnyékát.
+Dialogue: 0,0:04:10.00,0:04:15.00,Default,,0,0,0,,Ez a feIhőkarcoIó, az emberi\Nmohóság újabb emIékműve.
+Dialogue: 0,1:50:38.00,1:50:41.00,Default,,0,0,0,,készen áIIok.
+Dialogue: 0,1:51:00.00,1:51:03.00,Default,,0,0,0,,Joe ... Miguel keres.
+Dialogue: 0,2:00:18.00,9:59:59.99,Default,,0,0,0,,Magyar szöveg: Nikowvitz Oszkár
diff --git a/tests/ref/fate/sub-vplayer b/tests/ref/fate/sub-vplayer
index 6e804f6..7bdbe6b 100644
--- a/tests/ref/fate/sub-vplayer
+++ b/tests/ref/fate/sub-vplayer
@@ -1,15 +1,15 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:00.12,0:00:23.51,Default,,0,0,0,,Hello
-Dialogue: 0,0:00:23.51,0:01:02.05,Default,,0,0,0,,World
-Dialogue: 0,0:01:02.05,9:59:59.99,Default,,0,0,0,,!\Nnewline
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:00:00.12,0:00:23.51,Default,,0,0,0,,Hello
+Dialogue: 0,0:00:23.51,0:01:02.05,Default,,0,0,0,,World
+Dialogue: 0,0:01:02.05,9:59:59.99,Default,,0,0,0,,!\Nnewline
diff --git a/tests/ref/fate/sub-webvtt b/tests/ref/fate/sub-webvtt
index 8c63a90..97222ec 100644
--- a/tests/ref/fate/sub-webvtt
+++ b/tests/ref/fate/sub-webvtt
@@ -1,27 +1,27 @@
-[Script Info]
-; Script generated by FFmpeg/Lavc
-ScriptType: v4.00+
-PlayResX: 384
-PlayResY: 288
-
-[V4+ Styles]
-Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
-
-[Events]
-Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:11.00,0:00:13.00,Default,,0,0,0,,We are in New York City\NRandom line added
-Dialogue: 0,0:00:13.00,0:00:16.00,Default,,0,0,0,,We're actually at the Lucern Hotel, just down the street
-Dialogue: 0,0:00:16.00,0:00:18.00,Default,,0,0,0,,from the American Museum of Natural History
-Dialogue: 0,0:00:18.00,0:00:20.00,Default,,0,0,0,,And with me is Neil deGrasse Tyson
-Dialogue: 0,0:00:20.00,0:00:22.00,Default,,0,0,0,,Astrophysicist, Director of the Hayden Planetarium
-Dialogue: 0,0:00:22.00,0:00:24.00,Default,,0,0,0,,at the AMNH.
-Dialogue: 0,0:00:24.00,0:00:26.00,Default,,0,0,0,,Thank you for walking down here.
-Dialogue: 0,0:00:27.00,0:00:30.00,Default,,0,0,0,,And I want to do a follow-up on the last conversation we did.\Nmultiple lines\Nagain
-Dialogue: 0,0:00:30.00,0:00:31.50,Default,,0,0,0,,When we e-mailed—
-Dialogue: 0,0:00:30.50,0:00:32.50,Default,,0,0,0,,Didn't we {\b1}talk {\i1}about\N{\i0} enough{\b0} in that conversation? \{I'm not an ASS comment\}
-Dialogue: 0,0:00:32.00,0:00:35.50,Default,,0,0,0,,No! No no no no; 'cos 'cos obviously 'cos
-Dialogue: 0,0:00:32.50,0:00:33.50,Default,,0,0,0,,{\i1}Laughs{\i0}
-Dialogue: 0,0:00:35.50,0:00:38.00,Default,,0,0,0,,You know I'm so excited my glasses are falling off here.
-Dialogue: 0,0:00:50.00,0:00:51.13,Default,,0,0,0,,This event and the following\None have CLRF
-Dialogue: 0,0:59:00.12,1:23:45.68,Default,,0,0,0,,Obiwan Kenobi
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
+Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:00:11.00,0:00:13.00,Default,,0,0,0,,We are in New York City\NRandom line added
+Dialogue: 0,0:00:13.00,0:00:16.00,Default,,0,0,0,,We're actually at the Lucern Hotel, just down the street
+Dialogue: 0,0:00:16.00,0:00:18.00,Default,,0,0,0,,from the American Museum of Natural History
+Dialogue: 0,0:00:18.00,0:00:20.00,Default,,0,0,0,,And with me is Neil deGrasse Tyson
+Dialogue: 0,0:00:20.00,0:00:22.00,Default,,0,0,0,,Astrophysicist, Director of the Hayden Planetarium
+Dialogue: 0,0:00:22.00,0:00:24.00,Default,,0,0,0,,at the AMNH.
+Dialogue: 0,0:00:24.00,0:00:26.00,Default,,0,0,0,,Thank you for walking down here.
+Dialogue: 0,0:00:27.00,0:00:30.00,Default,,0,0,0,,And I want to do a follow-up on the last conversation we did.\Nmultiple lines\Nagain
+Dialogue: 0,0:00:30.00,0:00:31.50,Default,,0,0,0,,When we e-mailed—
+Dialogue: 0,0:00:30.50,0:00:32.50,Default,,0,0,0,,Didn't we {\b1}talk {\i1}about\N{\i0} enough{\b0} in that conversation? \{I'm not an ASS comment\}
+Dialogue: 0,0:00:32.00,0:00:35.50,Default,,0,0,0,,No! No no no no; 'cos 'cos obviously 'cos
+Dialogue: 0,0:00:32.50,0:00:33.50,Default,,0,0,0,,{\i1}Laughs{\i0}
+Dialogue: 0,0:00:35.50,0:00:38.00,Default,,0,0,0,,You know I'm so excited my glasses are falling off here.
+Dialogue: 0,0:00:50.00,0:00:51.13,Default,,0,0,0,,This event and the following\None have CLRF
+Dialogue: 0,0:59:00.12,1:23:45.68,Default,,0,0,0,,Obiwan Kenobi


More information about the ffmpeg-devel mailing list