Author Topic: A stream is not created for the M4A file from the URL.  (Read 165 times)

AlexandrSokolov

  • Posts: 2
Hello everyone! Help me figure it out.
There is a direct link to the M4A file on DropBox:
https://www.dropbox.com/scl/fi/1tc1qo8hjd1vflk42ow14/Accept-Midnight-Mover.m4a?rlkey=8ryzfstcmuhoyi5khitoz7kzm&dl=1
This link is for the file Accept - Midnight Mover .m4a
Download the file and place it in the application folder.
C# code:
string file = @"Accept - Midnight Mover .m4a";
int stream = Bass.BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_DEFAULT);
if (stream == 0)
{
    var errorCode = Bass.BASS_ErrorGetCode();
    MessageBox.Show("Error code: " + errorCode.ToString());
}
else
{
    Bass.BASS_ChannelPlay(stream, false);
}
Run the application. The file plays!
Change the code to:
string url = "https://www.dropbox.com/scl/fi/1tc1qo8hjd1vflk42ow14/Accept-Midnight-Mover.m4a?rlkey=8ryzfstcmuhoyi5khitoz7kzm&dl=1";
int stream = Bass.BASS_StreamCreateURL(url, 0, BASSFlag.BASS_DEFAULT, null, IntPtr.Zero);
if (stream == 0)
{
    var errorCode = Bass.BASS_ErrorGetCode();
    MessageBox.Show("Error code: " + errorCode.ToString());
}
else
{
    Bass.BASS_ChannelPlay(stream, false);
}
We get the error "Error code: BASS_ERROR_FILEFORM".
Add the BASSFlag.BASS_STREAM_BLOCK flag to the stream creation string. The string will now look like this:
int stream = Bass.BASS_StreamCreateURL(url, 0, BASSFlag.BASS_STREAM_BLOCK | BASSFlag.BASS_DEFAULT, null, IntPtr.Zero);
Now the file from the URL plays!
But the BASSFlag.BASS_STREAM_BLOCK flag blocks the stream. In my application, I need to change the playback position using bass_fx.dll. Changing the tempo works, but I cannot set the position. It's understandable that moving forward doesn't work, as the file hasn't fully loaded yet, but moving backward should work.
If I take another file, for example, MP3, I don't encounter such issues.
There are only 4 files in the application folder:
Accept - Midnight Mover .m4a
bass.dll
Bass.Net.dll
my_app.exe
I tried adding the bass_aac.dll plugin, but it didn't work.
I tried asynchronously downloading the file via WebClient and creating a stream using Bass.BASS_StreamCreateFile, but the playback stops after a short time. Again, the MP3 file plays without any problems in this case.
Please advise on how to make this file play with the ability to change the position. Are there any plugins missing? Do I need any buffer settings? Do I need to add any flags?
I apologize if the message is not formatted correctly according to the rules of the forum. I am a visually impaired programmer.
Thank you in advance!

Ian @ un4seen

  • Administrator
  • Posts: 26172
That file uses the "dash" format, which BASS_AAC doesn't support, so Media Foundation will be used by BASS to play it on Windows. In this case the MF decoder/parser is trying to seek to the end of the file, which isn't available yet, and it's apparently rejecting the file because of that. BASS doesn't tell MF the filesize when BASS_STREAM_BLOCK is used, so that seems to be the solution. Here's an update for you to try:

   www.un4seen.com/stuff/bass.zip

Let me know if you now have problems with any other MP4/M4A URLs (or this one still).

AlexandrSokolov

  • Posts: 2
Thank you so much for your help! Everything works as I need it to.
There is another MP4 file
https://www.dropbox.com/scl/fi/xmkonp94h49mctenp5kiy/.mp4?rlkey=j2cwigfxfp0hhhv0cqaj8opby&dl=1
When creating a stream, it gives the error BASS_ERROR_UNSTREAMABLE. If playing from the file, it plays without BASS plugins.
I don't really need this file. I was just trying to play different files via URL and noticed that this one doesn't play either.
Also, with the M4A file, on slow internet, there was an error related to server response timeout. I didn't have time to write down the exact name of the error. It appeared rarely.

Ian @ un4seen

  • Administrator
  • Posts: 26172
The problem with that file it that its "moov" atom is at the end of the file rather than the start. The "moov" atom is needed to initialize the decoder, so the entire file would need to be downloaded first, ie. it can't be streamed. If you would like to be able to stream it, there are tools that can reorder an MP4 file's atoms to make that possible.