[FFmpeg-user] Transcoding for the Roku with recent ffmpeg

Roku Coder mattkazee at hotmail.com
Mon May 27 10:29:40 CEST 2013


Yan Seiner <yan <at> seiner.com> writes:

> 
> I'm having trouble transcoding into h264 with recent (1.0) ffmpeg.
> 
> Older versions (0.8?) did fine using this command line:
> 
> ffmpeg -i input.vob -acodec libfaac -ab 128k -vcodec libx264 -vpre 
> normal -s 854x480 -crf 22 -threads 0 -f mp4 output.mp4
> 
> the newer versions fail with:
> 
> Undefined constant or missing '(' in 'wpred'
> [NULL  <at>  0x177ca80] Unable to parse option value 
> "wpred+dct8x8+fastpskip+mbtree"
> [NULL  <at>  0x177ca80] Error setting option flags2 to value 
> +wpred+dct8x8+fastpskip+mbtree.
> 
> Based on the little bit of research I did, I should replace -vpre normal 
> with something like
> 
> -vcodec libx264 -c:v libx264 -preset fast -profile:v baseline
> 
> which results in this command line:
> 
> ffmpeg -i input.vob -acodec libfaac -ab 128k -vcodec libx264 -c:v 
> libx264 -preset fast -profile:v baseline -s 854x480 -crf 22 -threads 0 
> -f mp4 output.mp4
> 
> the video transcodes fine, but will not play on the Roku.  It plays 
> about 30 seconds, then stops and the Roku starts buffering 
> indefinitely.  It also shows lower quality connection, and my apache 
> logs fill up with:
> 
> (104)Connection reset by peer: core_output_filter: writing data to the 
> network
> 
> Indicating that the Roku is resetting the connection.
> 
> Anyone transcoding for the Roku?  Any suggestions?
> 

The Roku preset provided with the Roku 4.1 SDK is old and outdated. They
really need to update the SDK Encoding Guide with better examples.  Make a
new ffpreset libx264-roku.ffpreset with this:

coder=1
flags=+loop
cmp=chroma
partitions=+parti8x8+parti4x4+partp8x8+partb8x8
me_method=umh
subq=8
me_range=16
g=250
keyint_min=25
sc_threshold=40
i_qfactor=0.71
b_strategy=2
qcomp=0.6
qmin=10
qmax=51
qdiff=4
bf=4
refs=4
direct-pred=3
trellis=1
8x8dct=1
fast-pskip=1
mixed-refs=1



then save that preset here /usr/local/share/ffmpeg/  or to your local ffmpeg
preset folder.

Technically Roku can play video in other resolutions other than 480p 720p or
1080p but it doesn't like it.  I would recommend using 720x480 instead of
854x480.  Roku 1 doesn't like the new ffmpeg however it works fine for Roku
2 and Roku 3.  It will still work on roku 1 but not as good.

Try the encode with the latest version of ffmpeg and use the preset above
like this for 16x9 vob files

ffmpeg -i input.vob -f mp4 -aspect 16:9 -vf yadif=0:1 -vcodec libx264
-bufsize 2000k -profile:v high -level 4.0 -s 720x480 -vb 1000k -acodec
libfaac -ab 128k -vpre roku -r 29.97  -adrift_threshold 0.01 -threads 0
output.mp4


for encoding avi,mpg,mp4 or mov files to roku you will need to remove the
'-vf yadif=0:1'

2 pass looks better for lower bit rates.

For variant stream playback using Apple ios HLS you would need to encode
using the same preset like this   

ffmpeg -i input.vob -f mpegts -aspect 16:9 -vf yadif=0:1 -vcodec libx264
-bufsize 2000k -profile:v high -level 4.0 -s 720x480 -vb 1000k -acodec
libfaac -ab 128k -vpre roku -r 29.97 -vbsf h264_mp4toannexb
-adrift_threshold 0.01  -threads 0 output.1.ts

This will work decently on Roku1 and perfectly on Roku2 and Roku3

Cheers!






More information about the ffmpeg-user mailing list