Subtitles

Need help? Post your questions here.

Moderator: moderators

Re: Subtitles

Postby nikku » Tue Apr 24, 2012 7:22 pm

Just figured I'd swing by and say that I did an alternative subtitle solution to this (mainly due to me having alot of Hi10p files that mencoder can't properly transcode). It's a lot more involved than this process is, but it uses the native encoder and instead involves utilizing a plugin within JWPlayer (captions plugin) and generating SRT subtitle files from the MKV video (I have a script I found which goes through all my MKV files on my server and extracts the subtitles from them, cleans them up, and converts them to an SRT file that the Captions plugin can use to render the subtitles within JWPlayer). I followed the procedure outlined in this posting: viewtopic.php?f=3&t=5708&p=34045&hilit=subtitle#p34045
If anyone is particularly interested in this (or about the scripts I used for the subtitle processing) feel free to let me know, I can try to explain the process or upload the scripts (forgot where I originally found them, but the author's name is within the credits of the script!)
nikku
 
Posts: 14
Joined: Sun Aug 14, 2011 11:39 pm

Re: Subtitles

Postby mohala » Fri May 04, 2012 11:45 pm

Hello,

Is there a possibility of someone creating a how-to for windows clients,
Also badsanta / yostinso versions are they able to use the embedded subtitles on files instead of having to rip the srt out of the files.
nearly all anime fan subbers embed it into mkv files and now on hi10p mkv files.

mo
mohala
 
Posts: 6
Joined: Fri May 04, 2012 11:37 pm

Re: Subtitles

Postby nikku » Mon May 07, 2012 4:55 pm

Hey,
At one point I had mine using embedded subs through the use of badsanta / yostinso's scripts, but that was only because mencoder was handling it and was able to do so. I haven't been able to find any way of having ffmpeg use the embedded subtitles, and since mencoder can't properly render hi10p I resorted to having a script generate SRT subtitles that could then be rendered along with the video, since ffmpeg is able to properly render hi10p content.
nikku
 
Posts: 14
Joined: Sun Aug 14, 2011 11:39 pm

Re: Subtitles

Postby f7n » Thu May 30, 2013 12:16 am

Does anyone have a link to mencoder source code? I don't have root privs, so I can't apt-get install mencoder.

Thanks
f7n
 
Posts: 8
Joined: Thu May 23, 2013 1:53 pm

Re: Subtitles

Postby Drefsab » Thu May 30, 2013 12:40 pm

If only I knew enough to code either subtitles burnin on ffmpeg or hi10p support in mencoder does anyone else who knows more know how much effort each option would take?
Drefsab
 
Posts: 47
Joined: Sat May 07, 2011 9:44 am

Re: Subtitles

Postby Noxeus » Fri Dec 06, 2013 3:47 pm

I recently updated from 10.04 to 12.04 LTS and now I can't use a start time.
When I start from -ss "0" it works fine, but if I start on -say- -ss "60" the video is stuck and only audio will play.

Can anybody help me solve this?
Noxeus
 
Posts: 3
Joined: Wed Jan 25, 2012 4:29 pm

Re: Subtitles

Postby Noxeus » Thu Dec 19, 2013 3:58 pm

Turned out it had an internal error:
Code: Select all
pts < dts in stream 0

I fixed it by adding fixpts=22,fixpts to the -vf making it
Code: Select all
"-vf" "fixpts=22,fixpts,harddup,scale=$width:-3"
Noxeus
 
Posts: 3
Joined: Wed Jan 25, 2012 4:29 pm

Re: Subtitles

Postby bwadrochit » Thu Mar 05, 2015 6:37 pm

Damn, I managed it all to work, awsome, thanks to all.
@Noxeus, your last little fix was a life saver.
Here is my computed script that works for me (I redirected the log to the subsonic log file because I did not get any log otherwise).

Code: Select all
#!/usr/bin/perl
use strict;
use POSIX qw(mkfifo);

my $logfile = "/var/subsonic/subsonic.log";
open(my $logger, '>>', $logfile) or die "Could not open log file '$logfile' $!";
print $logger "[mencoder_hook] START\n";

my ($start_offset, $file, $bitrate, $width, $height, @user_args) = @ARGV;
$bitrate =~ s/k$//;
my $pipe = sprintf("/var/subsonic/pipes/%04d.mencoder", int(rand(10000)));
mkfifo( $pipe, 0770 ) or die "Couldn't make pipe";
my @args = (
  $file,
  "-ss", $start_offset,
  "-of", "lavf",
  "-oac", "lavc",
  "-ovc", "lavc",
  "-lavcopts", "vcodec=flv:vbitrate=" . $bitrate ,
  "-oac", "mp3lame",
  "-lameopts", "abr:br=96:vol=4",
  "-srate", "44100",
  "-af", "lavcresample=44100",
  "-lavfopts", "format=flv",
  "-vf", "fixpts=22,fixpts,harddup,scale=$width:-3",
  "-utf8",
  "-o", $pipe
);
foreach my $ext (".ass", ".srt") {
  my $subs = $file;
  $subs =~ s/\.[^\.]*$/$ext/;
  if (-e $subs) {
    if ($ext eq ".ass") {
       push @args, (
         "-ass", $subs,
         "-subpos", "95"
       );
    } else {
       push @args, (
         "-sub", $subs,
         "-subpos", "95"
       );
    }
  }
}
open OLDOUT, ">&", \*STDOUT;
open OLDERR, ">&", \*STDERR;
my $child = fork();
if (!$child) {
  # CHILD
  $SIG{'TERM'} = sub { syslog("info", "TERMED CHILD"); };
  print $logger "[mencoder_hook] mencoder " . join(" ", map { "\"$_\"" } @args, @user_args) . "\n";
  open STDOUT, ">", "/dev/null";
  open STDERR, ">", "/dev/null";
  exec("mencoder", @args, @user_args);
}
# PARENT
$SIG{'TERM'} = sub {
  # Kill mencoder with a SIGKILL so it actually quits
  kill 'KILL', $child;
  unlink $pipe;
  print $logger "[mencoder_hook] killed prematurely; child was $child\n";
  close $logger;
};
# Print the pipe to stdout
open F, "<", $pipe or print $logger "Pipe is missing!\n";
my $buf;
my $oldout = select(OLDOUT); $| = 1; select($oldout);
while (read F, $buf, 1024) {
  print OLDOUT $buf;
}
print $logger "[mencoder_hook] finished\n";
close $logger;


Anyway, I'm digging out this topic because I'm dreaming about making this work for external players, such as android apps. But I don't have a clue about how to do it. I tried to play with all the transcripting commands, but it did not even alter the process. The encoding command that is prompted in the log file when i play a video from an external player remains the same whatever I do :
Code: Select all
INFO TranscodeInputStream - Starting transcoder: [/var/subsonic/transcode/ffmpeg] [-r] [1] [-ss] [60] [-t] [1] [-i] [/path/to/video.mp4] [-s] [106x60] [-v] [0] [-f] [mjpeg] [-]

Waiting for the Subsonic developers to officialy implement subtitle support (if it's even on the roadmap), any help on how to make subtitles works with external players would be greatly appreciated.
bwadrochit
 
Posts: 1
Joined: Thu Mar 05, 2015 4:51 pm

Previous

Return to Help

Who is online

Users browsing this forum: No registered users and 35 guests