Marksdo / Whisper

Batch Local Transcribe Audio/Movie To Text With Whisper AI Model. Keep Privacy Safe!
https://whisper.marksdo.com
8 stars 1 forks source link

How can I add a specific Custom export template? #22

Open dhckdgjs opened 4 months ago

dhckdgjs commented 4 months ago

I want to add "Final cut Pro 29.97fps drop frame" to custom option in the Custom export template, Can you provide an example?

Marksdo commented 4 months ago

Try add below code to template code to custom template

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fcpxml>
<fcpxml version="1.9">
  <resources>
    <format id="r1" name="FFVideoFormat1080p2997" frameDuration="2002/60000s" width="1920" height="1080" colorSpace="1-1-1 (Rec. 709)"/>
    <effect id="r2" name="Basic Title" uid=".../Titles.localized/Bumper:Opener.localized/Basic Title.localized/Basic Title.moti"/>
  </resources>
  <library>
    <event name="{{ projectName }}" uid="{{ 32|rand }}">
      <project name="{{ projectName }}" uid="{{ 32|rand }}" modDate="2023-08-25 04:43:49 +0000">
        <sequence format="r1" duration="{{ durationSecond|m:60060 }}/60000s" tcStart="0s" tcFormat="NDF" audioLayout="stereo" audioRate="48k">
          <spine>
            <gap name="Gap" offset="0s" start="0s" duration="{{ durationSecond|m:60060 }}/60000s">
                {% for st in subtitles %}
              <title ref="r2" lane="1" name="{{ st.text|escXML }} - Basic Title" offset="{{ st.t0s|m:60060 }}/60000s" start="{{ st.t0s|m:60060 }}/60000s" duration="{{ st.tds1|m:60060 }}/60000s">
                <param name="Flatten" key="9999/999166631/999166633/2/351" value="1"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/3142713059/401" value="1 (Center)"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/999169573/401" value="1 (Center)"/>
                <text>
                  <text-style ref="ts{{ st.idx1 }}">{{ st.text|escXML }}</text-style>
                </text>
                <text-style-def id="ts{{ st.idx1 }}">
                  <text-style font="Helvetica" fontSize="60" fontFace="Regular" fontColor="1 1 1 1" alignment="center"/>
                </text-style-def>
              </title>
             {% endfor %}
            </gap>
          </spine>
        </sequence>
      </project>
    </event>
    <smart-collection name="Projects" match="all">
      <match-clip rule="is" type="project"/>
    </smart-collection>
    <smart-collection name="All Video" match="any">
      <match-media rule="is" type="videoOnly"/>
      <match-media rule="is" type="videoWithAudio"/>
    </smart-collection>
    <smart-collection name="Audio Only" match="all">
      <match-media rule="is" type="audioOnly"/>
    </smart-collection>
    <smart-collection name="Stills" match="all">
      <match-media rule="is" type="stills"/>
    </smart-collection>
    <smart-collection name="Favorites" match="all">
      <match-ratings value="favorites"/>
    </smart-collection>
  </library>
</fcpxml>
image
dhckdgjs commented 4 months ago

