Flash Client

flv
I am trying to create a website so I can view my Plex Library on my Nintendo Wii. I have got it kind of working, but have an issue with some of the hardcoded parameters that are set in the Plex Media Server.exe on Windows(not sure if all platforms hardcode this) There are 2 issue I ran into for transcoding the content to flv: -threads 0 , and -ar 48000 seem to be hardcoded. I hex edited the Plex Media Server.exe to return -threads 1 and -ar 44100 and then the follow code would allow me to watch a hardcoded video title on my wii(worked on my samsung note also)


<br />
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><br />
<head><br />
<title>Plex Video Player</title><br />
<style type="text/css"><br />
body{<br />
        margin:0;<br />
        padding:0;<br />
        background-color: #000000;<br />
        }<br />
</style><br />
</head><br />
<body><br />
<br />
<script type="text/javascript" src="base64.js"></script><br />
<script type="text/javascript" src="jssha256.js"></script><br />
<br />
<script type="text/javascript"><br />
<br />
publicKey = "KQMIY6GATPC63AIMC4R2";<br />
privateKey = decode64("k3U6GLkZOoNIoSgjDshPErvqMIFdE0xMTx8kgsrhnC0=");<br />
<br />
//from Plex Media Server<br />
part = encodeURIComponent('/library/parts/12083/file.avi');<br />
<br />
add= "http://192.168.2.12:32400";<br />
<br />
myurl = "/video/:/transcode/generic.flv?format=flv&videoCodec=flv&videoBitrate=1000&audioCodec=libmp3lame&audioBitrate=128&size=624x336"<br />
myurl = myurl + "&fakeContentLength=2000000000&url=http%3A%2F%2F192.168.2.12%3A32400" + part + "&3g=0&httpCookies=&userAgent=";<br />
<br />
time = Math.round(new Date().getTime() / 1000);<br />
<br />
msg = myurl+"@"+time;<br />
<br />
redirectURL = encodeURIComponent(msg);<br />
<br />
HMAC_SHA256_init(privateKey);<br />
HMAC_SHA256_write(msg);<br />
mac = HMAC_SHA256_finalize();<br />
msg = encode64(array_to_string(mac));<br />
<br />
URL=add+redirectURL+encodeURIComponent("&X-Plex-Access-Key="+publicKey+"&X-Plex-Access-Code="+array_to_string(mac))+encodeURIComponent("&X-Plex-Access-Time="+time);<br />
<br />
document.write("<table cellpadding='0' cellspacing='0' height='100%' width='100%' style='text-align:center;'><tr><td>");<br />
document.write("<embed src='http://192.168.2.12/videoplayer.swf?streamUrl="); //from http://mycast.orb.com/orb/resources/common/videoplayer.swf<br />
document.write(URL);<br />
document.write(" quality='best' scale='noborder' width='100%' height='100%' name='videoplayer' align='middle' allowScriptAccess='sameDomain' ");<br />
document.write(" type='application/x-shockwave-flash' flashvars='file=");<br />
document.write(URL);<br />
document.write("' allowFullScreen='true' pluginspage='https://www.macromedia.com/go/getflashplayer' /></object></td></tr></table>");<br />
<br />
<br />
</script><br />
<br />
</body><br />
</html><br />




Is there a way to pass the audiorate and threads , so I won't have to hex edit the Plex Media Server.exe? Also i had to pass the -vcodec flv or it wouldn't work because otherwise it would pass -vcodec "" to the PlexTranscoder.exe and fail.

Thanks,
Troy

Ok figured out the audio parameter it is audioSamples=22050, still have the problem with the hardcoded -threads 0, which seems to be a limitation in the flv video codec not supporting threads(says “automatic thread number detection not supported by codec, patch welcome”)



