]> granicus.if.org Git - handbrake/commitdiff
add subtitle track name read/write
authorJohn Stebbins <jstebbins.hb@gmail.com>
Fri, 2 Aug 2019 18:41:13 +0000 (11:41 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Sun, 11 Aug 2019 22:36:40 +0000 (15:36 -0700)
Works similar to audio track names.
If source has a subtitle track name, hb_subtitle_t.name is set.
To set output subtitle track name, set hb_subtitle_config_t.name.

Source track names are available in title returned by hb_title_to_dict
and hb_title_to_json in SubtitleList[].Name

In job dict it is also SubtitleList[].Name

hb_preset_job_init and hb_preset_job_init_json initialize output tracks
with the source track name.

Also adds subtitle name support to LinGui

gtk/src/ghb3.ui
gtk/src/ghb4.ui
gtk/src/subtitlehandler.c
libhb/common.c
libhb/common.h
libhb/hb_json.c
libhb/muxavformat.c
libhb/preset.c
libhb/stream.c
macosx/HBJob+HBJobConversion.m

index eccd56efc3aa23581cd447be044cfc99bd2ffc8d..1a7eea08abc5a35eed88235f897240c712f3906b 100644 (file)
@@ -8732,6 +8732,7 @@ Setting this to 0 means there is no maximum height.</property>
     </action-widgets>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-subtitle-vbox">
+        <property name="orientation">vertical</property>
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="spacing">6</property>
@@ -8796,264 +8797,298 @@ Setting this to 0 means there is no maximum height.</property>
               </packing>
             </child>
           </object>
+          <packing>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkGrid" id="subtitle_track_grid">
+            <property name="row-spacing">2</property>
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="column_spacing">5</property>
+            <property name="halign">center</property>
+            <child>
+              <object class="GtkLabel" id="subtitle_track_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label" translatable="yes">Source Track</property>
+              </object>
+              <packing>
+                <property name="top_attach">0</property>
+                <property name="left_attach">0</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkComboBox" id="SubtitleTrack">
+                <property name="valign">GTK_ALIGN_CENTER</property>
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="tooltip_text" translatable="yes">List of subtitle tracks available from your source.</property>
+                <signal name="changed" handler="subtitle_track_changed_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="top_attach">1</property>
+                <property name="left_attach">0</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="subtitle_name_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Track Name:</property>
+                <property name="use_markup">True</property>
+                <property name="halign">center</property>
+              </object>
+              <packing>
+                <property name="top_attach">0</property>
+                <property name="left_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="SubtitleTrackName">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="tooltip_text" translatable="yes">Set the subtitle track name.
+
+Players may use this in the subtitle selection list.</property>
+                <property name="max_length">80</property>
+                <property name="width-chars">40</property>
+                <property name="activates_default">True</property>
+                <property name="truncate_multiline">True</property>
+                <signal name="changed" handler="subtitle_name_changed_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="top_attach">1</property>
+                <property name="left_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+          </object>
           <packing>
             <property name="position">1</property>
           </packing>
         </child>
         <child>
-          <object class="GtkBox" id="subtitle_settings_box">
-            <property name="orientation">horizontal</property>
+          <object class="GtkGrid" id="subtitle_import_grid">
             <property name="visible">True</property>
+            <property name="row-spacing">2</property>
             <property name="can_focus">False</property>
-            <property name="spacing">6</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="column_spacing">4</property>
             <child>
-              <object class="GtkGrid" id="subtitle_import_grid">
+              <object class="GtkLabel" id="import_lang_label">
                 <property name="visible">True</property>
-                <property name="row-spacing">2</property>
                 <property name="can_focus">False</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="column_spacing">4</property>
-                <child>
-                  <object class="GtkLabel" id="import_lang_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label" translatable="yes">Language</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">0</property>
-                    <property name="left_attach">1</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="srt_code_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label" translatable="yes">Character Code</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">0</property>
-                    <property name="left_attach">2</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="import_file_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label" translatable="yes">File:</property>
-                    <property name="halign">end</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">2</property>
-                    <property name="left_attach">0</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="import_offset_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label" translatable="yes">Offset (ms)</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">0</property>
-                    <property name="left_attach">4</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkComboBox" id="ImportLanguage">
-                    <property name="valign">GTK_ALIGN_CENTER</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="tooltip_text" translatable="yes">Set the language of this subtitle.
+                <property name="label" translatable="yes">Language</property>
+              </object>
+              <packing>
+                <property name="top_attach">0</property>
+                <property name="left_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="srt_code_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label" translatable="yes">Character Code</property>
+              </object>
+              <packing>
+                <property name="top_attach">0</property>
+                <property name="left_attach">2</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="import_file_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label" translatable="yes">File:</property>
+                <property name="halign">end</property>
+              </object>
+              <packing>
+                <property name="top_attach">2</property>
+                <property name="left_attach">0</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="import_offset_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label" translatable="yes">Offset (ms)</property>
+              </object>
+              <packing>
+                <property name="top_attach">0</property>
+                <property name="left_attach">4</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkComboBox" id="ImportLanguage">
+                <property name="valign">GTK_ALIGN_CENTER</property>
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="tooltip_text" translatable="yes">Set the language of this subtitle.
 This value will be used by players in subtitle menus.</property>
-                    <signal name="changed" handler="import_lang_changed_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="top_attach">1</property>
-                    <property name="left_attach">1</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkComboBox" id="SrtCodeset">
-                    <property name="valign">GTK_ALIGN_FILL</property>
-                    <property name="width_request">150</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="tooltip_text" translatable="yes">Set the character code used by the SRT file you are importing.
+                <signal name="changed" handler="import_lang_changed_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="top_attach">1</property>
+                <property name="left_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkComboBox" id="SrtCodeset">
+                <property name="valign">GTK_ALIGN_FILL</property>
+                <property name="width_request">150</property>
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="tooltip_text" translatable="yes">Set the character code used by the SRT file you are importing.
 
 SRTs come in all flavours of character sets.
 We translate the character set to UTF-8.
 The source's character code is needed in order to perform this translation.</property>
-                    <signal name="changed" handler="srt_codeset_changed_cb" swapped="no"/>
-                    <property name="has_entry">True</property>
-                    <child internal-child="entry">
-                      <object class="GtkEntry" id="combobox-entry1">
-                        <property name="can_focus">True</property>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="top_attach">1</property>
-                    <property name="left_attach">2</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkFileChooserButton" id="ImportFile">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="tooltip_text" translatable="yes">Select the SRT file to import.</property>
-                    <property name="local_only">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="title" translatable="yes">Import File</property>
-                    <signal name="selection-changed" handler="import_file_changed_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="top_attach">2</property>
-                    <property name="left_attach">1</property>
-                    <property name="width">2</property>
-                    <property name="height">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkSpinButton" id="ImportOffset">
-                    <property name="valign">GTK_ALIGN_FILL</property>
-                    <property name="vexpand">False</property>
-                    <property name="width-chars">8</property>
-                    <property name="visible">True</property>
+                <signal name="changed" handler="srt_codeset_changed_cb" swapped="no"/>
+                <property name="has_entry">True</property>
+                <child internal-child="entry">
+                  <object class="GtkEntry" id="combobox-entry1">
                     <property name="can_focus">True</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="tooltip_text" translatable="yes">Adjust the offset in milliseconds between video and SRT timestamps</property>
-                    <property name="adjustment">adjustment31</property>
-                    <signal name="value-changed" handler="import_offset_changed_cb" swapped="no"/>
                   </object>
-                  <packing>
-                    <property name="top_attach">1</property>
-                    <property name="left_attach">4</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
-                  </packing>
                 </child>
               </object>
               <packing>
-                <property name="position">0</property>
+                <property name="top_attach">1</property>
+                <property name="left_attach">2</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
               </packing>
             </child>
             <child>
-              <object class="GtkBox" id="subtitle_track_box">
-                <property name="orientation">vertical</property>
+              <object class="GtkFileChooserButton" id="ImportFile">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <child>
-                  <object class="GtkLabel" id="subtitle_track_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label" translatable="yes">Track</property>
-                  </object>
-                  <packing>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkComboBox" id="SubtitleTrack">
-                    <property name="valign">GTK_ALIGN_CENTER</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="tooltip_text" translatable="yes">List of subtitle tracks available from your source.</property>
-                    <signal name="changed" handler="subtitle_track_changed_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
+                <property name="can_focus">True</property>
+                <property name="tooltip_text" translatable="yes">Select the SRT file to import.</property>
+                <property name="local_only">False</property>
+                <property name="hexpand">True</property>
+                <property name="title" translatable="yes">Import File</property>
+                <signal name="selection-changed" handler="import_file_changed_cb" swapped="no"/>
               </object>
               <packing>
-                <property name="position">1</property>
+                <property name="top_attach">2</property>
+                <property name="left_attach">1</property>
+                <property name="width">2</property>
+                <property name="height">1</property>
               </packing>
             </child>
             <child>
-              <object class="GtkBox" id="subtitle_options_box">
-                <property name="orientation">vertical</property>
+              <object class="GtkSpinButton" id="ImportOffset">
+                <property name="valign">GTK_ALIGN_FILL</property>
+                <property name="vexpand">False</property>
+                <property name="width-chars">8</property>
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <child>
-                  <object class="GtkCheckButton" id="SubtitleForced">
-                    <property name="label" translatable="yes">Forced Subtitles Only</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="tooltip_text" translatable="yes">Use only subtitles that have been flagged
+                <property name="can_focus">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="tooltip_text" translatable="yes">Adjust the offset in milliseconds between video and SRT timestamps</property>
+                <property name="adjustment">adjustment31</property>
+                <signal name="value-changed" handler="import_offset_changed_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="top_attach">1</property>
+                <property name="left_attach">4</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="subtitle_options_box">
+            <property name="orientation">vertical</property>
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin_top">12</property>
+            <child>
+              <object class="GtkCheckButton" id="SubtitleForced">
+                <property name="label" translatable="yes">Forced Subtitles Only</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="tooltip_text" translatable="yes">Use only subtitles that have been flagged
 as forced in the source subtitle track
 
 "Forced" subtitles are usually used to show
 subtitles during scenes where someone is speaking
 a foreign language.</property>
-                    <property name="halign">start</property>
-                    <property name="draw_indicator">True</property>
-                    <signal name="toggled" handler="subtitle_forced_toggled_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="SubtitleBurned">
-                    <property name="label" translatable="yes">Burn into video</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="tooltip_text" translatable="yes">Render the subtitle over the video.
+                <property name="halign">start</property>
+                <property name="draw_indicator">True</property>
+                <signal name="toggled" handler="subtitle_forced_toggled_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="SubtitleBurned">
+                <property name="label" translatable="yes">Burn into video</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="tooltip_text" translatable="yes">Render the subtitle over the video.
 The subtitle will be part of the video and can not be disabled.</property>
-                    <property name="halign">start</property>
-                    <property name="draw_indicator">True</property>
-                    <signal name="toggled" handler="subtitle_burned_toggled_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="SubtitleDefaultTrack">
-                    <property name="label" translatable="yes">Set Default Track</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="tooltip_text" translatable="yes">Set the default output subtitle track.
+                <property name="halign">start</property>
+                <property name="draw_indicator">True</property>
+                <signal name="toggled" handler="subtitle_burned_toggled_cb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="SubtitleDefaultTrack">
+                <property name="label" translatable="yes">Set Default Track</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="tooltip_text" translatable="yes">Set the default output subtitle track.
 
 Most players will automatically display this
 subtitle track whenever the video is played.
 
 This is useful for creating a "forced" track
 in your output.</property>
-                    <property name="halign">start</property>
-                    <property name="draw_indicator">True</property>
-                    <signal name="toggled" handler="subtitle_default_toggled_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="position">2</property>
-                  </packing>
-                </child>
+                <property name="halign">start</property>
+                <property name="draw_indicator">True</property>
+                <signal name="toggled" handler="subtitle_default_toggled_cb" swapped="no"/>
               </object>
               <packing>
                 <property name="position">2</property>
@@ -9061,7 +9096,7 @@ in your output.</property>
             </child>
           </object>
           <packing>
-            <property name="position">2</property>
+            <property name="position">3</property>
           </packing>
         </child>
       </object>
@@ -9170,7 +9205,8 @@ in your output.</property>
                 <property name="tooltip_text" translatable="yes">Set the audio track name.
 
 Players may use this in the audio selection list.</property>
-                <property name="max_length">40</property>
+                <property name="max_length">80</property>
+                <property name="width-chars">40</property>
                 <property name="hexpand">True</property>
                 <property name="activates_default">True</property>
                 <property name="truncate_multiline">True</property>
index a43645944b0afb77f4873947645845af4e796cc6..ca4d3d36a3220356dc1df8820b1e6e2f4d1367a2 100644 (file)
@@ -7335,210 +7335,244 @@ Setting this to 0 means there is no maximum height.</property>
           </object>
         </child>
         <child>
-          <object class="GtkBox" id="subtitle_settings_box">
-            <property name="orientation">horizontal</property>
+          <object class="GtkGrid" id="subtitle_track_grid">
+            <property name="row-spacing">2</property>
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="spacing">6</property>
+            <property name="column-spacing">5</property>
+            <property name="halign">center</property>
             <child>
-              <object class="GtkGrid" id="subtitle_import_grid">
+              <object class="GtkLabel" id="subtitle_track_label">
                 <property name="visible">True</property>
-                <property name="row-spacing">2</property>
                 <property name="can_focus">False</property>
-                <property name="column-spacing">4</property>
-                <child>
-                  <object class="GtkLabel" id="import_lang_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Language</property>
-                    <layout>
-                      <property name="top-attach">0</property>
-                      <property name="left-attach">1</property>
-                    </layout>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="srt_code_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Character Code</property>
-                    <layout>
-                      <property name="top-attach">0</property>
-                      <property name="left-attach">2</property>
-                    </layout>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="import_file_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">File:</property>
-                    <property name="halign">end</property>
-                    <layout>
-                      <property name="top-attach">2</property>
-                      <property name="left-attach">0</property>
-                    </layout>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="import_offset_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Offset (ms)</property>
-                    <layout>
-                      <property name="top-attach">0</property>
-                      <property name="left-attach">4</property>
-                    </layout>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkComboBox" id="ImportLanguage">
-                    <property name="valign">GTK_ALIGN_CENTER</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="tooltip_text" translatable="yes">Set the language of this subtitle.
+                <property name="label" translatable="yes">Source Track</property>
+                <layout>
+                  <property name="top_attach">0</property>
+                  <property name="left_attach">0</property>
+                </layout>
+              </object>
+            </child>
+            <child>
+              <object class="GtkComboBox" id="SubtitleTrack">
+                <property name="valign">GTK_ALIGN_CENTER</property>
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="tooltip_text" translatable="yes">List of subtitle tracks available from your source.</property>
+                <signal name="changed" handler="subtitle_track_changed_cb" swapped="no"/>
+                <layout>
+                  <property name="top_attach">1</property>
+                  <property name="left_attach">0</property>
+                </layout>
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel" id="subtitle_name_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Track Name:</property>
+                <property name="use_markup">True</property>
+                <property name="halign">center</property>
+                <layout>
+                  <property name="top_attach">0</property>
+                  <property name="left_attach">1</property>
+                </layout>
+              </object>
+            </child>
+            <child>
+              <object class="GtkEntry" id="SubtitleTrackName">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="tooltip_text" translatable="yes">Set the subtitle track name.
+
+Players may use this in the subtitle selection list.</property>
+                <property name="max_length">80</property>
+                <property name="width-chars">40</property>
+                <property name="activates_default">True</property>
+                <property name="truncate_multiline">True</property>
+                <signal name="changed" handler="subtitle_name_changed_cb" swapped="no"/>
+                <layout>
+                  <property name="top_attach">1</property>
+                  <property name="left_attach">1</property>
+                </layout>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkGrid" id="subtitle_import_grid">
+            <property name="visible">True</property>
+            <property name="row-spacing">2</property>
+            <property name="can_focus">False</property>
+            <property name="column-spacing">4</property>
+            <child>
+              <object class="GtkLabel" id="import_lang_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Language</property>
+                <layout>
+                  <property name="top-attach">0</property>
+                  <property name="left-attach">1</property>
+                </layout>
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel" id="srt_code_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Character Code</property>
+                <layout>
+                  <property name="top-attach">0</property>
+                  <property name="left-attach">2</property>
+                </layout>
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel" id="import_file_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">File:</property>
+                <property name="halign">end</property>
+                <layout>
+                  <property name="top-attach">2</property>
+                  <property name="left-attach">0</property>
+                </layout>
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel" id="import_offset_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Offset (ms)</property>
+                <layout>
+                  <property name="top-attach">0</property>
+                  <property name="left-attach">4</property>
+                </layout>
+              </object>
+            </child>
+            <child>
+              <object class="GtkComboBox" id="ImportLanguage">
+                <property name="valign">GTK_ALIGN_CENTER</property>
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="tooltip_text" translatable="yes">Set the language of this subtitle.
 This value will be used by players in subtitle menus.</property>
-                    <signal name="changed" handler="import_lang_changed_cb" swapped="no"/>
-                    <layout>
-                      <property name="top-attach">1</property>
-                      <property name="left-attach">1</property>
-                    </layout>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkComboBox" id="SrtCodeset">
-                    <property name="valign">GTK_ALIGN_FILL</property>
-                    <property name="width_request">150</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="tooltip_text" translatable="yes">Set the character code used by the SRT file you are importing.
+                <signal name="changed" handler="import_lang_changed_cb" swapped="no"/>
+                <layout>
+                  <property name="top-attach">1</property>
+                  <property name="left-attach">1</property>
+                </layout>
+              </object>
+            </child>
+            <child>
+              <object class="GtkComboBox" id="SrtCodeset">
+                <property name="valign">GTK_ALIGN_FILL</property>
+                <property name="width_request">150</property>
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="tooltip_text" translatable="yes">Set the character code used by the SRT file you are importing.
 
 SRTs come in all flavours of character sets.
 We translate the character set to UTF-8.
 The source's character code is needed in order to perform this translation.</property>
-                    <signal name="changed" handler="srt_codeset_changed_cb" swapped="no"/>
-                    <property name="has_entry">True</property>
-                    <layout>
-                      <property name="top-attach">1</property>
-                      <property name="left-attach">2</property>
-                    </layout>
-                    <child internal-child="entry">
-                      <object class="GtkEntry" id="combobox-entry1">
-                        <property name="can_focus">True</property>
-                      </object>
-                    </child>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkFileChooserButton" id="ImportFile">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="tooltip_text" translatable="yes">Select the SRT file to import.</property>
-                    <property name="local_only">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="title" translatable="yes">Import File</property>
-                    <signal name="selection-changed" handler="import_file_changed_cb" swapped="no"/>
-                    <layout>
-                      <property name="top-attach">2</property>
-                      <property name="left-attach">1</property>
-                      <property name="column-span">2</property>
-                    </layout>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkSpinButton" id="ImportOffset">
-                    <property name="valign">GTK_ALIGN_FILL</property>
-                    <property name="vexpand">False</property>
-                    <property name="width-chars">8</property>
-                    <property name="visible">True</property>
+                <signal name="changed" handler="srt_codeset_changed_cb" swapped="no"/>
+                <property name="has_entry">True</property>
+                <layout>
+                  <property name="top-attach">1</property>
+                  <property name="left-attach">2</property>
+                </layout>
+                <child internal-child="entry">
+                  <object class="GtkEntry" id="combobox-entry1">
                     <property name="can_focus">True</property>
-                    <property name="tooltip_text" translatable="yes">Adjust the offset in milliseconds between video and SRT timestamps</property>
-                    <property name="adjustment">adjustment31</property>
-                    <signal name="value-changed" handler="import_offset_changed_cb" swapped="no"/>
-                    <layout>
-                      <property name="top-attach">1</property>
-                      <property name="left-attach">4</property>
-                    </layout>
                   </object>
                 </child>
               </object>
             </child>
             <child>
-              <object class="GtkBox" id="subtitle_track_box">
-                <property name="orientation">vertical</property>
+              <object class="GtkFileChooserButton" id="ImportFile">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <child>
-                  <object class="GtkLabel" id="subtitle_track_label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Track</property>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkComboBox" id="SubtitleTrack">
-                    <property name="valign">GTK_ALIGN_CENTER</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="tooltip_text" translatable="yes">List of subtitle tracks available from your source.</property>
-                    <signal name="changed" handler="subtitle_track_changed_cb" swapped="no"/>
-                  </object>
-                </child>
+                <property name="can_focus">True</property>
+                <property name="tooltip_text" translatable="yes">Select the SRT file to import.</property>
+                <property name="local_only">False</property>
+                <property name="hexpand">True</property>
+                <property name="title" translatable="yes">Import File</property>
+                <signal name="selection-changed" handler="import_file_changed_cb" swapped="no"/>
+                <layout>
+                  <property name="top-attach">2</property>
+                  <property name="left-attach">1</property>
+                  <property name="column-span">2</property>
+                </layout>
               </object>
             </child>
             <child>
-              <object class="GtkBox" id="subtitle_options_box">
-                <property name="orientation">vertical</property>
+              <object class="GtkSpinButton" id="ImportOffset">
+                <property name="valign">GTK_ALIGN_FILL</property>
+                <property name="vexpand">False</property>
+                <property name="width-chars">8</property>
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <child>
-                  <object class="GtkCheckButton" id="SubtitleForced">
-                    <property name="label" translatable="yes">Forced Subtitles Only</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="tooltip_text" translatable="yes">Use only subtitles that have been flagged
+                <property name="can_focus">True</property>
+                <property name="tooltip_text" translatable="yes">Adjust the offset in milliseconds between video and SRT timestamps</property>
+                <property name="adjustment">adjustment31</property>
+                <signal name="value-changed" handler="import_offset_changed_cb" swapped="no"/>
+                <layout>
+                  <property name="top-attach">1</property>
+                  <property name="left-attach">4</property>
+                </layout>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkBox" id="subtitle_options_box">
+            <property name="orientation">vertical</property>
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin_top">12</property>
+            <child>
+              <object class="GtkCheckButton" id="SubtitleForced">
+                <property name="label" translatable="yes">Forced Subtitles Only</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="tooltip_text" translatable="yes">Use only subtitles that have been flagged
 as forced in the source subtitle track
 
 "Forced" subtitles are usually used to show
 subtitles during scenes where someone is speaking
 a foreign language.</property>
-                    <property name="halign">start</property>
-                    <property name="draw_indicator">True</property>
-                    <signal name="toggled" handler="subtitle_forced_toggled_cb" swapped="no"/>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="SubtitleBurned">
-                    <property name="label" translatable="yes">Burn into video</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="tooltip_text" translatable="yes">Render the subtitle over the video.
+                <property name="halign">start</property>
+                <property name="draw_indicator">True</property>
+                <signal name="toggled" handler="subtitle_forced_toggled_cb" swapped="no"/>
+              </object>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="SubtitleBurned">
+                <property name="label" translatable="yes">Burn into video</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="tooltip_text" translatable="yes">Render the subtitle over the video.
 The subtitle will be part of the video and can not be disabled.</property>
-                    <property name="halign">start</property>
-                    <property name="draw_indicator">True</property>
-                    <signal name="toggled" handler="subtitle_burned_toggled_cb" swapped="no"/>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="SubtitleDefaultTrack">
-                    <property name="label" translatable="yes">Set Default Track</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="tooltip_text" translatable="yes">Set the default output subtitle track.
+                <property name="halign">start</property>
+                <property name="draw_indicator">True</property>
+                <signal name="toggled" handler="subtitle_burned_toggled_cb" swapped="no"/>
+              </object>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="SubtitleDefaultTrack">
+                <property name="label" translatable="yes">Set Default Track</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="tooltip_text" translatable="yes">Set the default output subtitle track.
 
 Most players will automatically display this
 subtitle track whenever the video is played.
 
 This is useful for creating a "forced" track
 in your output.</property>
-                    <property name="halign">start</property>
-                    <property name="draw_indicator">True</property>
-                    <signal name="toggled" handler="subtitle_default_toggled_cb" swapped="no"/>
-                  </object>
-                </child>
+                <property name="halign">start</property>
+                <property name="draw_indicator">True</property>
+                <signal name="toggled" handler="subtitle_default_toggled_cb" swapped="no"/>
               </object>
             </child>
           </object>
index fcf530cc78d98567c3dced68aa2f5654a14ae53a..684603895479ea765b57b63c8e21685343ca4a7a 100644 (file)
@@ -27,6 +27,7 @@
 #include "hb.h"
 #include "settings.h"
 #include "jobdict.h"
+#include "titledict.h"
 #include "hb-backend.h"
 #include "values.h"
 #include "callbacks.h"
@@ -428,7 +429,6 @@ subtitle_get_track_description(GhbValue *settings, GhbValue *subsettings)
 static GhbValue*  subtitle_add_track(
     signal_user_data_t *ud,
     GhbValue *settings,
-    const hb_title_t *title,
     int track,
     int mux,
     gboolean default_track,
@@ -437,10 +437,14 @@ static GhbValue*  subtitle_add_track(
     gboolean burn,
     gboolean *burned)
 {
+    const char * name = NULL;
     if (track >= 0 && !import)
     {
-        hb_subtitle_t *subtitle = hb_list_item(title->list_subtitle, track);
-        source = subtitle->source;
+        GhbValue * strack;
+
+        strack = ghb_get_title_subtitle_track(settings, track);
+        source = ghb_dict_get_int(strack, "Source");
+        name   = ghb_dict_get_string(strack, "Name");
     }
 
     burn |= !hb_subtitle_can_pass(source, mux);
@@ -474,6 +478,10 @@ static GhbValue*  subtitle_add_track(
         g_free(filename);
     }
 
+    if (name != NULL && name[0] != 0)
+    {
+        ghb_dict_set_string(subsettings, "Name", name);
+    }
     ghb_dict_set_int(subsettings, "Track", track);
     ghb_dict_set_int(subsettings, "Offset", 0);
     ghb_dict_set_bool(subsettings, "Forced", track == -1);
@@ -640,14 +648,26 @@ subtitle_update_dialog_widgets(signal_user_data_t *ud, GhbValue *subsettings)
 
         import = ghb_dict_get(subsettings, "Import");
         source = get_sub_source(ud->settings, subsettings);
-        val    = ghb_dict_get(subsettings, "Track");
 
+        val = ghb_dict_get_value(subsettings, "Name");
+        if (val != NULL)
+        {
+            ghb_ui_update(ud, "SubtitleTrackName", val);
+        }
+        else
+        {
+            ghb_ui_update(ud, "SubtitleTrackName", ghb_string_value(""));
+        }
+
+        val    = ghb_dict_get(subsettings, "Track");
         if (val != NULL)
         {
             ghb_ui_update(ud, "SubtitleTrack", val);
 
             // Hide regular subtitle widgets
-            widget = GHB_WIDGET(ud->builder, "subtitle_track_box");
+            widget = GHB_WIDGET(ud->builder, "subtitle_track_label");
+            gtk_widget_set_visible(widget, import == NULL);
+            widget = GHB_WIDGET(ud->builder, "SubtitleTrack");
             gtk_widget_set_visible(widget, import == NULL);
 
             // Show import subitle widgets
@@ -665,7 +685,9 @@ subtitle_update_dialog_widgets(signal_user_data_t *ud, GhbValue *subsettings)
         else
         {
             // Hide widgets not needed for "Foreign audio search"
-            widget = GHB_WIDGET(ud->builder, "subtitle_track_box");
+            widget = GHB_WIDGET(ud->builder, "subtitle_track_label");
+            gtk_widget_set_visible(widget, FALSE);
+            widget = GHB_WIDGET(ud->builder, "SubtitleTrack");
             gtk_widget_set_visible(widget, FALSE);
 
             widget = GHB_WIDGET(ud->builder, "subtitle_import_grid");
@@ -742,7 +764,9 @@ subtitle_update_dialog_widgets(signal_user_data_t *ud, GhbValue *subsettings)
         gtk_widget_set_visible(widget, FALSE);
 
         // Show regular subtitle widgets
-        widget = GHB_WIDGET(ud->builder, "subtitle_track_box");
+        widget = GHB_WIDGET(ud->builder, "subtitle_track_label");
+        gtk_widget_set_visible(widget, TRUE);
+        widget = GHB_WIDGET(ud->builder, "SubtitleTrack");
         gtk_widget_set_visible(widget, TRUE);
     }
 }
@@ -783,6 +807,21 @@ subtitle_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
     }
 }
 
+G_MODULE_EXPORT void
+subtitle_name_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+    ghb_widget_to_setting(ud->settings, widget);
+    const char *s = ghb_dict_get_string(ud->settings, "SubtitleTrackName");
+    if (s != NULL && s[0] != 0)
+    {
+        subtitle_update_setting(ghb_widget_value(widget), "Name", ud);
+    }
+    else
+    {
+        subtitle_update_setting(NULL, "Name", ud);
+    }
+}
+
 G_MODULE_EXPORT void
 subtitle_forced_toggled_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
