transcoding with ffmpeg + multi threaded + android

Got an idea? Missing something? Post your feature request here.

Moderator: moderators

transcoding with ffmpeg + multi threaded + android

Postby pdcrow » Tue Aug 23, 2011 7:48 pm

I've been trying to no avail to get ffmpeg to utilize both processors on my hp proliant server backend when streaming a video. apparently the default video codec for flv conversion isnt capable of multi core flv encoding. i've read that using h264 for the video and using flv as a container will allow hyperthreading because libx264 supports this. so i'm using ffmpeg from the multiverse so it has libx264 enabled and compiled into ffmpeg. however, whenever change the parameters in the transcode settings from subsonic, the flash player (jwplayer) says it cant find the file. this is what i'm currently using in the transcode box in subsonic:

ffmpeg -vcodec libx264 -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -

if i use:

ffmpeg -vcodec h264 -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -

it works. but still no hyperthreading. if i put the -threads 0 option into either of these it also fails. has anyone been able to successfully implement hyperthreading into their transcoding? my backend system is just a tad underpowered right now and cant transcode in realtime with just a single core.

I also have a request. My android phone is a bit old (sprint hero) and doesnt have flash player. I was wondering if it would be possible to transcode the files to .3gp format and/or have an html5 video player backup for the flash jwplayer??? anyone have any tips on getting this working?
pdcrow
 
Posts: 6
Joined: Fri Oct 08, 2010 4:23 pm

Re: transcoding with ffmpeg + multi threaded + android

Postby GJ51 » Wed Aug 24, 2011 6:09 am

ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -vcodec libx264 -preset fast -threads 0 -


ffmpeg -ss %o -i %s -async 30 -b %bk -r 23-.976 -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -vcodec libx264 -preset fast -threads 0 -
Gary J

http://bios-mods.com
http://www.maplegrovepartners.com
http://theaverageguy.tv/category/tagpodcasts/cyberfrontiers/
User avatar
GJ51
 
Posts: 3492
Joined: Wed Oct 20, 2010 11:58 pm
Location: Western New York

Re: transcoding with ffmpeg + multi threaded + android

Postby pdcrow » Wed Aug 24, 2011 3:10 pm