<br />
c:\Program Files\Plex\Plex Media Server>PlexTranscoder.exe -i http://192.168.2.12:32400/library/parts/12083/file.avi -async 1 -f flv -vcodec flv -b 1000k -acodec libmp3lame -ar 22050 -ab 128k -ac 2 -s 624x336 -threads 0 -re -rebuf 10 -<br />
<br />
ffmpeg version git-2012-05-15-859b6e3, Copyright (c) 2000-2011 the FFmpeg developers<br />
  built on May 14 2012 23:35:41 with gcc 4.5.2<br />
  configuration: --enable-memalign-hack --enable-encoders --enable-muxers --enable-encoder=libx264 --enable-muxer=mpegts --enable-libx264 --enable-gpl --disable-libfaac --enable-version3 --enable-libvo-aacenc --extra-ldflags='-Llib/windows/win32 -lws2_32' --extra-libs='lib/windows/win32/libcurldll.a lib/windows/win32/libeay32.a lib/windows/win32/libssl32.a lib/windows/win32/libx264.a lib/windows/win32/libfaac.a lib/windows/win32/libass.a lib/windows/win32/freetype.a lib/windows/win32/libfribidi.a lib/windows/win32/libfribidi-char-sets.a lib/windows/win32/libfontconfig.a lib/windows/win32/libiconv.a lib/windows/win32/libexpat.a lib/windows/win32/libmp3lame.a lib/windows/win32/libxml2.a -lwsock32' --extra-cflags='-Iinclude/windows/win32 -DWINDOWS -falign-loops=16 -ffast-math -mfpmath=sse -msse' --enable-pthreads --disable-debug --disable-bzlib --arch=i386 --disable-protocol=rtp --enable-muxer=mp4 --enable-avfilter --disable-muxer=image2 --disable-muxer=image2pipe --disable-shared --disable-ffplay --disable-ffserver --enable-libmp3lame<br />
  libavutil    51. 11. 1 / 51. 11. 1<br />
  libavcodec   53.  9. 0 / 53.  9. 0<br />
  libavformat  53.  6. 0 / 53.  6. 0<br />
  libavdevice  53.  2. 0 / 53.  2. 0<br />
  libavfilter   2. 27. 5 /  2. 27. 5<br />
  libswscale    2.  0. 0 /  2.  0. 0<br />
  libpostproc  51.  2. 0 / 51.  2. 0<br />
Input #0, avi, from 'http://192.168.2.12:32400/library/parts/12083/file.avi':<br />
Input #0, avi, from 'http://192.168.2.12:32400/library/parts/12083/file.avi':<br />
  Metadata:<br />
    encoder         : VirtualDubMod 1.5.10.1 (build 2366/release)<br />
  Duration: 02:30:37.96, start: 0.000000, bitrate: 781 kb/s<br />
    Stream #0.0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 672x272 [SAR 1:1 DAR 42:17], 25 tbr, 25 tbn, 25 tbc (codecdata: 41 bytes)<br />
    Stream #0.0, 1, 1/25: Video: mpeg4 (Advanced Simple Profile), yuv420p, 672x272 [SAR 1:1 DAR 42:17]<br />
    Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 112 kb/s (codecdata: 12 bytes)<br />
    Stream #0.1, 21, 3/125: Audio: mp3, 48000 Hz, stereo, s16, 112 kb/s<br />
Average FPS ~ 0 fps, Frame rate ~ 25 fps.<br />
[buffer @ 02c97aa0] w:672 h:272 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param:<br />
[scale @ 02c918a0] w:672 h:272 fmt:yuv420p -> w:624 h:252 fmt:yuv420p flags:0x4<br />
[flv @ 02c99780] automatic thread number detection not supported by codec, patch welcome<br />
Output #0, flv, to 'pipe:':<br />
Output #0, flv, to 'pipe:':<br />
    Stream #0.0: Video: flv, yuv420p, 624x252 [SAR 1:1 DAR 52:21], q=2-31, 1000 kb/s, 90k tbn, 25 tbc (codecdata: 0 bytes)<br />
    Stream #0.0, 0, 1/90000: Video: flv, yuv420p, 624x252 [SAR 1:1 DAR 52:21], q=2-31, 1000 kb/s<br />
    Stream #0.1: Audio: libmp3lame, 22050 Hz, 2 channels, s16, 64 kb/s (codecdata: 0 bytes)<br />
    Stream #0.1, 0, 1/90000: Audio: libmp3lame, 22050 Hz, 2 channels, s16, 64 kb/s<br />
Stream mapping:<br />
  Stream #0.0 -> #0.0<br />
  Stream #0.1 -> #0.1<br />
Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height<br />




but it works fine with -threads 1