@@ -1129,13 +1168,13 @@ subtitle_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
     for (subsettings = NULL, track = 0;
          subsettings == NULL && track < count; track++)
     {
-        subsettings = subtitle_add_track(ud, ud->settings, title, track,
+        subsettings = subtitle_add_track(ud, ud->settings, track,
                                 mux->format, FALSE, FALSE, VOBSUB,
                                 FALSE, &one_burned);
     }
     if (subsettings == NULL)
     {
-        subsettings = subtitle_add_track(ud, ud->settings, title, 0,
+        subsettings = subtitle_add_track(ud, ud->settings, 0,
                                 mux->format, FALSE, TRUE, IMPORTSRT,
                                 FALSE, &one_burned);
     }
@@ -1247,7 +1286,7 @@ subtitle_add_all_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
     int count = hb_list_count(title->list_subtitle);
     for (track = 0; track < count; track++)
     {
-        subtitle_add_track(ud, ud->settings, title, track, mux->format,
+        subtitle_add_track(ud, ud->settings, track, mux->format,
                            FALSE, FALSE, VOBSUB, FALSE, &one_burned);
     }
     subtitle_refresh_list_ui(ud);
index e21590fa243d3b3f3a3fa36c2b4708a9df172ad6..df5d6046773ee92f5a55bb274a8ab3d7aff938e2 100644 (file)
@@ -4809,6 +4809,14 @@ hb_subtitle_t *hb_subtitle_copy(const hb_subtitle_t *src)
             subtitle->extradata = malloc( src->extradata_size );
             memcpy( subtitle->extradata, src->extradata, src->extradata_size );
         }
+        if (src->name != NULL)
+        {
+            subtitle->name = strdup(src->name);
+        }
+        if (src->config.name != NULL)
+        {
+            subtitle->config.name = strdup(src->config.name);
+        }
     }
     return subtitle;
 }
