Page 1 of 3

Xbox 360 not transcoding .avi files

PostPosted: Wed Jun 19, 2013 10:56 pm
by Snoogins
I'm having a problem with certain .avi files not being transcoded when they need to be. The Xbox does support some .avi files natively but not others and Serviio doesn't seem to be able to distinguish between the two so doesn't try to transcode any .avi files.

When I play the files on my laptop they're fine but when they stream they're not being transcoded (I can tell because it lets me skip forward). It plays for a couple of seconds perfectly and then the sound gets quiet and choppy. Almost like it's stopping and starting for a fraction of a second at a time. When Serviio does force transcoding (ie. .mkv files) it works flawlessly regardless of file size/quality so I don't think it's caused by my hardware not being up to scratch. It only occurs on .avi files.

I know this is probably a problem with the way Xbox only plays certain types of .avi files but is there a way to set serviio up so that it will only attempt to play the ones that do work and transcode the rest?

Sorry if I wasn't clear but it's an odd problem to try to describe!

Re: Xbox 360 not transcoding .avi files

PostPosted: Thu Jun 20, 2013 10:29 am
by zip
I doubt there is a (easy) way to distinguish a good an bad avi for transcoding. I'd say the file is not correctly encoded, or not the way the xbox likes. Obviously it's a supported ormat (as it starts playing), but corrupted somehow. Get another copy or rip it again.

Re: Xbox 360 not transcoding .avi files

PostPosted: Thu Jun 20, 2013 1:36 pm
by DenyAll
One method I have had success with is to simply repackage the AVI. Run the command:

    "C:\Program Files\Serviio\lib\ffmpeg.exe" -i "srcfile.avi" -vcodec copy -acodec copy "test.avi"
changing scrcfile.avi for your file name. You may also have to adjust the command for wherever your ffmpeg.exe file is located. Include quotes as shown. When running the command note any errors or warnings (usually show in red or yellow).

This will produce a new file test.avi for you to test.

Re: Xbox 360 not transcoding .avi files

PostPosted: Thu Jun 20, 2013 7:53 pm
by Snoogins
Thanks guys. The problem I'm having isn't with just a couple of files though so any reconverting etc. isn't really practical.

The problem with the Xbox is that it will play any .avi files that have been converted using divx/xvid as long as the audio is AC3. Files with AAC audio don't play properly.

Is there a way to set up a renderer profile that can tell the difference? And then transcode when it is AAC?

I absolutely love this media server so far (all my files are renamed using themoviedb through filebot so the metadata is spot on), it's also the only one I've found that actually sends the dvd covers over to the Xbox. It's brilliant to be able to scroll through covers like on netflix rather than just filenames. PMS, Tversity and Plex don't do that. PMS does manage to play the problem .avi's but it transcodes them as it goes. I don't want to have to flick back and forth between the two for different files so hopefully there's be a way to do this through a renderer profile

Re: Xbox 360 not transcoding .avi files

PostPosted: Fri Jun 21, 2013 2:01 am
by DenyAll
Snoogins wrote:Is there a way to set up a renderer profile that can tell the difference? And then transcode when it is AAC?
Should be able to easily ('tis the true strength of Serviio imho). Try inserting this into the standard XBox 360 profile (edit profiles.xml file):
  Code:
<Matches container="*" aCodec="aac" />
above the existing line
<Matches container="avi" vCodec="h264" />
This should work (and will also pick up any other types with AAC audio). Remember to restart your PC after editing profiles.xml. If this doesn't work (I don't have an XBox to test) post a MediaInfo view of the file (see viewtopic.php?f=5&t=4510).

Re: Xbox 360 not transcoding .avi files

PostPosted: Fri Jun 21, 2013 11:17 am
by zip
More like

  Code:
<Matches container="avi" aCodec="aac" />


to only target AVIs

Re: Xbox 360 not transcoding .avi files

PostPosted: Sat Jun 22, 2013 9:30 am
by Snoogins
Thanks Guys. That seems to have solved the problem I had with aac :)

