Subtitles

Need help? Post your questions here.

Moderator: moderators

Postby Castius » Fri Jul 22, 2011 5:23 pm

I embed my subtitles as well. But i also generate srt files for player that use that method. They really are very different methods. One is image based and the other is text based. So for now i just make both.

Well the subtitles are really up to the jwplayer to handle. And from what i can tell the built in one is fairly limited. It only reads mp4 embedded subtitles. I think the changes i made would be pretty easy to add to the standard install of subsonic. Once i can figure out how to read and modify the path. So i don't need to store the srt files in subsonic.

I don't use memcoder. but i can see if i can get it working in the same way. So that it's burned into the video. But that still looks like it does it from a external file. So it doesn't change much.
Castius
 
Posts: 34
Joined: Wed Sep 02, 2009 9:11 pm

Postby tgrhp » Tue Jul 26, 2011 8:21 am

With the script there is no need to embed your subtitles. The script burns the subs into the transcode. The script also allows you to have separate srt files, which if found are also burned into the transcode. This means you dont have to modify any of your files, everything can be done on the fly.


There is another transcoder which has better ass/ssa support and also correctly handles chapters, is called HandBrake. But, it can't output to stdout. Also the output containers seems more limited [mp4 works].

Since the perl code looks like its piping a file to stdout, I have been trying to modify the perl code to use HandBrake instead. This is what I have so far [I removed the code that accepts separate srt files]:

Code: Select all
#!/usr/bin/perl

# Instructions:
#   install HandBrake
#   make symbolic link to HandBrakeCLI in /var/subsonic/transcode [may be unnecessary]
#   copy code to /var/subsonic/transcode/handbrake_hook.pl
#   make file executable
#   change pipe file location
#   change step 1 transcode settings to handbrake_hook.pl %o %s %bk %w %h

use strict;
use POSIX qw(mkfifo);

my ($start_offset, $file, $bitrate, $width, $height, @user_args) = @ARGV;

$bitrate =~ s/k$//;

# pipe file location
my $pipe = sprintf("/mnt/backup/pipes/%04d.HandBrakeCLI.mp4", int(rand(10000)));
mkfifo( $pipe, 0770 ) or die "Couldn't make pipe";

# arguments for transcoding file
my $args = ' -i "'.$file.'" -o "'.$pipe.'" --start-at '.$start_offset." -s 1 --subtitle-burn -B 192 -b ".$bitrate." -X ".$width." -Y ".$height." -R 44.1";

open OLDOUT, ">&", \*STDOUT;
open OLDERR, ">&", \*STDERR;

my $child = fork();
if (!$child) {
  # CHILD
  $SIG{'TERM'} = sub { syslog("info", "TERMED CHILD"); };
  print STDERR "HandBrakeCLI " .$args. join(" ", @user_args) . "\n";
  open STDOUT, ">", "/dev/null";
  open STDERR, ">", "/dev/null";
  exec("HandBrakeCLI". $args, @user_args);
}

# PARENT
$SIG{'TERM'} = sub {
  # Kill HandBrakeCLI with a SIGKILL so it actually quits
  kill 'KILL', $child;
  unlink $pipe;
  print STDERR "killed prematurely; child was $child\n";
};

# Print the pipe to stdout
open F, "<", $pipe or print STDERR "Pipe is missing!\n";
my $buf;
my $oldout = select(OLDOUT); $| = 1; select($oldout);
while (read F, $buf, 1024) {
  print OLDOUT $buf;
}

print STDERR "finished\n";



Examining the log the script seems to run fine. Running the command in the log correctly transcodes the file. I think its a problem with the pipe, but I dont know anything about pipes...

Any help would be appreciated.
tgrhp
 
Posts: 16
Joined: Wed Jul 13, 2011 3:54 pm

Re: Subtitles

Postby Drefsab » Tue Aug 30, 2011 7:58 am

having this in windows is exactly what I need using the embedded subs in MKV's I've downloaded I really cant wait to see this working.
Drefsab
 
Posts: 47
Joined: Sat May 07, 2011 9:44 am

Re: Subtitles

Postby Drefsab » Tue Aug 30, 2011 11:57 am

I just tried yostinso's script and get the same errors when playing video's (video not found or permission denied etc). Checking the log files they show nothing it suggests the transcode is finished. the pipe folder gets a 0kb file in it for the transcode.