@@ -4846,6 +4854,8 @@ void hb_subtitle_close( hb_subtitle_t **sub )
 {
     if ( sub && *sub )
     {
+        free ((char*)(*sub)->name);
+        free ((char*)(*sub)->config.name);
         free ((*sub)->extradata);
         free(*sub);
         *sub = NULL;
@@ -4905,6 +4915,10 @@ int hb_subtitle_add(const hb_job_t * job, const hb_subtitle_config_t * subtitlec
     // "track" in job->list_audio is an index into title->list_audio
     subtitle->track = track;
     subtitle->config = *subtitlecfg;
+    if (subtitlecfg->name != NULL && subtitlecfg->name[0] != 0)
+    {
+        subtitle->config.name = strdup(subtitlecfg->name);
+    }
     subtitle->out_track = hb_list_count(job->list_subtitle) + 1;
     hb_list_add(job->list_subtitle, subtitle);
     return 1;
@@ -4944,6 +4958,10 @@ int hb_import_subtitle_add( const hb_job_t * job,
     strcpy(subtitle->iso639_2, lang->iso639_2);
 
     subtitle->config = *subtitlecfg;
+    if (subtitlecfg->name != NULL && subtitlecfg->name[0] != 0)
+    {
+        subtitle->config.name = strdup(subtitlecfg->name);
+    }
     hb_list_add(job->list_subtitle, subtitle);
 
     return 1;
index e7c9b2b5f0c854a2e223653c176426c95b2311d5..6cf94988128c2935271407601e7aa3f834a1e449 100644 (file)
@@ -297,13 +297,14 @@ void hb_image_close(hb_image_t **_image);
 struct hb_subtitle_config_s
 {
     enum subdest { RENDERSUB, PASSTHRUSUB } dest;
-    int  force;
-    int  default_track; 
-    
+    int          force;
+    int          default_track;
+    const char * name;
+
     /* SRT subtitle tracks only */
-    char src_filename[256];
-    char src_codeset[40];
-    int64_t offset;
+    char      src_filename[256];
+    char      src_codeset[40];
+    int64_t   offset;
 };
 
 /*******************************************************************************
@@ -966,9 +967,10 @@ struct hb_subtitle_s
     enum subsource { VOBSUB, CC608SUB, /*unused*/CC708SUB,
                      UTF8SUB, TX3GSUB, SSASUB, PGSSUB,
                      IMPORTSRT, IMPORTSSA, SRTSUB = IMPORTSRT } source;
-    char lang[1024];
-    char iso639_2[4];
-    uint32_t attributes; /* Closed Caption, Childrens, Directors etc */
+    const char * name;
+    char         lang[1024];
+    char         iso639_2[4];
+    uint32_t     attributes; /* Closed Caption, Childrens, Directors etc */
     
     // Color lookup table for VOB subtitle tracks. Each entry is in YCbCr format.
     // Must be filled out by the demuxer for VOB subtitle tracks.
index 08e9400a0ce135b42c923fafb99950f0eb762db8..09ef619d70da8c6d30c6c73b7628661e7deb30e8 100644 (file)
@@ -441,6 +441,10 @@ static hb_dict_t* hb_title_to_dict_internal( hb_title_t *title )
             hb_error("json pack failure: %s", error.text);
             return NULL;
         }
+        if (subtitle->name != NULL)
+        {
+            hb_dict_set_string(subtitle_dict, "Name", subtitle->name);
+        }
         hb_value_array_append(subtitle_list, subtitle_dict);
     }
     hb_dict_set(dict, "SubtitleList", subtitle_list);
@@ -889,6 +893,10 @@ hb_dict_t* hb_job_to_dict( const hb_job_t * job )
                 "Burn",     hb_value_bool(subtitle->config.dest == RENDERSUB),
                 "Offset",   hb_value_int(subtitle->config.offset));
         }
