Transcoding Video to FLV for use in new JWPlayer

Need help? Post your questions here.

Moderator: moderators

Transcoding Video to FLV for use in new JWPlayer

Postby braddyo » Wed Feb 04, 2009 9:28 pm

Hello,

I've been toying with ffmpeg (windows binary found here) to get it to transcode any of my .mp4, .avi, .mpg videos to flv. Many of my videos are HD and around 6-10GB. FFMPEG does support on the fly transcoding and from what I understand can output to stdout. I have a rule set up in transcoding that is "ffmpeg -re -y -i %s -f flv" but it doesn't work. All my log says that it starts loading the 'song' and nothing else happens. My bandwidth goes crazy, but I don't know what it's doing.

Does anyone here have experience with ffmpeg? The following page shows how to get it working with Jinzora, and might be a good starting point.

Bradford
User avatar
braddyo
 
Posts: 97
Joined: Mon Oct 29, 2007 10:27 pm
Location: UT

Postby BrianDelShasta » Thu Feb 05, 2009 1:25 am

I played around with this for a bit One area to look at is the playlist generated by subsonic. I believe its using an xspf xml v1 format. I would verify first that you can transcode correctly using ffmpeg to an external player like vlc using the flv format.
BrianDelShasta
 
Posts: 116
Joined: Tue Jun 03, 2008 4:45 am
Location: USA

Postby BrianDelShasta » Thu Feb 05, 2009 2:11 am

Cool, actually it is easily possible now. I got it to work by doing this:

change one line in playlist.jsp to give the flash player space to actually view the video, for example:

From this:
Code: Select all
swfobject.embedSWF("<c:url value="/flash/player.swf"/>", "placeholder", "340", "20", "9.0.0", false, flashvars, params, attributes);


to this:
Code: Select all
swfobject.embedSWF("<c:url value="/flash/player.swf"/>", "placeholder", "340", "320", "9.0.0", false, flashvars, params, attributes);


Next create a new transcoder. I used these options for ffmpeg:

Code: Select all
ffmpeg -re -y -i %s -ar 44100 -f flv -


This is only a proof of concept and there are a couple of issues:
-need to make is so video only shows during full screen or whatever
-seek doesn't work
BrianDelShasta
 
Posts: 116
Joined: Tue Jun 03, 2008 4:45 am
Location: USA

Postby braddyo » Thu Feb 05, 2009 4:46 am

I'm glad it's working for you! That shows some great progress. Not so great for me though. Are you running this on linux or Windows? Did you get the same ffmpeg binary I linked to in my original post?

I have two transcoding rules: avi to flv, and mp4 to flv. When I try to transcode from avi to flv the video portion of JWPlayer shows "No Playable Video Found" error mesesage. The log shows nothing.

When I try to transcode mp4 to flv, the video screen in JWPlayer has an animated squiggly, and my bandwidth has traffic between subsonic-service.exe and firefox, about 30Mbps, however my processor is really low, which leads me to believe it isn't being transcoded, but loaded into the player. I haven't waited long enough for it to load the relatively small 1.7GB video I'm testing (not HD). The log shows:

[2/4/09 9:44:59 PM MST] INFO PlaylistInputStream Opening new song d:\documents\Videos\movies\Action Adventure\Chain Reaction.mp4


and that's it. Again, I haven't waited to see if it will play after it loads the whole video file, but I doubt it since it is not transcoding.
User avatar
braddyo
 
Posts: 97
Joined: Mon Oct 29, 2007 10:27 pm
Location: UT

Postby BrianDelShasta » Thu Feb 05, 2009 5:19 am

I would try streaming to VLC to at least make sure you have a good stream first, then move on to the flash player.
BrianDelShasta
 
Posts: 116
Joined: Tue Jun 03, 2008 4:45 am
Location: USA

Postby braddyo » Thu Feb 05, 2009 5:24 am

Good idea. I'm not too good with transcoding, is there a flag in ffmpeg where I specify a program to receive the stream?
User avatar
braddyo
 
Posts: 97
Joined: Mon Oct 29, 2007 10:27 pm
Location: UT