I still have some problem .avi's left however, I ran them all through g-spot to see what they all had in common. They all have the same audio codec listed as "0x0055 MPEG-1 Layer 3" I thought the Xbox probably didn't like that one either but I tested these one a different media server and they played ok without encoding.

I'm guessing the easiest thing to do is to add another line to force that codec to transcode as well. I'm not sure which part of 0x0055 MPEG-1 Layer 3 is the codec name I'd add to the command. Where it says "aCodec=aac" on the last one, would I change it to "aCodec=0x0055", or just use the mpeg-1?...or the entire thing? Sorry if it's a dumb question, I did google it first hoping for an easy answer!

I'm not great at this but thanks so much for helping me out guys

Re: Xbox 360 not transcoding .avi files

PostPosted: Mon Jun 24, 2013 12:58 pm
by zip
it's mp3

Re: Xbox 360 not transcoding .avi files

PostPosted: Tue Jun 25, 2013 9:04 pm
by Snoogins
It appears that the problem was with .avi containers with mp3 audio after all. After adding that to the code it fixed all of my files. Normal .avi files still play just fine and allow me to skip and all of the problem .avi's with .mp3 audio transcode automatically.

Thank you so much for your help with this! I really appreciate it. You guys made it easy for a novice like me to actually sort this out

It might be worth changing the xbox profile on the next update to automatically encode .avi's with .mp3 audio. I don't think it's just my xbox since it was happening on both machines I have.

Thanks again everyone who helped :)

Re: Xbox 360 not transcoding .avi files