So I had a look at the mencoder command thats being called:

mencoder "/home/drefsab/Downloads/1.mkv" -ss 0 -of lavf -oac lavc -ovc lavc -lavcopts vcodec=flv:vbitrate=1000:acodec=libmp3lame:abitrate=96 -srate 44100 -af lavcresample=44100 -lavfopts format=flv -vf harddup,scale=644:-3 -o test.flv

Gives:

MEncoder SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
success: format: 0 data: 0x0 - 0x11b724f8
[mkv] Track ID 1: video (V_MPEG4/ISO/AVC), -vid 0
[mkv] Track ID 2: audio (A_AAC), -aid 0, -alang und
[mkv] Track ID 3: subtitles (S_TEXT/ASS), -sid 0, -slang und
[mkv] Will play video track 1.
Matroska file format detected.
VIDEO: [avc1] 1280x720 24bpp 23.976 fps 0.0 kbps ( 0.0 kbyte/s)
[V] filefmt:31 fourcc:0x31637661 size:1280x720 fps:23.976 ftime:=0.0417
==========================================================================
Opening audio decoder: [faad] AAC (MPEG2/4 Advanced Audio Coding)
FAAD: compressed input bitrate missing, assuming 128kbit/s!
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
Selected audio codec: [faad] afm: faad (FAAD AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
** MUXER_LAVF *****************************************************************
REMEMBER: MEncoder's libavformat muxing is presently broken and can generate
INCORRECT files in the presence of B-frames. Moreover, due to bugs MPlayer
will play these INCORRECT files as if nothing were wrong!
*******************************************************************************
OK, exit.
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [scale w=644 h=-3]
Opening video filter: [harddup]
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
Audio LAVC, couldn't find encoder for codec libmp3lame.

Exiting..

As you can see it doesn't like the audio codec so I swapped this to:

mencoder "/home/drefsab/Downloads/1.mkv" -ss 0 -of lavf -oac mp3lame -ovc lavc -lavcopts vcodec=flv:vbitrate=1000:acodec=libmp3lame:abitrate=96 -srate 44100 -af lavcresample=44100 -lavfopts format=flv -vf harddup,scale=644:-3 -o test.flv

This gave:

MEncoder SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
success: format: 0 data: 0x0 - 0x11b724f8
[mkv] Track ID 1: video (V_MPEG4/ISO/AVC), -vid 0
[mkv] Track ID 2: audio (A_AAC), -aid 0, -alang und
[mkv] Track ID 3: subtitles (S_TEXT/ASS), -sid 0, -slang und
[mkv] Will play video track 1.
Matroska file format detected.
VIDEO: [avc1] 1280x720 24bpp 23.976 fps 0.0 kbps ( 0.0 kbyte/s)
[V] filefmt:31 fourcc:0x31637661 size:1280x720 fps:23.976 ftime:=0.0417
==========================================================================
Opening audio decoder: [faad] AAC (MPEG2/4 Advanced Audio Coding)
FAAD: compressed input bitrate missing, assuming 128kbit/s!
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
Selected audio codec: [faad] afm: faad (FAAD AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
** MUXER_LAVF *****************************************************************
REMEMBER: MEncoder's libavformat muxing is presently broken and can generate
INCORRECT files in the presence of B-frames. Moreover, due to bugs MPlayer
will play these INCORRECT files as if nothing were wrong!
*******************************************************************************
OK, exit.
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [scale w=644 h=-3]
Opening video filter: [harddup]
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
MP3 audio selected.
Pos: 0.0s 1f ( 0%) 0.00fps Trem: 0min 0mb A-V:0.000 [0:0]
1 duplicate frame(s)!
VIDEO CODEC ID: 22
AUDIO CODEC ID: 15001, TAG: 0
Writing header...
[flv @ 0xccb300]dimensions not set
Floating point exception

So I got past the first error but now have another, I've tried altering the scale setting but cant for the life of me figure out why its not setting the dimension.

*edit*

I have tried commands like:

mencoder "/home/drefsab/Downloads/1.mkv" "-ss" "0" "-of" "lavf" "-oac" "mp3lame" "-ovc" "lavc" "-lavcopts" "vcodec=flv:vbitrate=1000:acodec=libmp3lame:abitrate=96" "-srate" "44100" "-af" "lavcresample=44100" "-lavfopts" "format=flv" "-vf" "harddup,scale=644:360" "-o" "/var/subsonic/pipes/2257.mencoder" "-ass" "-sub" "/home/drefsab/Downloads/1.ass" "-subpos" "95"

as well but with no luck
Drefsab
 
Posts: 47
Joined: Sat May 07, 2011 9:44 am

Re: Subtitles

Postby RonanRaven » Mon Sep 12, 2011 6:38 pm

Drefsab wrote:I just tried yostinso's script and get the same errors when playing video's (video not found or permission denied etc). Checking the log files they show nothing it suggests the transcode is finished. the pipe folder gets a 0kb file in it for the transcode.

So I had a look at the mencoder command thats being called:

mencoder "/home/drefsab/Downloads/1.mkv" -ss 0 -of lavf -oac lavc -ovc lavc -lavcopts vcodec=flv:vbitrate=1000:acodec=libmp3lame:abitrate=96 -srate 44100 -af lavcresample=44100 -lavfopts format=flv -vf harddup,scale=644:-3 -o test.flv
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
Audio LAVC, couldn't find encoder for codec libmp3lame.

Exiting..

As you can see it doesn't like the audio codec so I swapped this to:

You may want to just look into installing the encoders for the mp3, you may have the decoders only, so I would look into getting the other packages. if you are using ubuntu it should be relatively easy: sudo apt-get install libmp3lame0, if this does not work for you, try the dev: sudo apt-get install sudo apt-get install libmp3lame-dev
RonanRaven
 
Posts: 1
Joined: Thu Sep 08, 2011 5:35 am

Re: Subtitles

Postby nikku » Wed Oct 05, 2011 2:07 pm

Drefsab wrote:I just tried yostinso's script and get the same errors when playing video's (video not found or permission denied etc). Checking the log files they show nothing it suggests the transcode is finished. the pipe folder gets a 0kb file in it for the transcode.

So I had a look at the mencoder command thats being called:

mencoder "/home/drefsab/Downloads/1.mkv" -ss 0 -of lavf -oac lavc -ovc lavc -lavcopts vcodec=flv:vbitrate=1000:acodec=libmp3lame:abitrate=96 -srate 44100 -af lavcresample=44100 -lavfopts format=flv -vf harddup,scale=644:-3 -o test.flv

Gives:

MEncoder SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
success: format: 0 data: 0x0 - 0x11b724f8
[mkv] Track ID 1: video (V_MPEG4/ISO/AVC), -vid 0
[mkv] Track ID 2: audio (A_AAC), -aid 0, -alang und
[mkv] Track ID 3: subtitles (S_TEXT/ASS), -sid 0, -slang und
[mkv] Will play video track 1.
Matroska file format detected.
VIDEO: [avc1] 1280x720 24bpp 23.976 fps 0.0 kbps ( 0.0 kbyte/s)
[V] filefmt:31 fourcc:0x31637661 size:1280x720 fps:23.976 ftime:=0.0417
==========================================================================
Opening audio decoder: [faad] AAC (MPEG2/4 Advanced Audio Coding)
FAAD: compressed input bitrate missing, assuming 128kbit/s!
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
Selected audio codec: [faad] afm: faad (FAAD AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
** MUXER_LAVF *****************************************************************
REMEMBER: MEncoder's libavformat muxing is presently broken and can generate
INCORRECT files in the presence of B-frames. Moreover, due to bugs MPlayer
will play these INCORRECT files as if nothing were wrong!
*******************************************************************************
OK, exit.
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [scale w=644 h=-3]
Opening video filter: [harddup]
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
Audio LAVC, couldn't find encoder for codec libmp3lame.

Exiting..

As you can see it doesn't like the audio codec so I swapped this to:

mencoder "/home/drefsab/Downloads/1.mkv" -ss 0 -of lavf -oac mp3lame -ovc lavc -lavcopts vcodec=flv:vbitrate=1000:acodec=libmp3lame:abitrate=96 -srate 44100 -af lavcresample=44100 -lavfopts format=flv -vf harddup,scale=644:-3 -o test.flv

This gave:

MEncoder SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
success: format: 0 data: 0x0 - 0x11b724f8
[mkv] Track ID 1: video (V_MPEG4/ISO/AVC), -vid 0
[mkv] Track ID 2: audio (A_AAC), -aid 0, -alang und
[mkv] Track ID 3: subtitles (S_TEXT/ASS), -sid 0, -slang und
[mkv] Will play video track 1.
Matroska file format detected.
VIDEO: [avc1] 1280x720 24bpp 23.976 fps 0.0 kbps ( 0.0 kbyte/s)
[V] filefmt:31 fourcc:0x31637661 size:1280x720 fps:23.976 ftime:=0.0417
==========================================================================
Opening audio decoder: [faad] AAC (MPEG2/4 Advanced Audio Coding)
FAAD: compressed input bitrate missing, assuming 128kbit/s!
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
Selected audio codec: [faad] afm: faad (FAAD AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
** MUXER_LAVF *****************************************************************
REMEMBER: MEncoder's libavformat muxing is presently broken and can generate
INCORRECT files in the presence of B-frames. Moreover, due to bugs MPlayer
will play these INCORRECT files as if nothing were wrong!
*******************************************************************************
OK, exit.
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [scale w=644 h=-3]
Opening video filter: [harddup]
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
MP3 audio selected.
Pos: 0.0s 1f ( 0%) 0.00fps Trem: 0min 0mb A-V:0.000 [0:0]
1 duplicate frame(s)!
VIDEO CODEC ID: 22
AUDIO CODEC ID: 15001, TAG: 0
Writing header...
[flv @ 0xccb300]dimensions not set
Floating point exception

So I got past the first error but now have another, I've tried altering the scale setting but cant for the life of me figure out why its not setting the dimension.

*edit*

I have tried commands like:

mencoder "/home/drefsab/Downloads/1.mkv" "-ss" "0" "-of" "lavf" "-oac" "mp3lame" "-ovc" "lavc" "-lavcopts" "vcodec=flv:vbitrate=1000:acodec=libmp3lame:abitrate=96" "-srate" "44100" "-af" "lavcresample=44100" "-lavfopts" "format=flv" "-vf" "harddup,scale=644:360" "-o" "/var/subsonic/pipes/2257.mencoder" "-ass" "-sub" "/home/drefsab/Downloads/1.ass" "-subpos" "95"

as well but with no luck


(Posting this for anyone who has this problem and stumbles upon this post)
I had this problem as well and resolved it by doing the following:
In Subsonic, go to the transcode tab as an admin. Go to where you placed the perl script line (probably something like conver.pl %b %.....)
at the end, add the option -ofps 22 and this error should go away.
This is a somewhat crappy explanation I know, but I'm at work and stumbled upon this so I figured I'd put something up!
nikku
 
Posts: 14
Joined: Sun Aug 14, 2011 11:39 pm

Re: Subtitles

Postby nattybumpo123 » Mon Oct 17, 2011 11:04 pm

I've set up subtitles exactly as indicated in @yostinso post. However, I don't get any subtitles showing up when I play a video. I'm not exactly sure what is wrong, other than I get a "av_interleaved_write_frame(): Operation not permitted" error once the video starts playing. Any help is appreciated. I've posted a hopefully relevant section from subsonic.log

[10/17/11 6:56:04 PM EDT] INFO PlaylistInputStream cody listening to "Season 05/The Big Bang Theory - 5x05 - The Russian Rocket Reaction.mkv"
[10/17/11 6:56:04 PM EDT] DEBUG TranscodeInputStream Starting transcoder: [/var/subsonic/transcode/mencoder_hook.pl] [0] [/media/Drive1/Video/Big Bang Theory/Season 05/The Big Bang Theory - 5x05 - The Russian Rocket Reaction.mkv] [1000k] [640] [360]
[10/17/11 6:56:04 PM EDT] DEBUG TranscodeInputStream Starting transcoder: [/var/subsonic/transcode/ffmpeg] [-ss] [0] [-i] [/media/Drive1/Video/Big Bang Theory/Season 05/The Big Bang Theory - 5x05 - The Russian Rocket Reaction.mkv] [-async] [1] [-b] [1000k] [-s] [640x360] [-ar] [44100] [-ac] [2] [-v] [0] [-f] [flv] [-]
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/mencoder_hook.pl) mencoder "/media/Drive1/Video/Big Bang Theory/Season 05/The Big Bang Theory - 5x05 - The Russian Rocket Reaction.mkv" "-ss" "0" "-of" "lavf" "-oac" "lavc" "-ovc" "lavc" "-lavcopts" "vcodec=flv:vbitrate=1000:acodec=libmp3lame:abitrate=96" "-srate" "44100" "-af" "lavcresample=44100" "-lavfopts" "format=flv" "-vf" "harddup,scale=640:-3" "-o" "/var/subsonic/pipes/7613.mencoder"
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) FFmpeg version SVN-r25838, Copyright (c) 2000-2010 the FFmpeg developers
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) built on Sep 20 2011 17:00:01 with gcc 4.4.5
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) configuration: --enable-libdc1394 --prefix=/usr --extra-cflags='-Wall -g ' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-avfilter --enable-libdirac --disable-decoder=libdirac --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-libvpx --enable-librtmp --extra-libs=-lgcrypt --disable-altivec --disable-armv5te --disable-armv6 --disable-vis
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) libavutil 50.33. 0 / 50.33. 0
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) libavcore 0.14. 0 / 0.14. 0
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) libavcodec 52.97. 2 / 52.97. 2
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) libavformat 52.87. 1 / 52.87. 1
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) libavdevice 52. 2. 2 / 52. 2. 2
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) libavfilter 1.65. 0 / 1.65. 0
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) libswscale 0.12. 0 / 0.12. 0
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) libpostproc 51. 2. 0 / 51. 2. 0
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) [matroska,webm @ 0x1af07a0] Estimating duration from bitrate, this may be inaccurate
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg)
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) Seems stream 0 codec frame rate differs from container frame rate: 47.95 (5994/125) -> 24.00 (24/1)
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) Input #0, matroska,webm, from '/media/Drive1/Video/Big Bang Theory/Season 05/The Big Bang Theory - 5x05 - The Russian Rocket Reaction.mkv':
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) Duration: 00:21:37.44, start: 0.000000, bitrate: 384 kb/s
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) Stream #0.0(eng): Video: h264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 23.98 fps, 24 tbr, 1k tbn, 47.95 tbc
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1, s16, 384 kb/s
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) Metadata:
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) title : English
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) [buffer @ 0x1b2eb90] w:1280 h:720 pixfmt:yuv420p
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) [scale @ 0x1b3b5e0] w:1280 h:720 fmt:yuv420p -> w:640 h:360 fmt:yuv420p flags:0xa0000004
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) Output #0, flv, to 'pipe:':
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) Metadata:
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) encoder : Lavf52.87.1
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) Stream #0.0(eng): Video: flv, yuv420p, 640x360 [PAR 1:1 DAR 16:9], q=2-31, 1000 kb/s, 1k tbn, 24 tbc
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) Stream #0.1(eng): Audio: libmp3lame, 44100 Hz, 2 channels, s16, 64 kb/s
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) Metadata:
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) title : English
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) Stream mapping:
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) Stream #0.0 -> #0.0
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) Stream #0.1 -> #0.1
[10/17/11 6:56:04 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) Press [q] to stop encoding
[10/17/11 6:56:13 PM EDT] DEBUG InputStreamReaderThread (/var/subsonic/transcode/ffmpeg) av_interleaved_write_frame(): Operation not permitted
nattybumpo123
 
