当前位置:网站首页>Fcpx quickly add subtitles | Final Cut Pro import fcpxml subtitle file does not match the video time? I got it in code
Fcpx quickly add subtitles | Final Cut Pro import fcpxml subtitle file does not match the video time? I got it in code
2022-06-25 09:28:00 【Maoningyi】
Click to view the video course ↓↓↓
fcpx Quickly add subtitles | final cut pro Import fcpxml The subtitle file does not match the video time ? I'll show you a way to get it done
Hello everyone , I'm Ning Yi , During this time, I upgraded my video editing device , from iMovie Upgrade to fcpx, It took me. 10 Hot pot 、100 Spicy hot money , Think about how inexplicable a little distressed ..
I want to improve the quality of my videos , The most important thing is to add subtitles to the video , But I got stuck doing subtitles , Import fcpxml The subtitle file does not match the video time
Next, I will show you the steps of making subtitles , And show me the problem and my solution
First, only the voice of the video is exported mp3 file , Note that the exported voice file should not have background music
Then import this file into Netease external worktable In this website , After adjusting the error , We can get one srt Subtitle files
Then use the website to srt Document conversion fcpxml file , Import to fcp Inside , All the way up to this point, everything went well
But behind , When I paste subtitles into the project , I found that these subtitles are not aligned , Each subtitle seems to be a little longer

And when switching subtitles , There is overlap

And it is the kind that can be right at the beginning , The later the time error is, the greater , If they're not right , I can also drag the subtitles , Now I need to correct the time one by one , It's too troublesome
however , We programmers are not vegetarian , The problem of batch processing can be solved by code ~~
So I opened it fcpxml Subtitle files , Analyzed his source code , Sure enough, I found a solution !
I won't talk about the specific analysis process , I spent a day and a half analyzing it .. Tell us the reason why the time is not right
It is in the subtitle we exported , The end and the beginning are at the same time , So in the video , At the same time , There will be two subtitle frames

In this way, the length of each caption is increased by one frame , And then the error becomes larger and larger
We need to shorten the time of each letter by one frame , So the subtitles are correct , Will be fcpxml In the document duration Subtract the number after the field 100, such as
// The original
duration="2700/3000s"
// After modification
duration="2600/3000s"
If you are not a programmer , You can paste my code directly , No other software needs to be installed , Just follow me step by step
Let's start with this fcpxml Copy the subtitle file , Rename it to new file , And rename the original subtitle file to old

Come and get it old The path to this file , Right click on the file , Click to display the profile , This location is the path , Let's make a copy of

Go to the application and open the terminal , Paste path , The paste may be different from the display , Turn into English format , It's like this , The users here will become User

Next we use Ruby Language to solve , It will be automatically installed on Macintosh ruby Environmental , If you are not sure if there is such an environment , You can enter ruby -v Check the ,-v There is a space before it , If the version number appears , It means there are ruby Environmental Science , You can follow me in the following operations
~$ ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
If not , You can find your programmer friends , Give him the code I'll paste next , Help you change it ~~
Of course, don't forget to send a red envelope to others , After all, programmers are very busy ~~~
We input... At the terminal irb, The front will become a serial number plus a rightwards arrow , Now you are in the state of code editing
~$ irb
2.2.1 :001 >
Next, let's define a path , Replace this path with the one you just copied old.fcpxml Path to file
~$ path = "/Users/xuzhaoning/Downloads"
Next, copy the following code
# Code copied for the first time
text = File.read("#{path}/old.fcpxml")
f = File.open("#{path}/old.fcpxml", "r")
f.each_line do |line|
m_duration = line.match(/duration.{
2}(\d*)\/3000s.{
1}/)
if m_duration && m_duration[1]
m_duration_num = m_duration[1].to_i
if m_duration_num > 100
m_duration_num = m_duration_num - 100
end
m_duration_true = m_duration[0].gsub(m_duration[1],m_duration_num.to_s)
puts "===m_duration=========#{m_duration[0]}======"
puts "===m_duration_true=========#{m_duration_true}======"
text = text.gsub(m_duration[0],m_duration_true)
end
end
Will print out some information ,m_duration_true The last number is always better than the last line m_duration The following numbers are small 100, It means that the code runs successfully
Next we will copy the following code , Import the corrected subtitles into new.fcpxml In file
# A second copy
path2 = "#{path}/new.fcpxml"
file = File.open(path2,"w")
file.write(text)
file.close
After completion of operation , Let's take this new.fcpxml File import to fcp in , Now the subtitle is consistent with the time of the video .
If there are few subtitles , It can also be in fcpxml Manual modification in the file duration The numerical , It should be noted that , This value can only be 100 Multiple , It can't be 50 55 Numbers like this
We have solved the problem of subtitles , So learn to write code , Not only can it be used to write projects , It can also solve many daily problems , come on. ~~
边栏推荐
- Notes on key vocabulary of the original English work biography of jobs (I) [introduction]
- Nodejs using the express framework demo
- 手机办理长城证券开户靠谱安全吗?
- 《乔布斯传》英文原著重点词汇笔记(四)【 chapter two 】
- Is it safe to open an account online? Who can I ask?
- Flutter multilingual intl: ^0.17.0 cannot be imported
- Is the security account opening risky and safe?
- Is it safe to open a stock account through the account opening QR code of the account manager? Or is it safe to open an account in a securities company?
- SQL高级
- 从别人库里拷贝的游戏如何再自己的库里显示
猜你喜欢

Prediction of pumpkin price based on BP neural network

matplotlib 简单逻辑回归可视化

Where are the hotel enterprises that have been under pressure since the industry has warmed up in spring?

How to delete a blank page that cannot be deleted in word

【OpenCV】—输入输出XML和YAML文件
![[opencv] - input and output XML and yaml files](/img/4e/7944e205c71246d0b0e3747eefca37.png)
[opencv] - input and output XML and yaml files

RMB 3000 | record "tbtools" video, make a friend and get a cash prize!

5、 Project practice --- identifying man and horse

matplotlib matplotlib中axvline()和axhline()函数

Matplotlib decision boundary drawing function plot in Matplotlib_ decision_ Boundary and plt Detailed explanation of contour function
随机推荐
Are the top ten securities companies at great risk of opening accounts and safe and reliable?
证券开户风险大吗,安全靠谱吗?
Atguigu---18-component
2、 Training fashion_ MNIST dataset
Is the client that gets the scanning code wechat or Alipay
Flutter multilingual intl: ^0.17.0 cannot be imported
C#启动程序传递参数丢失双引号,如何解决?
Online notes on Mathematics for postgraduate entrance examination (9): a series of courses on probability theory and mathematical statistics
[zero foundation understanding innovation and entrepreneurship competition] overall cognition and introduction of mass entrepreneurship and innovation competition (including FAQs and integration of bl
With the QQ group file storage function of super nice, you immediately have n cloud disks that are easy to download and never expire
Nodejs using the express framework demo
四、卷积神经网络(Convolution Neural Networks)
Socket programming -- poll model
Study on correlation of pumpkin price and design of price prediction model based on BP neural network
备战2022年金九银十必问的1000道Android面试题及答案整理,彻底解决面试的烦恼
Abbreviations of common English terms for IC R & D
[design completion - opening report] zufeinfo 2018 software engineering major (including FAQ)
Oracle one line function Encyclopedia
微服务调用组件Ribbon底层调用流程分析
matplotlib matplotlib中决策边界绘制函数plot_decision_boundary和plt.contourf函数详解