I have just done some testing with my Xbox 360 and the current profile is needlessly transcoding H.264 video to WMV, when it is in fact supported.
I think it's worthwhile getting this right given how inexpensive these consoles are, and how large the user base is too. Serviio could easily become the most popular media server for console users.
Most files people will want to stream will be H.264, and we can't remux that to ASF apparently. We therefore need to remux to MP4 - the only other container the Xbox 360 will support for HD content. The problem is that Serviio will not allow transcoding to an MP4 container, even though FFmpeg can do it. The service fails to start and the log reads:
ERROR [XmlUtils] XML Profiles.xsd didn't pass validation, reason: cvc-enumeration-valid: Value 'mp4' is not facet-valid with respect to enumeration '[asf, mpegvideo, mpeg, mpegts]'. It must be a value from the enumeration.Can this be added?
The audio is the next issue because the 360 will not play multichannel audio (except WMA9 Pro). We need to transcode to AAC Low Complexity, as stated in
Microsoft's official specs.
The snag here is that the FFmpeg project withdrew
libfaac from the static builds because its licence is not GPL. This means it cannot be included with Serviio unfortunately, though it can be compiled to link to an external libfaac library which Xbox owning Serviio users would need to download separately. Reading around it seems to be pretty hard to compile FFmpeg on Windows and the older builds which still include it seem to have issues with transcoding mkv files. Fortunately thanks to
this page I discovered that the
recent SVN FFmpeg binary from here includes the external libfaac support:
http://sourceforge.net/projects/mplayer-win32/files/The libfaac library can be downloaded
here and placed in the same folder as FFmpeg.
Testing transcoding on a sample mkv file yielded an MP4 that was perfectly playable on the 360 from a USB stick. I then went on to test a 1080p m2ts H.264 file, also fine, and I served them both from Serviio. Playback was perfect. This was the command line:
C:\Temp\FFmpeg-svn-25456>ffmpeg.exe -i "g:\video\HD Movies\district9-720p.mkv
-vcodec copy -acodec libfaac -ab 320k -ac 2 -profile aac_low g:\d9test.mp4
FFmpeg version SVN-r25456-Sherpya, Copyright (c) 2000-2010 the FFmpeg developers
built on Oct 14 2010 16:46:15 with gcc 4.2.5 20090330 (prerelease) [Sherpya]
libavutil 50.32. 3 / 50.32. 3
libavcore 0. 9. 1 / 0. 9. 1
libavcodec 52.92. 0 / 52.92. 0
libavformat 52.81. 0 / 52.81. 0
libavdevice 52. 2. 2 / 52. 2. 2
libavfilter 1.51. 1 / 1.51. 1
libswscale 0.12. 0 / 0.12. 0
libpostproc 51. 2. 0 / 51. 2. 0
[matroska,webm @ 002cbe50] max_analyze_duration reached
[matroska,webm @ 002cbe50] Estimating duration from bitrate, this may be inaccur
ate
Seems stream 0 codec frame rate differs from container frame rate: 47.95 (200000
00/417083) -> 23.98 (24000/1001)
Input #0, matroska,webm, from 'g:\video\HD Movies\district9-720p.mkv':
Duration: 01:52:15.72, start: 0.000000, bitrate: 1536 kb/s
Stream #0.0(eng): Video: h264, yuv420p, 1280x688, PAR 1:1 DAR 80:43, 23.98 f
ps, 23.98 tbr, 1k tbn, 47.95 tbc
Stream #0.1(eng): Audio: dca, 48000 Hz, 5.1, s16, 1536 kb/s
Stream #0.2(eng): Subtitle: [0][0][0][0] / 0x0000
Output #0, ipod, to 'g:\d9test.mp4':
Metadata:
encoder : Lavf52.81.0
Stream #0.0(eng): Video: libx264, yuv420p, 1280x688 [PAR 1:1 DAR 80:43], q=2
-31, 10000k tbn, 23.98 tbc
Stream #0.1(eng): Audio: libfaac, 48000 Hz, 2 channels, s16, 320 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
frame= 2428 fps= 93 q=-1.0 size= 59137kB time=101.18 bitrate=4787.8kbits/s
frame= 2471 fps= 93 q=-1.0 size= 60405kB time=102.98 bitrate=4805.3kbits/s
frame= 2519 fps= 93 q=-1.0 size= 62533kB time=104.98 bitrate=4879.7kbits/s
frame= 2558 fps= 93 q=-1.0 size= 64748kB time=106.61 bitrate=4975.5kbits/s
frame= 2600 fps= 92 q=-1.0 size= 66120kB time=108.36 bitrate=4998.7kbits/s
...So really the desired transcoding config would look something like below, but it would need a new aCodec setting (aac-lc?). We also need to transcode MP4 files with vCodec="h264" but which have multichannel aac audio. How would we match that?
- Code:
<Transcoding>
<!--
http://blogs.msdn.com/xboxteam/archive/2007/11/30/december-2007-video-playback-faq.aspx
-->
<Video targetContainer="mp4" targetACodec="aac-lc">
<Matches container="matroska" vCodec="h264" />
<Matches container="mpegts" vCodec="h264" />
<Matches container="avi" vCodec="h264" />
</Video>
<Video targetContainer="asf" targetVCodec="wmv2" targetACodec="wmav2" maxVBitrate="15360">
<Matches container="mpeg" />
<Matches container="mpegvideo" />
<Matches container="avi" vCodec="msmpeg4" />
</Video>
</Transcoding>