Posts: 1
Joined: Mon Oct 17, 2011 10:54 pm

Re: Subtitles

Postby Poulpatine » Tue Nov 01, 2011 6:41 pm

Hi,

it's working.

Thanks for your help !!! :)
Poulpatine
 
Posts: 5
Joined: Wed Nov 17, 2010 9:05 pm

Re: Subtitles

Postby Aethies » Wed Nov 02, 2011 1:23 pm

Still getting Video not found or Access Denied. This is annoying as hell. I modified my subsonic user to allow it more access, but still got nothing. Anyone else figure this out, please, post it.

I have tried deleting and creating a new user, deleting the player.. nothing.. Still getting the same error. This is soooo aggravating..

Thanks
Aethies

Ubuntu Server 12.04
===================
3,281 artists
9,432 albums
113,608 songs
2636.09 GB (10,769 hours)
===================
User avatar
Aethies
 
Posts: 197
Joined: Fri Oct 24, 2008 4:33 pm

Re: Subtitles

Postby Dietch » Wed Nov 09, 2011 9:06 am

Hi everyone and thanks for sharing all the info ;)
I think I'd be grateful if someone make a step-by-step guide to install this script under a windows environment.
I'm a bit confused on where downloading mEncoder (which version), how installing it (it looks like I have to put it in a sub dir under subsonic dir) etc...