Postby BrianDelShasta » Thu Feb 05, 2009 5:32 am

Oh, no, actually you setup the transcoder the same way. Inside the setting for the playlist in subsonic choose the third option to disable the flash player. It will just spit out a playlist that you can open with an external program. Also, make sure the transcoder you created is enabled for the current playlist.
BrianDelShasta
 
Posts: 116
Joined: Tue Jun 03, 2008 4:45 am
Location: USA

Postby braddyo » Thu Feb 05, 2009 5:45 am

Oh, HAH! Silly me. In the player settings I have to activate the new transcoders, it's not enough to enable them in the transcoding section.

So, now that THAT's squared away, I'm trying to transcode a h264 film in a avi container.

Nothing happens. The log says:

2/4/09 10:40:31 PM MST] INFO PlaylistInputStream Opening new song d:\documents\Videos\movies\Action Adventure\300.avi
[2/4/09 10:40:31 PM MST] DEBUG TranscodeInputStream Starting transcoder: [d:\inetpub\wwwroot\subsonic\transcode\ffmpeg] [-re] [-y] [-i] [d:\documents\Videos\movies\Action Adventure\300.avi] [-ar] [44100] [-f] [flv] [-]
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) FFmpeg version SVN-r15815, Copyright (c) 2000-2008 Fabrice Bellard, et al.
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) configuration: --enable-memalign-hack --enable-postproc --enable-swscale --enable-gpl --enable-libfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libx264 --enable-libxvid --disable-ffserver --disable-vhook --enable-avisynth --enable-pthreads
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) libavutil 49.12. 0 / 49.12. 0
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) libavcodec 52. 3. 0 / 52. 3. 0
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) libavformat 52.23. 1 / 52.23. 1
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) libavdevice 52. 1. 0 / 52. 1. 0
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) libswscale 0. 6. 1 / 0. 6. 1
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) libpostproc 51. 2. 0 / 51. 2. 0
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) built on Nov 13 2008 10:28:29, gcc: 4.2.4 (TDM-1 for MinGW)
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) [NULL @ 0x141b700]Invalid and inefficient vfw-avi packed B frames detected
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) Input #0, avi, from 'd:\documents\Videos\movies\Action Adventure\300 [Edited...kinda].avi':
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) Duration: 01:51:41.06, start: 0.000000, bitrate: 1434 kb/s
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) Stream #0.0: Video: mpeg4, yuv420p, 656x272 [PAR 1:1 DAR 41:17], 23.98 tb(r)
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) Stream #0.1: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) Output #0, flv, to 'pipe:':
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) Stream #0.0: Video: flv, yuv420p, 656x272 [PAR 1:1 DAR 41:17], q=2-31, 200 kb/s, 23.98 tb(c)
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) Stream #0.1: Audio: libmp3lame, 44100 Hz, 5.1, s16, 64 kb/s
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) Stream mapping:
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) Stream #0.0 -> #0.0
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) Stream #0.1 -> #0.1
[2/4/09 10:40:31 PM MST] DEBUG InputStreamReaderThread (d:\inetpub\wwwroot\subsonic\transcode\ffmpeg) Error while opening codec for output stream #0.1 - maybe incorrect parameters such as bit_rate, rate, width or height
[2/4/09 10:40:33 PM MST] INFO StreamController Stopping stream bradford@69.169.136.242:54858 (VLC media player - version 0.9.8a Grishenko - (c) 1996-2008 the VideoLAN team)


The two lines that are fishy I've bolded. I'm not sure about the last one, which looks like is what kills.

When I try to transcode a h264 packed in mp4 container, all I get is the following:

[2/4/09 10:43:46 PM MST] INFO PlaylistInputStream Opening new song d:\documents\Videos\movies\Action Adventure\Chain Reaction.mp4
[2/4/09 10:43:46 PM MST] DEBUG TranscodeInputStream Starting transcoder: [d:\inetpub\wwwroot\subsonic\transcode\ffmpeg] [-re] [-y] [-i] [d:\documents\Videos\movies\Action Adventure\Chain Reaction.mp4] [-ar] [44100] [-f] [flv] [-]
[2/4/09 10:43:51 PM MST] INFO StreamController Stopping stream bradford@69.169.136.242:54867 (VLC media player - version 0.9.8a Grishenko - (c) 1996-2008 the VideoLAN team)