+        if (subtitle->config.name != NULL)
+        {
+            hb_dict_set_string(subtitle_dict, "Name", subtitle->config.name);
+        }
         hb_value_array_append(subtitle_list, subtitle_dict);
     }
 
@@ -1579,10 +1587,12 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict )
             int burn = 0;
             const char *importfile = NULL;
             json_int_t offset = 0;
+            const char *name = NULL;
 
             result = json_unpack_ex(subtitle_dict, &error, 0,
-                                    "{s?i, s?{s:s}, s?{s:s}}",
+                                    "{s?i, s?s, s?{s:s}, s?{s:s}}",
                                     "Track", unpack_i(&track),
+                                    "Name",  unpack_s(&name),
                                     // Support legacy "SRT" import
                                     "SRT",
                                         "Filename", unpack_s(&importfile),
@@ -1594,6 +1604,7 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict )
                 hb_job_close(&job);
                 return NULL;
             }
+
             // Embedded subtitle track
             if (track >= 0 && importfile == NULL)
             {
@@ -1602,6 +1613,7 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict )
                 if (subtitle != NULL)
                 {
                     sub_config = subtitle->config;
+                    sub_config.name = name;
                     result = json_unpack_ex(subtitle_dict, &error, 0,
                         "{s?b, s?b, s?b, s?I}",
                         "Default",  unpack_b(&sub_config.default_track),
@@ -1650,6 +1662,7 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict )
                     hb_job_close(&job);
                     return NULL;
                 }