I'm really looking into this and not sure how to make it work without messing my system :)
Cheers,
Dietch
 
Posts: 1
Joined: Wed Nov 09, 2011 5:27 am

Re: Subtitles

Postby Drefsab » Wed Nov 16, 2011 6:01 pm

Ok I finally came back to looking into this (been busy with work and moving my hosting provider), and I have it working. However for those that are struggling I will give you a step by step for a ubuntu based linux system.

  • Install mencoder (apt-get install mencoder)
  • Create the folder /var/subsonic/pipes
  • Set /var/subsonic/pipes to be writeable (chmod 777 /var/subsonic/pipes)
  • Create a file called mencoder_hook.pl in the /var/subsonic/transcode/ folder
  • Make that file executable (chmod +x /var/subsonic/transcode/mencoder_hook.pl)
  • Edit the /var/subsonic/transcode/mencoder_hook.pl and paste in the following code:

    Code: Select all
    #!/usr/bin/perl

    # mencoder_hook.pl
    # Perl hook script for using mencoder to encode FLV with Subsonic
    #   Renders subtitles if they exist in the same dir and with the same name as
    #   the video and end in either .ass or .str
    # Usage:
    #   Install mencoder (apt-get install mencoder)
    #   Paste this script into mencoder_hook.pl in /var/subsonic/transcode/
    #   Make this scrip executable (chmod +x mencoder_hook.pl)
    #   Create the folder /var/subsonic/pipes
    #   Go to the "Transcoding" config in Subsonic
    #   Edit "mp4 > flv" (and any other video->flv encoders that you want)
    #   Set "Step 1" to:
    #   mencoder_hook.pl %o %s %bk %w %h -ofps 22
    #   Enjoy!
    #   If you are having trouble with video/audio sync issues, try adding "-mc 1", e.g.:
    #   mencoder_hook.pl %o %s %bk %w %h -ofps 22 -mc 1
    #   If you are getting the wrong audio track, use "-aid #", where # is the audio track number (they start at 1), e.g.:
    #   mencoder_hook.pl %o %s %bk %w %h -ofps 22 -aid 2


    use strict;
    use POSIX qw(mkfifo);

    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", "mp3lame",
      "-ovc", "lavc",
      "-lavcopts", "vcodec=flv:vbitrate=" . $bitrate . ":acodec=libmp3lame:abitrate=96",
      "-srate", "44100",
      "-af", "lavcresample=44100",
      "-lavfopts", "format=flv",
      "-vf", "harddup,scale=$width:-3",
      "-o", $pipe
    );


    foreach my $ext (".ass", ".srt") {
      my $subs = $file;
      $subs =~ s/\.[^\.]*$/$ext/;
      if (-e $subs) {
        push @args, (
          "-ass",
          "-sub", $subs,
          "-subpos", "95"
        );
      }
    }

    open OLDOUT, ">&", \*STDOUT;
    open OLDERR, ">&", \*STDERR;

    my $child = fork();
    if (!$child) {
      # CHILD
      $SIG{'TERM'} = sub { syslog("info", "TERMED CHILD"); };
      print STDERR "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 STDERR "killed prematurely; child was $child\n";
    };

    # Print the pipe to stdout
    open F, "<", $pipe or print STDERR "Pipe is missing!\n";
    my $buf;
    my $oldout = select(OLDOUT); $| = 1; select($oldout);
    while (read F, $buf, 1024) {
      print OLDOUT $buf;
    }

    print STDERR "finished\n";
  • Go to the "Transcoding" config in Subsonic
  • Remove mvk from "convert from" (or which ever format you want) on flv/h264 video.
  • Add a new transcoding option called flv/h264 video_subs.
  • Add mvk (or which ever format you want) to "convert from".
  • Set "convert to" as flv
  • Set "step 1" to mencoder_hook.pl %o %s %bk %w %h -ofps 22
  • Enjoy :)

