ffmpeg Decodes .xma Too Fast? by Kurausukun at 4:34 AM EST on December 10, 2016
I just tried using the latest build of ffmpeg to decode an .xma file (specifically, an .xma file from Sonic 06, which uses xma1), and ffmpeg does successfully output the file, but it plays too fast. Does anyone else have this issue, or have any experience/tips in decoding .xma files with ffmpeg?
by bnnm at 7:08 AM EST on December 10, 2016
Looks like XMA2 with XMA1 header, so it decodes incorrectly? (it has XMA2 stuff at the very end)
Meaning vgmstream's FFmpeg also can't open it.

Probably fixable, I'll look into it.

I got it from joshw, I wonder it they weren't ripped incorrectly.


edited 7:09 AM EST December 10, 2016
by kode54 at 4:15 PM EST on December 10, 2016
Also look into supporting the loop points from the extra codec setup data, since FFmpeg doesn't support those.
by Kurausukun at 5:36 PM EST on December 10, 2016
I got mine directly from an ISO. I doubt joshw's was ripped incorrectly, but if you want, I can upload one here.

edited 5:37 PM EST December 10, 2016
by kode54 at 3:13 PM EST on December 11, 2016
FFmpeg needs to be tricked into ignoring the "fmt " chunks in those files, so it only parses the XMA2 chunks for format information. I tried to make it override at one point, but that didn't work. It needs to not even see the "fmt " chunks if there are "XMA2" chunks.
by bxaimc at 8:36 PM EST on December 11, 2016
*cough* I ripped it *cough*
by AnonRunzes at 8:47 PM EST on December 11, 2016
@bxaimc - Yes, and...?
by bnnm at 2:18 PM EST on December 12, 2016
Not being ripped ok was just a random thought!

I did some grotesque header forgery and it's working ok. I'll take some time to check variations and stuff though.
(maybe it's just easier to fix it in FFmpeg itself)
by kode54 at 3:44 PM EST on December 12, 2016
Chopping out the "fmt " chunk will "fix" it too. Maybe add a check to FFmpeg to search for the XMA2 chunk separately first, then bypass the fmt chunk if an XMA2 chunk is found? And don't forget to submit your patch to the ffmpeg devel mailing list!
by bnnm at 4:39 PM EST on December 12, 2016
The main problem is that the XMA2 chunk has some variations but FFmpeg only supports one.
I can reconstruct the header ignoring the fmt and moving XMA2 data around where FFmpeg expects it but it's so ugly.

Patching FFmpeg wouldn't be so hard but on the other hand it could take a while (months?) to propagate plus having to go through all their hoops.

I think I'll do a quick hack and call it a day.

edited 4:39 PM EST December 12, 2016
by Kurausukun at 6:28 PM EST on December 12, 2016
When/if you do this quick hack, how will we be able to use it?
by richardpl at 4:17 AM EST on December 13, 2016
Can you please upload sample somewhere?

I'm one responsible for XMA1/2 support in FFmpeg.

And I welcome any patches to FFmpeg.
by bnnm at 2:43 PM EST on December 13, 2016
@Kurausukun - I meant I'll update vgmstream to play XMA, but internally it may be hack-y.

@richardpi - Samples: https://www.sendspace.com/file/4u546i

Issues I know:
- if the "fmt" chunk is found first "XMA2" is ignored (@ wavdec.c)
- "XMA2" chunk: no V3 = size 0x24 (minor variation), expects V4 = size 0x2c (@ wavdec.c)
- no XMA2 6 channel (@ wmaprodec.c)
- no RIFX/big endian
(also I'll check if various block sizes are supported)

The 6ch is the only one I can't hack into vgmstream, so it would be great if you could look into that first.

***

Also I couldn't find a XMA1 set with loop points. I'm blind, loop points are outside, or is every joshw set borked/transconverted? :S
by richardpl at 3:36 PM EST on December 13, 2016
The >2 channel in XMA1/2 is one big mess, i failed to dechiper it. Perhaps someone can explain to me how to implement it because it needs big blocks of data. I'm well aware of scripts which splits such streams into stereo files.
by Kurausukun at 6:08 PM EST on December 13, 2016
I don't know if His World actually loops in-game, so I'm not sure there are loop points in that file... I'll upload the one I've been using just in case: here.
by richardpl at 5:58 PM EST on January 18, 2017
I got multichannel XMA2 somehow working in FFmpeg.
Decoder still spills errors now and then but everything sounds fine to my ears.
by bnnm at 3:06 PM EST on January 19, 2017
Thanks, much appreciated.

I tested with vgmstream a bit and generally works fine, but there are some problems when looping/seeking.
Seems channel packets are being mixed (ex. packets from ch0 will appear in ch2, etc).

Looping works by using avformat_seek_file to 0 + avcodec_flush_buffers, and decoding again until the desired sample.

Maybe some internal state isn't being flushed?

EDIT: ah, I see you already submitted a patch!

edited 3:08 PM EST January 19, 2017
by richardpl at 8:12 AM EST on January 20, 2017
I think I fixed those channel mixing issues. Only I get some errors when decoding some xma1 multichannel files, dunno why.
by bnnm at 7:22 PM EST on January 21, 2017
It's working great now. Thanks!

For XMA1, I've seen many samples around incorrectly converted from XMA2, I wouldn't worry too much (unless you ripped them yourself...)


Go to Page 0

Search this thread

Show all threads

Reply to this thread:

User Name Tags:

bold: [b]bold[/b]
italics: [i]italics[/i]
emphasis: [em]emphasis[/em]
underline: [u]underline[/u]
small: [small]small[/small]
Link: [url=http://www.google.com]Link[/url]

[img=https://www.hcs64.com/images/mm1.png]
Password
Subject
Message

HCS Forum Index
Halley's Comet Software
forum source