PostPosted: Tue Jun 25, 2013 11:50 pm
by DenyAll
From what I read on the web, the Xbox should support AVI with MP3 (one resource: http://support.xbox.com/en-US/xbox-360/ ... vds-movies), so may need further testing and confirmation from other Xbox users before changing the standard profile.

Re: Xbox 360 not transcoding .avi files

PostPosted: Mon Aug 19, 2013 12:56 pm
by allenlook
What's most annoying is finding out a file won't play when it's in the middle of a series, and having to "fix" it late at night. When a file is "broken" it almost always plays on the PC, but the XBox throws an error. A simple run through VirtualDub or HandBrake will always fix it, but that takes 15 minutes or more.

Is there any way to scan a series of folders and list the files that *won't* play on the XBox 360? Maybe with something like the program AVICodec?

I'm going to try the command listed above next time (thank you for that), and I'll probably use PSExec to run it on the server remotely so I don't have to copy the file to my laptop, run it through VDub/HandBrake, copy it back, etc.

Thanks for a great program!

Re: Xbox 360 not transcoding .avi files

PostPosted: Tue Aug 20, 2013 12:22 am
by DenyAll
After re-reading this topic I am 95% convinced the problem the OP and you are experiencing is to do with "the non-zero wBitsPerSample problem" - search for "wBitsPerSample" on the forum. This issue resulted from how AVI's were encoded for a period - was fixed in later encoders.

For me this issue shows up as: the file will play perfectly well on my PC or PS3. On the Panasonic the file will freeze shortly after playing, rewind and FF will not be available. Whether it plays comes down to some devices requiring stricter conformance to the MP3 standard than others.

How to detect these AVI's?? - VirtualDub will report it apparently, ffmpeg will detect it but only when copying the streams (you will see a message about sample size from memory). It only affects AVI files, and only those with MP3 audio. Best way is simply to watch them on your device and make a list, but I also use Windows Explorer (My Computer, detailed view) and show a column for "bit rate" (right click columns, select More and find the bit rate). If the bit rate reports as 128 kbps, then it likely affected (not guaranteed, and the fixed files show the same bit rate... but it is an indication). Another indication I have found is if (using MediaInfo) the file was encoded using the writing application Transcode 1.3.x.x to 1.5.x.x. then it's also a likely suspect (once again, not guaranteed).

This problem is easily fixed by repacking the AVI as per my original post above. Snoogins didn't want to try it since he had so many, but since then I have written the following batch file to fix all files in a folder (I normally drag all suspect files into one folder and then run it). Note it has no effect on files that are not "damaged" other than it makes a copy of them. To use (Windows only, sorry) - copy this code to a batch file called "vFix.bat" or something like that, put it in the same folder as affected files. You may need to change the location of ffmpeg (the line with "C:\Program Files\Serviio\lib\ffmpeg.exe") to suit your install.

Run the batch file and sit back and watch - if you want, look for bright yellow/blue warning messages (sorry, can't remember what they say, and I've fixed all my files) - it indicates the problem was found. Old files are retained with the extension "old". You will notice affected files have a few bytes different between the old and new files, unaffected files should have the same file size.

  Code:
@echo off
REM Remux all AVI in current folder, video and audio copied

FOR /R %%I IN (*.AVI) DO CALL :ffmpeg "%%I"

echo.
echo.
echo Finished remuxing AVI files
echo Previous version renamed to *.old
echo.
echo 
rem pause
EXIT

:ffmpeg

set "old="%~n1.old""
if exist %old% del %old%

REM The following creates a unique temporary filename
:getTempAVI
set tempavi=temp-%RANDOM%-%TIME:~6,5%.avi
if exist "%tempavi%" GOTO getTempAVI

"C:\Program Files\Serviio\lib\ffmpeg.exe" -i "%~nx1" -vcodec copy -acodec copy %tempavi%

rename "%~nx1" %old%
rename %tempavi% "%~nx1"
set "old="
set "tempavi="
GOTO :eof

Re: Xbox 360 not transcoding .avi files

PostPosted: Tue Aug 20, 2013 10:00 am
by Illico
DenyAll, could you copy this great post in a wiki page ?

There were a similar topic here, but you can create another solution with ffmpeg.

Re: Xbox 360 not transcoding .avi files

PostPosted: Tue Aug 20, 2013 12:17 pm
by allenlook
Thank you very much for the tip, I will look into the wBitsPerSample problem.

You are correct that it is an AVI file with an MP3 audio stream showing as 128 kbps. Unfortunately out of hundreds of files, many of them also show as the same thing, but only one or two random ones have a problem. MediaInfo shows some of the working files as being written by NanDub, and this particular non-working file does not show a writing application at all?

I have pasted that curl command (from an earlier post) into a batch file, and it allows me to refresh the library on the server (in the basement) without first having to get up, establish a remote control session, log in, start Serviio Console, select the Library tab, click Refresh,... etc. A great time-saver!

I'll look into this ffmpeg script as well, thank you!

Re: Xbox 360 not transcoding .avi files

PostPosted: Tue Aug 20, 2013 8:19 pm
by allenlook
I rewrote the script you posted, and also made a copy that does only a single file so I can drag and drop one file on the CMD file/shortcut and have it done. Interestingly, on some of the files that I have already watched on the XBox 360, ffmpeg reports a warning about the bits per sample referenced and stored being different. I don't know if this is exactly what is being talked about by wbitspersample?

Re: Xbox 360 not transcoding .avi files

PostPosted: Wed Aug 21, 2013 8:20 am
by DenyAll
Yes, the warning about the bits per sample referenced and stored being different is ffmpeg's way of telling you you have the wbitspersample problem. Sorry, couldn't remember the exact message when I posted above.

<edit>
The message is in the form of:
[NULL @ 018C75C0] requested bits_per_coded_sample (16) and actually stored (0) differ
</edit>

My understanding (and its by no means complete) is that the AVI container stores information about the bits per sample for the audio stream within the wbitspersample field in the AVI header. This value is either zero, in which case the decoder looks for the information in the audio stream, or if not zero, must be a multiple of 8 and must align to the codecs rules that particular audio type (eg. it must align to sample size, 8, 16, 32 bits etc).

For these problem files this information is not stored correctly in the header (ie. it is non-zero, hence the name of the issue, and the wrong value is stored). ffmpeg detects this when copying the audio stream, and displays the message you got. For some devices this results in un-playable AVI's while other devices have no problem (my guess is they either ignore this field and use the true value from the audio stream, or have some value they default to eg. 16 bits, that results in some files working, others not, depending on whether the default happens to align to the real value). Remuxing a file recreates the AVI container, fixing the wbitspersample field.

Anyway, the bigger question, did this fix the problem for those files that were not playing on the Xbox?

ps. I also have a drag-and-drop version of this file if you or others want it. To use this save in a folder and drag your files on top of this one.

  Code:
@echo off
set "src="%~nx1""
set "old="%~n1.old""

if exist %old% del %old%

rem The following creates a unique temporary filname
:getTempAVI
set tempavi=temp-%RANDOM%-%TIME:~6,5%.avi
if exist "%tempavi%" GOTO getTempAVI

"C:\Program Files\Serviio\lib\ffmpeg.exe" -i %src% -vcodec copy -acodec copy %tempavi%

rename %src% %old%
rename %tempavi% %src%

echo.
echo.
echo Finished remuxing %src%.
echo Previous version renamed to %old%.
echo.
echo 
rem pause

set "src="
set "old="
set "tempavi="
I also have drag and drop batch files for "ffmpeg -i" and converting one video container to another (eg. convert to an AVI, convert to an MP4) if interested. All use ffmpeg that comes with Serviio.

Re: Xbox 360 not transcoding .avi files

PostPosted: Wed Aug 21, 2013 3:17 pm
by paniko
DenyAll wrote:Yes, the warning about the bits per sample referenced and stored being different is ffmpeg's way of telling you you have the wbitspersample problem. Sorry, couldn't remember the exact message when I posted above.

My understanding (and its by no means complete) is that the AVI container stores information about the bits per sample for the audio stream within the wbitspersample field in the AVI header. This value is either zero, in which case the decoder looks for the information in the audio stream, or if not zero, must be a multiple of 8 and must align to the codecs rules that particular audio type (eg. it must align to sample size, 8, 16, 32 bits etc).

For these problem files this information is not stored correctly in the header (ie. it is non-zero, hence the name of the issue, and the wrong value is stored). ffmpeg detects this when copying the audio stream, and displays the message you got. For some devices this results in un-playable AVI's while other devices have no problem (my guess is they either ignore this field and use the true value from the audio stream, or have some value they default to eg. 16 bits, that results in some files working, others not, depending on whether the default happens to align to the real value). Remuxing a file recreates the AVI container, fixing the wbitspersample field.

Anyway, the bigger question, did this fix the problem for those files that were not playing on the Xbox?

ps. I also have a drag-and-drop version of this file if you or others want it. To use this save in a folder and drag your files on top of this one.

  Code:
@echo off
set "src="%~nx1""
set "old="%~n1.old""

if exist %old% del %old%

rem The following creates a unique temporary filname
:getTempAVI
set tempavi=temp-%RANDOM%-%TIME:~6,5%.avi
if exist "%tempavi%" GOTO getTempAVI

"C:\Program Files\Serviio\lib\ffmpeg.exe" -i %src% -vcodec copy -acodec copy %tempavi%

rename %src% %old%
rename %tempavi% %src%

echo.
echo.
echo Finished remuxing %src%.
echo Previous version renamed to %old%.
echo.
echo 
rem pause

set "src="
set "old="
set "tempavi="
I also have drag and drop batch files for "ffmpeg -i" and converting one video container to another (eg. convert to an AVI, convert to an MP4) if interested. All use ffmpeg that comes with Serviio.


Wht's the different from the first .bat and the second .bat?

The second .bat don't work for me

Re: Xbox 360 not transcoding .avi files

PostPosted: Wed Aug 21, 2013 5:00 pm
by allenlook
Confusingly, I have many files with the wBitsPerSample issue, but they play just fine, so they don't need the ffmpeg remux. I need to find some other unique attribute that is causing the XBox 360 to throw the "unsupported" error.

Coincidentally I just created an "ffmpeg -i" command file last night while I was noodling with the files. I'd be glad to get a copy of any others you've found useful.

Here's a MediaInfo dump on the file that would not play...

  Code:
General
Complete name                            : C:\Users\User\Desktop\VideoFile.avi
Format                                   : AVI
Format/Info                              : Audio Video Interleave
File size                                : 351 MiB
Duration                                 : 54mn 7s
Overall bit rate                         : 906 Kbps

Video
ID                                       : 0
Format                                   : MPEG-4 Visual
Format profile                           : Advanced Simple@L5
Format settings, BVOP                    : 2
Format settings, QPel                    : No
Format settings, GMC                     : No warppoints
Format settings, Matrix                  : Default (H.263)
Codec ID                                 : XVID
Codec ID/Hint                            : XviD
Duration                                 : 54mn 7s
Bit rate                                 : 765 Kbps
Width                                    : 480 pixels
Height                                   : 272 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 29.970 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.195
Stream size                              : 296 MiB (84%)
Writing library                          : XviD 1.2.1 (UTC 2008-12-04)

Audio
ID                                       : 1
Format                                   : MPEG Audio
Format version                           : Version 1
Format profile                           : Layer 3
Codec ID                                 : 55
Codec ID/Hint                            : MP3
Duration                                 : 54mn 6s
Source duration                          : 54mn 6s
Bit rate mode                            : Constant
Bit rate                                 : 128 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 44.1 KHz
Compression mode                         : Lossy
Stream size                              : 49.5 MiB (14%)
Alignment                                : Split accross interleaves
Interleave, duration                     : 26 ms (0.78 video frame)


And here's a dump of the file that reports wBitsPerSample, but plays just fine.

  Code:
General
Complete name                            : C:\Users\User\Desktop\VideoFile2.avi
Format                                   : AVI
Format/Info                              : Audio Video Interleave
File size                                : 550 MiB
Duration                                 : 50mn 0s
Overall bit rate mode                    : Variable
Overall bit rate                         : 1 538 Kbps
Writing application                      : transcode-1.0.4

Video
ID                                       : 0
Format                                   : MPEG-4 Visual
Format profile                           : Advanced Simple@L5
Format settings, BVOP                    : 2
Format settings, QPel                    : No
Format settings, GMC                     : No warppoints
Format settings, Matrix                  : Default (H.263)
Codec ID                                 : XVID
Codec ID/Hint                            : XviD
Duration                                 : 50mn 0s
Bit rate                                 : 1 369 Kbps
Width                                    : 624 pixels
Height                                   : 352 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 23.976 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.260
Stream size                              : 490 MiB (89%)
Writing library                          : XviD 1.2.1 (UTC 2008-12-04)

Audio
ID                                       : 1
Format                                   : MPEG Audio
Format version                           : Version 1
Format profile                           : Layer 3
Codec ID                                 : 55
Codec ID/Hint                            : MP3
Duration                                 : 50mn 0s
Bit rate mode                            : Variable
Bit rate                                 : 128 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Stream size                              : 55.9 MiB (10%)
Alignment                                : Aligned on interleaves
Interleave, duration                     : 24 ms (0.58 video frame)

Re: Xbox 360 not transcoding .avi files

PostPosted: Wed Aug 21, 2013 6:13 pm
by allenlook
Here's a more graphical view of the two files compared. Green = identical, yellow = different, red = only appears in one of the files.

Image

Re: Xbox 360 not transcoding .avi files

PostPosted: Wed Aug 21, 2013 11:27 pm
by DenyAll
paniko wrote:Wht's the different from the first .bat and the second .bat?
The first bat file scans all AVI files in the current folder and remuxes them. The second batch file acts on a single AVI file only - to use, drag an AVI file on top of it. Let me know if it still doesn't work if you do this. ps. you can have multiple instances of the second batch file running (enables you to start re-muxing a second file without waiting for the first to finish. Drag the second file onto the batch file separately ie. don't try to drag two files on together).

@allenlook: I spent a long time doing what you're doing, trying to find a definitive indicator that would identify files with this issue. I haven't found one using ffmpeg or MediaInfo (even if you compare the fixed file with the original, you won't see much difference, and nothing of significance). In my winXP days there was a program that would actually display this field in the Windows Explorer window, but I can't remember what it is. Let me know if you find one - apparently VirtualDub will identify the based on other posts I've read.

For me, ffmpeg only ever showed the warning on files that wouldn't play on my TV (and yet were fine on the PS3 or PV). You are finding it is displaying the warning on some files that are fine on your Xbox. I suspect this is simply that the Xbox has some level of tolerance for this problem - the issue is still there, but like software on my PC or my PS3, the Xbox can deal with it in some situations.