<br />
c:\Program Files\Plex\Plex Media Server>PlexTranscoder.exe -i http://192.168.2.12:32400/library/parts/12083/file.avi -async 1 -f flv -vcodec flv -b 1000k -acodec libmp3lame -ar 22050 -ab 128k -ac 2 -s 624x336 -threads 1 -re -rebuf 10 -<br />
<br />
ffmpeg version git-2012-05-15-859b6e3, Copyright (c) 2000-2011 the FFmpeg developers<br />
  built on May 14 2012 23:35:41 with gcc 4.5.2<br />
  configuration: --enable-memalign-hack --enable-encoders --enable-muxers --enable-encoder=libx264 --enable-muxer=mpegts --enable-libx264 --enable-gpl --disable-libfaac --enable-version3 --enable-libvo-aacenc --extra-ldflags='-Llib/windows/win32 -lws2_32' --extra-libs='lib/windows/win32/libcurldll.a lib/windows/win32/libeay32.a lib/windows/win32/libssl32.a lib/windows/win32/libx264.a lib/windows/win32/libfaac.a lib/windows/win32/libass.a lib/windows/win32/freetype.a lib/windows/win32/libfribidi.a lib/windows/win32/libfribidi-char-sets.a lib/windows/win32/libfontconfig.a lib/windows/win32/libiconv.a lib/windows/win32/libexpat.a lib/windows/win32/libmp3lame.a lib/windows/win32/libxml2.a -lwsock32' --extra-cflags='-Iinclude/windows/win32 -DWINDOWS -falign-loops=16 -ffast-math -mfpmath=sse -msse' --enable-pthreads --disable-debug --disable-bzlib --arch=i386 --disable-protocol=rtp --enable-muxer=mp4 --enable-avfilter --disable-muxer=image2 --disable-muxer=image2pipe --disable-shared --disable-ffplay --disable-ffserver --enable-libmp3lame<br />
  libavutil    51. 11. 1 / 51. 11. 1<br />
  libavcodec   53.  9. 0 / 53.  9. 0<br />
  libavformat  53.  6. 0 / 53.  6. 0<br />
  libavdevice  53.  2. 0 / 53.  2. 0<br />
  libavfilter   2. 27. 5 /  2. 27. 5<br />
  libswscale    2.  0. 0 /  2.  0. 0<br />
  libpostproc  51.  2. 0 / 51.  2. 0<br />
Input #0, avi, from 'http://192.168.2.12:32400/library/parts/12083/file.avi':<br />
Input #0, avi, from 'http://192.168.2.12:32400/library/parts/12083/file.avi':<br />
  Metadata:<br />
    encoder         : VirtualDubMod 1.5.10.1 (build 2366/release)<br />
  Duration: 02:30:37.96, start: 0.000000, bitrate: 781 kb/s<br />
    Stream #0.0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 672x272 [SAR 1:1 DAR 42:17], 25 tbr, 25 tbn, 25 tbc (codecdata: 41 bytes)<br />
    Stream #0.0, 1, 1/25: Video: mpeg4 (Advanced Simple Profile), yuv420p, 672x272 [SAR 1:1 DAR 42:17]<br />
    Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 112 kb/s (codecdata: 12 bytes)<br />
    Stream #0.1, 21, 3/125: Audio: mp3, 48000 Hz, stereo, s16, 112 kb/s<br />
Average FPS ~ 0 fps, Frame rate ~ 25 fps.<br />
[buffer @ 032d7aa0] w:672 h:272 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param:<br />
[scale @ 032d18a0] w:672 h:272 fmt:yuv420p -> w:624 h:252 fmt:yuv420p flags:0x4<br />
Output #0, flv, to 'pipe:':<br />
Output #0, flv, to 'pipe:':<br />
  Metadata:<br />
    plex.total_duration: 9037.96<br />
    plex.duration   : 9037.96<br />
    encoder         : Lavf53.6.0<br />
    Stream #0.0: Video: flv, yuv420p, 624x252 [SAR 1:1 DAR 52:21], q=2-31, 1000 kb/s, 1k tbn, 25 tbc (codecdata: 0 bytes)<br />
    Stream #0.0, 0, 1/1000: Video: flv, yuv420p, 624x252 [SAR 1:1 DAR 52:21], q=2-31, 1000 kb/s<br />
    Stream #0.1: Audio: libmp3lame, 22050 Hz, 2 channels, s16, 128 kb/s (codecdata: 0 bytes)<br />
    Stream #0.1, 0, 1/1000: Audio: libmp3lame, 22050 Hz, 2 channels, s16, 128 kb/s<br />
Stream mapping:<br />
  Stream #0.0 -> #0.0<br />
  Stream #0.1 -> #0.1<br />
Closing down stderr.<br />




I am very much interested in this… If you need any help testing anything let me know…

I sent you a PM, would be happy to help you get it working :slight_smile:


Hi,
I am also looking into this. I am trying to extend the nodejs server to support the ps3 as the ps3 does not support m3u8.This may also be a solution to the original posters problem. It seems that video-embedded-h264,ffpreset is overwritten with default values when plex is restarted. Im using -acodec libvo_aacenc in a testing shell script and this is working when threads=1 is used. Any help/assistance/pointers would be apreciated


r 8-)


Elan,
I know this is beta ( alpha even) but any progress on this ?

R 8-)


Try videoCodec=libx264 and it will work!!!!!!!!!!


8-)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.