Bugs:
There are bound to be some, but I've not personally hit any just yet.

Credit:
badsanta / yostinso for the original scripts
nikku for pointing out the solution to the "[flv @ 0xccb300]dimensions not set, Floating point exception" error
Everyone else that helped make the tools that makes this possible :)

Disclaimer:
This is what I used to get it working for my, I am not responsible if you kill your system, doesn't work on your distribution start world war 3 etc.
Drefsab
 
Posts: 47
Joined: Sat May 07, 2011 9:44 am

Re: Subtitles

Postby Aethies » Wed Nov 16, 2011 9:12 pm

Well, I put all this in place, stopped getting errors and everything is being created properly, I think, but I get video not found or access denied message.

Here is from the logs...
[2011-11-16 14:09:07,969] DEBUG TranscodeInputStream - Starting transcoder: [/var/subsonic/transcode/mencoder_hook.pl] [0] [/subsonic/Movies/Star And Flag.avi] [1000k] [640] [272] [-ofps] [22]
[2011-11-16 14:09:07,994] DEBUG InputStreamReaderThread - (/var/subsonic/transcode/mencoder_hook.pl) mencoder "/subsonic/Movies/Star and Flag.avi" "-ss" "0" "-of" "lavf" "-oac" "lavc" "-ovc" "lavc" "-lavcopts" "vcodec=flv:vbitrate=1000:acodec=libmp3lame:abitrate=96" "-srate" "44100" "-af" "lavcresample=44100" "-lavfopts" "format=flv" "-vf" "harddup,scale=640:-3" "-o" "/var/subsonic/pipes/4325.mencoder" "-ofps" "22"
[2011-11-16 14:09:08,099] DEBUG InputStreamReaderThread - (/var/subsonic/transcode/mencoder_hook.pl) finished

