웹 페이지에 FLV 파일이있는 자막을 표시하는 방법은 무엇입니까?

StackOverflow https://stackoverflow.com/questions/674812

  •  21-08-2019
  •  | 
  •  

문제

FLV 파일로 온라인으로 참여하고 싶은 MP4 형식의 비디오 용 자막을 만들었습니다. 비디오 이미지에 통합하지 않고 자막을 FLV 파일과 함께 플레이 할 수 있으므로 SRT 형식으로 유지할 수 있습니까?

도움이 되었습니까?

해결책

JW FLV 플레이어를 사용하여 방법을 찾았습니다.

  1. .srt 파일을 XML 파일로 변환하십시오 (아래의 php 코드)
  2. 그런 다음 XML 파일을 가리키는 변수 "캡션"을 추가하십시오.

s0.addvariable ( "captions", "path/to/subtitles.xml");

라이브 예 여기

// script to convert multi-line srt caption files to new-format (02-05-08) tt XML caption files
$use_cdata_tags = true;
$debug_output = true;

// the directory to write the new files in
// it must exist, be writeable, and be outside of the directory that is being scanned
$new_directory = '../temp/';

/////////////////////////////////// no user configuration below this \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

// get filename or scan directory if it's a directory
$filename = (isset($_GET["filename"])) ? strval($_GET["filename"]) : "./";

// read each file into an array
$it = new RecursiveDirectoryIterator("$filename");

foreach(new RecursiveIteratorIterator($it) as $file)
{

// debug('Filename', $file); exit;
// debug('Ext', substr(strtolower($file), (strlen($file) - 4), 4));// exit;

// debug - only use test file
// if($file == '.\multi-line_test_file.srt')

  // check for .srt extension
  if(substr(strtolower($file), (strlen($file) - 4), 4) == '.srt')
  {
    $ttxml     = '';
    $full_line = '';

    if($file_array = file($file))
    {
      // write tt , head, and div elements for the new file
     $ttxml .= "";
      $ttxml .= "\n";
      $ttxml .= "  \n";
      $ttxml .= "  \n";
      $ttxml .= "  \n";
      $ttxml .= "    \n";

      foreach($file_array as $line)
      {
        $line = rtrim($line);

// debug('Line', $line);

        // get begin and end
        //                00  :  00  :  32  ,   000   -->   00  :  00  :  37  ,   000
        if(preg_match('/(\d\d):(\d\d):(\d\d),(\d\d\d) --> (\d\d):(\d\d):(\d\d),(\d\d\d)/', $line, $match))
        {
          $begin = $match[1] . ":" . $match[2] . ":" . $match[3] . "." . $match[4];
          $end   = $match[5] . ":" . $match[6] . ":" . $match[7] . "." . $match[8];
          $full_line = '';
        }
        // if the next line is not blank, get the text
        elseif($line != '')
        {
          if($full_line != '')
          {
            $full_line .= '
' . $line; } else { $full_line .= $line; } } // if the next line is blank, write the paragraph if($line == '') { // write new paragraph // Nothing is going on.

if($use_cdata_tags) { $ttxml .= "

\n"; } else { $ttxml .= " " . $full_line . "

\n"; } // debug('Text', $line); // debug('ttxml', $ttxml); exit; $full_line = ''; } } // write ending tags $ttxml .= " \n"; $ttxml .= " \n"; $ttxml .= "\n"; // write new file $new_file = $new_directory . substr($file, 0, (strlen($file) - 4)) . '.xml'; $fh = fopen($new_file, 'w') or die('Can\'t open: ' . $new_file); fwrite($fh, $ttxml) or die('Can\'t write to: ' . $new_file); fclose($fh); } } } function debug($title, $value) { global $debug_output; if ($debug_output) { print "
";
    if (is_array($value))
    {
      print $title . ":\n";
      print_r($value);
    }
    else
    {
      print $title . ": " . $value;
    }
    print "
\n"; } } ?>

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top