neither of those worked :(
pdcrow
 
Posts: 6
Joined: Fri Oct 08, 2010 4:23 pm

Re: transcoding with ffmpeg + multi threaded + android

Postby GJ51 » Wed Aug 24, 2011 3:12 pm

You'll need to update to a newer ffmpeg build.

ffmpeg - go to http://ffmpeg.zeranoe.com/builds/ and download the latest static build for your system. This site is for Windows builds. Check http://www.ffmpeg.org/download.html for other OS's. I just extracted the ffmpeg bin folder and replaced the files in C:\Subsonic\transcode
Gary J

http://bios-mods.com
http://www.maplegrovepartners.com
http://theaverageguy.tv/category/tagpodcasts/cyberfrontiers/
User avatar
GJ51
 
Posts: 3492
Joined: Wed Oct 20, 2010 11:58 pm
Location: Western New York

Re: transcoding with ffmpeg + multi threaded + android

Postby pdcrow » Wed Aug 24, 2011 3:57 pm

i'm on mythbuntu so i had the medibuntu repository enabled and have the latest build with mutlithreading and libx264 compiled in.

instead of -preset i used -vpre and it worked. now its using over 300% cpu when transcoding, although it still can't keep up with a high bitrate 720p movie in realtime. i'll have to look into this further... anyway here's what i'm using right now:

ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -vcodec libx264 -vpre fast -threads 8 -
pdcrow
 
Posts: 6
Joined: Fri Oct 08, 2010 4:23 pm

Re: transcoding with ffmpeg + multi threaded + android

Postby GJ51 » Wed Aug 24, 2011 4:12 pm

Transcoding video does take CPU power. I've been doing a lot of testing and found that my 2.83GHz quad core Xeon can handle anything until it hits a Blue Ray .m2ts file. I installed SS on my Core i7-950 desktop and was able to play the .m2ts smoothly. So there is no doubt that CPU power is a big factor and enabling the -threads 0 setting helps.

I'm also beginning to think that at higher resolution video there might be disk transfer speeds coming into play. I'll be testing for that next week as I'm putting a RAID 60 array on my server this weekend. That should be fast enough to take disk speed out of the equation for testing purposes. If my Xeon can play the .m2ts from the RAID array, then it'll be evident that is was the data transfer from the hard drive that was slowing things down, if the buffering is still there, then I'l know that it's the CPU that has reached its limit and just can't keep up with the .m2ts file.

One workaround I often use is to reformat any video into an mp4 and then turn off mp4 > flv transcoding. Jw Player will play mp4 natively so the limiting factor just becomes connection speed and the capability of the playback platform. I've reformated Blue Rays this way and they play well and you can have multiple streams without stressing the CPU.

http://maplegrovepartners.subsonic.org/share/peSZv
Gary J

http://bios-mods.com
http://www.maplegrovepartners.com
http://theaverageguy.tv/category/tagpodcasts/cyberfrontiers/
User avatar
GJ51
 
Posts: 3492
Joined: Wed Oct 20, 2010 11:58 pm
Location: Western New York

Re: transcoding with ffmpeg + multi threaded + android

Postby pdcrow » Wed Aug 24, 2011 6:20 pm

hm... good point with the mp4 idea. i'll have to try that.

i did some testing and can successfully convert a 720p movie to flv using the "-vpre superfast" option, but only if i set the "-s" option to something like 320x240. is there a way i can divide the resolution in half in the transcode command??? i tried this:

ffmpeg -ss %o -i %s -async 1 -b %bk -s (%w/2)x(%h/2) -ar 44100 -ac 2 -v 0 -f flv -vcodec libx264 -vpre superfast -threads 0 -

but it gave me an error :(
pdcrow
 
Posts: 6
Joined: Fri Oct 08, 2010 4:23 pm

Re: transcoding with ffmpeg + multi threaded + android

Postby r45k » Wed Aug 24, 2011 8:28 pm

Be careful with the mp4 container. AFAIK the markers for the mp4 container are at the end of the file so you won't be able to stream it until the entire video has been transcoded (though i should probably use the word encoded in this case)
r45k
 
Posts: 9
Joined: Fri Mar 25, 2011 2:11 pm

Re: transcoding with ffmpeg + multi threaded + android

Postby GJ51 » Wed Aug 24, 2011 8:41 pm

It's not always the case, it depends on the source video and the converter used. There is also a utility out there that will address the problem that has been mentioned somewhere here, but I don't remeber where - it's been a while since it was discussed.
Gary J

http://bios-mods.com
http://www.maplegrovepartners.com
http://theaverageguy.tv/category/tagpodcasts/cyberfrontiers/
User avatar
GJ51
 
Posts: 3492
Joined: Wed Oct 20, 2010 11:58 pm
Location: Western New York

Re: transcoding with ffmpeg + multi threaded + android

Postby pdcrow » Thu Aug 25, 2011 3:01 pm

well i decided to suck it up and use my core2duo computer as my backend and server instead of my super old proliant.

it converts in realtime now using multiple cores, however it still would be nice to have (in addition to the time and bitrate dropdowns) a resolution change dropdown so if i'm viewing this on my android, the computer doenst have to encode a full 720 or even 1080 stream... only a stream thats half or a third of the resolution.

maybe i should just dust off my java skills and see if i can do this myself :)
pdcrow
 
Posts: 6
Joined: Fri Oct 08, 2010 4:23 pm

Re: transcoding with ffmpeg + multi threaded + android

Postby jicama » Tue Sep 20, 2011 4:07 pm

I'd also add -vprofile baseline for streaming h.264 to android. I changed my video transoding settings by adding -vcodec libx264 -vprofile baseline -threads 0 and am happy with the results.
jicama
 
Posts: 1
Joined: Tue Sep 20, 2011 3:59 pm

Re: transcoding with ffmpeg + multi threaded + android

Postby fventura03 » Tue Sep 20, 2011 6:09 pm

I upgraded my server from Core2Duo 2.4ghz to an AMD Phenom II Quad Core @ 3.2ghz because it wasn't cutting it. After the upgrade, I've been able to stream anything I've thrown at it.

It is using 4 cores, and I got instructions on here from another thread on how to do it, I've created a batch file with these contents:

----
@echo off
setlocal

REM 1-start, 2-file, 3-bitrate, 4-width, 5-height
cd c:\subsonic\transcode
ffmpeg.exe -ss %1 -i %2 -async 1 -b %3k -s %4x%5 -ar 44100 -ac 2 -v 0 -threads 0 -vcodec libx264 -fpre .\presets\libx264-veryfast.ffpreset -f flv -
----

The only problem I've run is with HUGE files like 14-15gb, I have to pause the video for about 3 minutes to let the transcoding go a little ahead of the video. I'll be going in and editing these files with something a little bit better, about 4-5gb, I've found it to play perfect and I get REALLY good quality video from the browser, maybe better then HULU.

Image
fventura03
 
Posts: 12
Joined: Tue Sep 20, 2011 12:22 pm


Return to Feature Requests

Who is online

Users browsing this forum: No registered users and 6 guests