and windows reports ffmpeg.exe crashed. The first time it took a while for ffmpeg to crash, while subsequent crashes happened sooner and sooner after starting the transcode.

I'm going to try a different build of ffmpeg and also trying a full conversion (not streaming) to another file to see if that works.

Are you doing this on Windows of Linux?
User avatar
braddyo
 
Posts: 97
Joined: Mon Oct 29, 2007 10:27 pm
Location: UT

Postby BrianDelShasta » Thu Feb 05, 2009 6:04 am

It appears ffmpeg is having trouble transcoding the audio?

I'm using Windows 2003 sp2 with tomcat. I can send you my version of ffmpeg if you like.

Also for what it's worth, simply adding a single pixel (20 to 21) to the height of the flash player enables the video stream while still keeping the flash player small. You can barely notice, but of course when you hit full screen you can watch video.
BrianDelShasta
 
Posts: 116
Joined: Tue Jun 03, 2008 4:45 am
Location: USA

Postby BrianDelShasta » Sun Feb 08, 2009 7:24 pm

Correction, you do not need to change the height at all. Leave it at 20. I would also add an additional flashvar to disable auto-stretching of 4:3 formats on widescreen:

Code: Select all
stretching:"none"


I'm still working on fixing the seek problem...
BrianDelShasta
 
Posts: 116
Joined: Tue Jun 03, 2008 4:45 am
Location: USA

reply

Postby liveman » Sun Feb 08, 2009 9:24 pm

Hi, would you be able to provide instructions on how I can either play .flv or .mp4 files or both please?

would be much appreciated, I am a bit of a newb with this ;)
liveman
 
Posts: 2
Joined: Sun Feb 08, 2009 9:22 pm

Re: reply

Postby braddyo » Sun Feb 08, 2009 9:43 pm

liveman wrote:Hi, would you be able to provide instructions on how I can either play .flv or .mp4 files or both please?

would be much appreciated, I am a bit of a newb with this ;)


We're still trying to work this out. You should be able to simply play flv files in the JWplayer, but as it is, you can only see the video if you make it full screen. Also, you probably can't see flv files, so you have to add that file type to the general settings of Subsonic.

Hopefully soon we can get any video files working in JWPlayer, however at this point it's not working perfectly.
User avatar
braddyo
 
Posts: 97
Joined: Mon Oct 29, 2007 10:27 pm
Location: UT

reply

Postby liveman » Mon Feb 09, 2009 11:58 am

Yh, I have tried streaming .flv files and the sound will play but the cideo won't. Even in fullscreen mode? Do I have to set up transcoding for this?

How do I go about enabling the video of an .flv file?

PS- Thanks for your previous fast response.
liveman
 
Posts: 2
Joined: Sun Feb 08, 2009 9:22 pm

Postby ubuntu_user » Tue Feb 10, 2009 12:50 pm

Have any of you tried to stream videos +2gb to vlc without transcoding. The stream seems to start in the status window, but nothing to be streamed, though its reading from the file. It keeps reading from the file untill apache and java is killed. If you let it stream, then it keeps sending data above the filesize, and it seems it would continue untill its killed.

Before the fix from sindre with the above +2gb, the stream seems to start, but would only play 10 minutes. This was about the same as if you tried to download the file, and only got about 300 mb. Now you can download the file as the right filesize though.

Have anyone tried the same ?

ubuntu 8.10
apache
tomcat
ubuntu_user
 
Posts: 7
Joined: Thu Jan 22, 2009 9:42 pm

Postby braddyo » Mon Feb 23, 2009 7:02 am

ubuntu_user, I have the same problem on IIS 7 and windows Vista.
User avatar
braddyo
 
Posts: 97
Joined: Mon Oct 29, 2007 10:27 pm
Location: UT

Next

Return to Help

Who is online

Users browsing this forum: No registered users and 5 guests