Thank you for getting back to me. Upon implementing the code you recommended, I observed the resulting outcome.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fcpxml>
<fcpxml version="1.9">
  <resources>
    <format id="r1" name="FFVideoFormat1080p2997" frameDuration="2002/60000s" width="1920" height="1080" colorSpace="1-1-1 (Rec. 709)"/>
    <effect id="r2" name="Basic Title" uid=".../Titles.localized/Bumper:Opener.localized/Basic Title.localized/Basic Title.moti"/>
  </resources>
  <library>
    <event name="TEST-Seq" uid="Y5W678X2NZ0TR6AIVJ78IYC1JT8VSWHL">
      <project name="TEST-Seq" uid="UWDNIIKSXQI6O099ZKJKV6CKX8VA43LZ" modDate="2023-08-25 04:43:49 +0000">
        <sequence format="r1" duration="15615600/60000s" tcStart="0s" tcFormat="DF" audioLayout="stereo" audioRate="48k">
          <spine>
            <gap name="Gap" offset="0s" start="0s" duration="15615600/60000s">

              <title ref="r2" lane="1" name="TESTTESTTEST1 - Basic Title" offset="0/60000s" start="0/60000s" duration="120120/60000s">
                <param name="Flatten" key="9999/999166631/999166633/2/351" value="1"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/3142713059/401" value="1 (Center)"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/999169573/401" value="1 (Center)"/>
                <text>
                  <text-style ref="ts1"> TESTTESTTEST1</text-style>
                </text>
                <text-style-def id="ts1">
                  <text-style font="Helvetica" fontSize="60" fontFace="Regular" fontColor="1 1 1 1" alignment="center"/>
                </text-style-def>
              </title>

              <title ref="r2" lane="1" name="TESTTESTTEST2 - Basic Title" offset="120120/60000s" start="120120/60000s" duration="240240/60000s">
                <param name="Flatten" key="9999/999166631/999166633/2/351" value="1"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/3142713059/401" value="1 (Center)"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/999169573/401" value="1 (Center)"/>
                <text>
                  <text-style ref="ts2"> TESTTESTTEST2</text-style>
                </text>
                <text-style-def id="ts2">
                  <text-style font="Helvetica" fontSize="60" fontFace="Regular" fontColor="1 1 1 1" alignment="center"/>
                </text-style-def>
              </title>

              <title ref="r2" lane="1" name="TESTTESTTEST3 - Basic Title" offset="300300/60000s" start="300300/60000s" duration="120120/60000s">
                <param name="Flatten" key="9999/999166631/999166633/2/351" value="1"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/3142713059/401" value="1 (Center)"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/999169573/401" value="1 (Center)"/>
                <text>
                  <text-style ref="ts3"> TESTTESTTEST3 </text-style>
                </text>
                <text-style-def id="ts3">
                  <text-style font="Helvetica" fontSize="60" fontFace="Regular" fontColor="1 1 1 1" alignment="center"/>
                </text-style-def>
              </title>

(and so on)

Meanwhile, when trying an alternative online free tool, I obtained a different outcome. eg: https://en.editingtools.io/subtitles/

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fcpxml>
<fcpxml version="1.9">
  <resources>
    <format id="r1" name="FFVideoFormat1080p2997" frameDuration="2002/60000s" width="1920" height="1080" colorSpace="1-1-1 (Rec. 709)"/>
    <effect id="r2" name="Basic Title" uid=".../Titles.localized/Bumper:Opener.localized/Basic Title.localized/Basic Title.moti"/>
  </resources>
  <library>
    <event name="TEST-Seq" uid="1201A58E9869E03E26DC4C938D182864">
      <project name="TEST-Seq" uid="BB3174B0AD52C9E5E0EEC06B37F77435" modDate="2024-02-12 18:57:51 +0000">
        <sequence format="r1" duration="15675660/60000s" tcStart="0/30s" tcFormat="NDF" audioLayout="stereo" audioRate="48k">
          <spine>
            <gap name="Gap" offset="0s" start="0s" duration="15675660/60000s">
              <title ref="r2" lane="1" name="TESTTESTTEST1 - Basic Title" offset="0/60000s" start="0/60000s" duration="120120/60000s">
                <param name="Flatten" key="9999/999166631/999166633/2/351" value="1"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/3142713059/401" value="1 (Center)"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/999169573/401" value="1 (Center)"/>
                <text>
                  <text-style ref="ts1"> TESTTESTTEST1 </text-style>
                </text>
                <text-style-def id="ts1">
                  <text-style font="Helvetica" fontSize="60" fontColor="1 1 1 1" alignment="center" fontFace="Regular"/>
                </text-style-def>
              </title>
              <title ref="r2" lane="1" name="TESTTESTTEST2 - Basic Title" offset="120120/60000s" start="120120/60000s" duration="208208/60000s">
                <param name="Flatten" key="9999/999166631/999166633/2/351" value="1"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/3142713059/401" value="1 (Center)"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/999169573/401" value="1 (Center)"/>
                <text>
                  <text-style ref="ts2"> TESTTESTTEST2 </text-style>
                </text>
                <text-style-def id="ts2">
                  <text-style font="Helvetica" fontSize="60" fontColor="1 1 1 1" alignment="center" fontFace="Regular"/>
                </text-style-def>
              </title>
              <title ref="r2" lane="1" name="TESTTESTTEST3 - Basic Title" offset="328328/60000s" start="328328/60000s" duration="92092/60000s">
                <param name="Flatten" key="9999/999166631/999166633/2/351" value="1"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/3142713059/401" value="1 (Center)"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/999169573/401" value="1 (Center)"/>
                <text>
                  <text-style ref="ts3"> TESTTESTTEST3</text-style>
                </text>
                <text-style-def id="ts3">
                  <text-style font="Helvetica" fontSize="60" fontColor="1 1 1 1" alignment="center" fontFace="Regular"/>
                </text-style-def>
              </title>