And it creates the file in pipes - 4325.mencoder but nothing plays. Just keep getting that error.

Any ideas?
Aethies

Ubuntu Server 12.04
===================
3,281 artists
9,432 albums
113,608 songs
2636.09 GB (10,769 hours)
===================
User avatar
Aethies
 
Posts: 197
Joined: Fri Oct 24, 2008 4:33 pm

Re: Subtitles

Postby Drefsab » Thu Nov 17, 2011 8:48 am

Are you defiantly using my edited mencoder_hook.pl?

Your log shows its using "-oac" "lavc", I could not get it working using this (see my previous post's) I've changed mencoder_hook.pl to use
"-oac", "mp3lame".

make the changes to mencoder_hook.pl and give it another go :)

RonanRaven's suggestions sadly did not resolve the issue lavc just constantly spits out errors so changing the auto codec like I mentioned fixed it :)
Drefsab
 
Posts: 47
Joined: Sat May 07, 2011 9:44 am

Re: Subtitles

Postby Aethies » Thu Nov 17, 2011 2:29 pm

Drefsab wrote:Are you defiantly using my edited mencoder_hook.pl?

Your log shows its using "-oac" "lavc", I could not get it working using this (see my previous post's) I've changed mencoder_hook.pl to use
"-oac", "mp3lame".

make the changes to mencoder_hook.pl and give it another go :)

RonanRaven's suggestions sadly did not resolve the issue lavc just constantly spits out errors so changing the auto codec like I mentioned fixed it :)



Just to post back, I just changed the settings and yes.. that fixed the issue. I will keep testing it, but I REALLY appreciate your help! Thanks a TON!!!
User avatar
Aethies
 
Posts: 197
Joined: Fri Oct 24, 2008 4:33 pm

Re: Subtitles

Postby Deluxe » Tue Jan 10, 2012 6:11 pm

Hi !

This is working really well (I suggest you change the post on the "tutorial" section of the forum with this new code).

But I've got the acces denied message on some videos... even if they are almost identical (for example, I got some Breaking Bad S02 episodes working perfectly, and then some with the access denied error).

The message in subsonic.log are identical, the file is created under /pipes....
Deluxe
 
Posts: 2
Joined: Tue Jan 10, 2012 6:03 pm

PreviousNext

Return to Help

Who is online

Users browsing this forum: No registered users and 18 guests