filoe / cscore

An advanced audio library, written in C#. Provides tons of features. From playing/recording audio to decoding/encoding audio streams/files to processing audio data in realtime (e.g. applying custom effects during playback, create visualizations,...). The possibilities are nearly unlimited.
Other
2.2k stars 454 forks source link

Support for .aax files through ffmpeg #413

Open JKamsker opened 4 years ago

JKamsker commented 4 years ago

Using the ffmpeg package, it always returns "[aax] activation_bytes option is missing!" which indicates, that the "-activation_bytes" option is missing.

With my current state of knowledge, i don't know how to implement this. I hope you can show me a workaround or even provide a fix :)

Sample ffmpeg commandline: ffmpeg -activation_bytes abababab -i .\MyAudioFile.aax -vn -c:a copy MyAudioFile.m4b

Edit: I guess the last argument in https://github.com/filoe/cscore/blob/13bbebb4f0a8c3e12fc54a01c3485098bf13ba9c/CSCore.Ffmpeg/FfmpegCalls.cs#L173 should not be null to pass the extra argument.

filoe commented 4 years ago

I would have guessed the same. Could you maybe try that out whether that works or at least upload a testfile?

JKamsker commented 4 years ago

@filoe Have sent a mail with the files to (hopefully) your personal @fortix.io mail address. Could you please confirm that you got it? :D

If i could create and handle a native struct, i would have formulated my issue differently. But i can't, so i desperately begging you for help instead 😅

Edit: I've played around with it a bit and im quite sure he eats the struct i feed into the method but somehow it also results in a AccessViolationException :(

     internal static unsafe void AvformatOpenInput(AVFormatContext** formatContext, AvioContext avioContext)
{
    var key = Encoding.ASCII.GetBytes("activation_bytes").Select(x => (sbyte)x).ToArray();
    var value = Encoding.ASCII.GetBytes("abababab").Select(x => (sbyte)x).ToArray();

    fixed (sbyte* f_key = key)
    fixed (sbyte* f_value = value)
    {
        var elem = new[]
        {
          new AVDictionaryEntry { key = f_key, value = f_value }
        };

        fixed (AVDictionaryEntry* ee = elem)
        {
            AVDictionary dict = new AVDictionary { count = 1, elems = ee };

            AVDictionary* px = &dict;
            AVDictionary** px1 = &px;

            (*formatContext)->pb = (AVIOContext*)avioContext.ContextPtr;
            int result = ffmpeg.avformat_open_input(formatContext, "DUMMY-FILENAME", null, px1);//px1
            FfmpegException.Try(result, "avformat_open_input");
        }
    }
}
JKamsker commented 4 years ago

@filoe I've found some public aax files here: https://gitlab.com/vesselin.bontchev/audible-samples/tree/master

JKamsker commented 4 years ago

@filoe Have you tryed reproducing the error already?