(and so on)

It appears that there might be an error in the calculation of the "Duration" for elements such as Sequence, Gap, Title, etc. Consequently, the "Title" appears to be generated with a longer duration in FCPX compared to the outcome in SRT from the Whisper Mate.

Marksdo commented 4 months ago

I have found that the current template functions do not support generating related templates. We need to add corresponding template functions and properties to support the output of the corresponding templates in the V5.5.2 version.

dhckdgjs commented 4 months ago

Thank you for your response to my feedback. I'll be waiting for the next version to reflect the function-related updates. Thanks.

Marksdo commented 4 months ago

I just make an beta version of Whisper Mate, add new template functions to support export format like editingtools format, Can you download it to test?

The appstore version will not release soon. (Have other user's features developing)

https://download.marksdo.com/apps/WhisperMate/beta/WhisperMate552beta.zip

load fcpxml 29.97 from example or paste the below template code

image
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fcpxml>
<fcpxml version="1.9">
  <resources>
    <format id="r1" name="FFVideoFormat1080p2997" frameDuration="2002/60000s" width="1920" height="1080" colorSpace="1-1-1 (Rec. 709)"/>
    <effect id="r2" name="Basic Title" uid=".../Titles.localized/Bumper:Opener.localized/Basic Title.localized/Basic Title.moti"/>
  </resources>
  <library>
    <event name="{{ projectName }}" uid="{{ 32|rand }}">
      <project name="{{ projectName }}" uid="{{ 32|rand }}" modDate="2023-08-25 04:43:49 +0000">
        {%- setvar durationSegLatest|div:1000|m:30|round:-1|m:2002 durationFCPSRT %}
        <sequence format="r1" duration="{{durationFCPSRT}}/60000s" tcStart="0/30s" tcFormat="NDF" audioLayout="stereo" audioRate="48k">
          <spine>
            <gap name="Gap" offset="0s" start="0s" duration="{{ durationFCPSRT }}/60000s">
                {%- for st in subtitles -%}
          {%- setvar st.t0ss|m:30|round:-1|m:2002 st0fcps -%}
          {%- setvar st.t1ss|m:30|round:-1|m:2002 st1fcps -%}
          {%- setvar st.tdss|m:30|round:-1|m:2002 stdfcps -%}
          {%- setvar st1fcps|minus:st0fcps st10fcps %}
              <title ref="r2" lane="1" name="{{ st.text|escXML }} - Basic Title" offset="{{st0fcps}}/60000s" start="{{st0fcps}}/60000s" duration="{{stdfcps}}/60000s">
                <param name="Flatten" key="9999/999166631/999166633/2/351" value="1"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/3142713059/401" value="1 (Center)"/>
                <param name="Alignment" key="9999/999166631/999166633/2/354/999169573/401" value="1 (Center)"/>
                <text>
                  <text-style ref="ts{{ st.idx1 }}">{{ st.text|escXML }}</text-style>
                </text>
                <text-style-def id="ts{{ st.idx1 }}">
                  <text-style font="Helvetica" fontSize="60" fontFace="Regular" fontColor="1 1 1 1" alignment="center"/>
                </text-style-def>
              </title>
             {% endfor %}
            </gap>
          </spine>
        </sequence>
      </project>
    </event>
    <smart-collection name="Projects" match="all">
      <match-clip rule="is" type="project"/>
    </smart-collection>
    <smart-collection name="All Video" match="any">
      <match-media rule="is" type="videoOnly"/>
      <match-media rule="is" type="videoWithAudio"/>
    </smart-collection>
    <smart-collection name="Audio Only" match="all">
      <match-media rule="is" type="audioOnly"/>
    </smart-collection>
    <smart-collection name="Stills" match="all">
      <match-media rule="is" type="stills"/>
    </smart-collection>
    <smart-collection name="Favorites" match="all">
      <match-ratings value="favorites"/>
    </smart-collection>
  </library>
</fcpxml>
dhckdgjs commented 4 months ago

I just tested it in FCPX with the new version app you just sent me.(5.2.2 beta) At 29.97fps(in custom option), I export the fcpxml file after changing only the Drop frames I needed, and now the timeline and titles are the right length.

Screenshot 2024-02-16 at 22 32 22

I really appreciate the quick feedback. I'll be in touch with you if there are any bugs I find in the future as I use it in my field.

Marksdo commented 4 months ago

I'll be in touch with you if there are any bugs I find in the future as I use it in my field.

With your suggestions, Whisper Mate will become even better.