Русские субтитры: Сдвиг субтитров (с учётом реакции) - Русские субтитры

Перейти к содержимому

Страница 1 из 1
  • Вы не можете создать новую тему
  • Вы не можете ответить в тему

Сдвиг субтитров (с учётом реакции)

#1 Пользователь офлайн   BedaZzle Иконка

  • Иконка
  • Отправить ЛС
  • Группа: Admin
  • Сообщений: 2 991
  • Регистрация: 22 Октябрь 02
  • Страна:
  • Прислал(a) субтитров: 96
  • Своих переводов: 16

Отправлено 17 Апрель 2007 - 02:12

Скрипт производит смещение выделенных субтитров на 8 кадров назад, чтобы компенсировать задержку между началом произносимого текста и нажатием комбинации клавиш Alt+Z.
Также если предыдущий субтитр заканчиваестя меньше чем за (8+4+10) кадров до выделенного, его длительность увеличивается.


// Compensates for reaction time after pressing Alt-Z.
// Made by Tengo (flag & MsgBox bij Bedazzle).
//
// Shifts initial time of selected subs 8 frames back, to delete the reaction time
// between the beginning of speech and pressing Alt-Z.
// And maximizes the duration of the previous sub, if it ends less than (8+4+10) frames
// before the selected one. This way closely packed subs are placed end to front,
// 4 frames apart.
//
// This script is based on frames.
// Press F4 if the sidepanel isn't visible.
// Set the mode to frames and press F4 again.
//
// If you like my script and you use it a lot.
// You can change the shortcut for this script to Alt-A.
// which is more practical than Shift+Ctrl+1 to 5
//
// Changing the shorycut keys is done by editing shortcuts.key
// Which key you need to change depends on the original shortcut key.
// If the script is the first in the list, find SetKey(aPascalScript1,Shift+Ctrl,1)
// and set it to SetKey(aPascalScript1,Alt,A)
//
// The sequence now becomes:
// Start the movie, wait until speech begins and press Alt-Z
// Wait until speech ends and press Alt-X
// followed by Alt-A if you changed it, otherwise it's one of Shift+Ctrl+1 to 5.
// Double click the subtitle. If everything works as it should,
// the sub will start at the precise moment the speech is heard.
//
// If you find yourself adding or subtract frames to the begin time on a regular basis,
// your reaction time is different from mine. You can correct this by changing ReactionTime.
// If the sub starts too early, set it to 7 or less, otherwise set it to 8 or more.
//
// Enjoy...

program CompensateReactionTime;

var
  Flag		 : Boolean;
  FPS		  : Integer;
  ReactionTime : Integer;
  DesiredGap   : Integer;
  Shift		: Integer;
  i			: Integer;
  Count		: Integer;
  Init		 : Integer;
  Final		: Integer;
  Gap		  : Integer;
  Margin	   : Integer;

begin
  Flag		 := False;				   // did the user select any subtitles? (thx B)
  FPS		  := 24;					  // framerate
  ReactionTime := 8						// the frames it takes to push Alt-Z after speech has begun
  DesiredGap   := Round(4 * 1/FPS * 1000); // set this to your desired spacing, in frames. [1..n], 4 = default
  Margin	   := Round(10 * 1/FPS * 1000) // margin for pulling subs together. 10 = default, 0 = off
  Count		:= GetSubtitleCount;

  Shift := Round(ReactionTime * 1/FPS * 1000); // the # of ms the InitialTime will shifted

  for i := 0 to Count-1 do
  begin
	if ((Flag = False) and (IsSubtitleSelected(i) = True)) then
	  begin
		Init  := GetSubtitleInitialTime(i) - Shift;
		SetSubtitleInitialTime(i, Init);

		if i > 1 then // correct overlap with previous sub
		begin
		  Final := GetSubtitleFinalTime(i-1);
		  Gap   := Init - Final;

		  if Gap < (DesiredGap + Margin) then
		  begin
			Final := Init - DesiredGap;
			SetSubtitleFinalTime(i-1, Final);
		  end;
		end;

		Flag := True;
	  end;
  end;

  if (Flag = False) then
	MsgBox('You must select a subtitle!', '&Ok', '', '', $20);

end.

0

Страница 1 из 1
  • Вы не можете создать новую тему
  • Вы не можете ответить в тему