+                sub_config.name = name;
                 sub_config.offset = offset;
                 sub_config.dest = burn ? RENDERSUB : PASSTHRUSUB;
                 strncpy(sub_config.src_codeset, srtcodeset, 39);
index e353b0e322eadb23fd5cb8f6a3727ca65d4ac28d..353e519fcd71e9fae94fcc2f7999869a266266f2 100644 (file)
@@ -960,6 +960,12 @@ static int avformatInit( hb_mux_object_t * m )
         {
             av_dict_set(&track->st->metadata, "language", lang, 0);
         }
+        if (subtitle->config.name != NULL && subtitle->config.name[0] != 0)
+        {
+            // Set subtitle track title
+            av_dict_set(&track->st->metadata, "title",
+                        subtitle->config.name, 0);
+        }
     }
 
     if (need_fonts)
index 949b5f4a701e110127b39e69fe31f1e41fa96de0..5a7425a96044b16fb54ac7fb7cd072b9308a269c 100644 (file)
@@ -891,13 +891,15 @@ static int find_subtitle_track(const hb_title_t *title,
 }
 
 static void add_subtitle(hb_value_array_t *list, int track,
-                         int make_default, int force, int burn)
+                         int make_default, int force, int burn,
+                         const char * name)
 {
     hb_dict_t *subtitle_dict = hb_dict_init();
-    hb_dict_set(subtitle_dict, "Track", hb_value_int(track));
-    hb_dict_set(subtitle_dict, "Default", hb_value_bool(make_default));
-    hb_dict_set(subtitle_dict, "Forced", hb_value_bool(force));
-    hb_dict_set(subtitle_dict, "Burn", hb_value_bool(burn));
+    hb_dict_set_int(subtitle_dict, "Track", track);
+    hb_dict_set_bool(subtitle_dict, "Default", make_default);
+    hb_dict_set_bool(subtitle_dict, "Forced", force);
+    hb_dict_set_bool(subtitle_dict, "Burn", burn);
+    hb_dict_set_string(subtitle_dict, "Name", name);
     hb_value_array_append(list, subtitle_dict);
 }
 
@@ -962,7 +964,7 @@ static void add_subtitle_for_lang(hb_value_array_t *list, hb_title_t *title,
         behavior->burn_first &= !burn;
         behavior->one_burned |= burn;
         behavior->used[t] = 1;
-        add_subtitle(list, t, make_default, 0 /*!force*/, burn);
+        add_subtitle(list, t, make_default, 0 /*!force*/, burn, subtitle->name);
     }
 }
 
@@ -1180,7 +1182,8 @@ int hb_preset_job_add_subtitles(hb_handle_t *h, int title_index,
                         behavior.burn_first);
                 behavior.used[track] = 1;
                 behavior.one_burned |= burn;
-                add_subtitle(list, track, 0 /*default*/, 0 /*!force*/, burn);
+                add_subtitle(list, track, 0 /*default*/, 0 /*!force*/, burn,
+                             subtitle->name);
                 break;
             }
         }
index 1448ac4f00c0d6b43e56af43c3240e3abb4bb2e1..8182cb35cc7ccfe37c316d3a3914f723266012a4 100644 (file)
@@ -5414,6 +5414,8 @@ static void add_ffmpeg_subtitle( hb_title_t *title, hb_stream_t *stream, int id
 {
     AVStream          * st       = stream->ffmpeg_ic->streams[id];
     AVCodecParameters * codecpar = st->codecpar;
+    AVDictionaryEntry * tag_lang = av_dict_get(st->metadata, "language", NULL, 0 );
+    AVDictionaryEntry * tag_name = av_dict_get(st->metadata, "title", NULL, 0);
 
     hb_subtitle_t *subtitle = calloc( 1, sizeof(*subtitle) );
 
@@ -5474,16 +5476,18 @@ static void add_ffmpeg_subtitle( hb_title_t *title, hb_stream_t *stream, int id
             return;
     }
 
-    AVDictionaryEntry *tag;
     iso639_lang_t *lang;
 
-    tag = av_dict_get( st->metadata, "language", NULL, 0 );
-    lang = lang_for_code2( tag ? tag->value : "und" );
+    lang = lang_for_code2(tag_lang ? tag_lang->value : "und");
     snprintf(subtitle->lang, sizeof( subtitle->lang ), "%s [%s]",
              strlen(lang->native_name) ? lang->native_name : lang->eng_name,
              hb_subsource_name(subtitle->source));
     strncpy(subtitle->iso639_2, lang->iso639_2, 3);
     subtitle->iso639_2[3] = 0;
+    if (tag_name != NULL)
+    {
+        subtitle->name = strdup(tag_name->value);
+    }
 
     // Copy the extradata for the subtitle track
     if (codecpar->extradata != NULL)
index 073612b262aa8a7cf43b25c116c1562be418d75b..aa01aa56ca496344c871d5bc23d22c48bb27f1d3 100644 (file)
                     hb_subtitle_config_t sub_config;
                     int type = subTrack.type;
 
+                    sub_config.name = NULL;
                     sub_config.offset = subTrack.offset;
 
                     // we need to strncpy file name and codeset