Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalStateException: Error from decoder 16394 #161

Open
munishkhatri720 opened this issue Dec 23, 2024 · 0 comments
Open

java.lang.IllegalStateException: Error from decoder 16394 #161

munishkhatri720 opened this issue Dec 23, 2024 · 0 comments

Comments

@munishkhatri720
Copy link

  • Error Logs :
11|basic  | 2024-12-23T05:21:35.621Z ERROR 3221009 --- [Lavalink] [-1-thread-61750] c.s.d.l.t.p.LocalAudioTrackExecutor      : Error in playback of 4WMHDpmfuLwM2Ty8KQXZjN
11|basic  | com.sedmelluq.discord.lavaplayer.tools.FriendlyException: Something went wrong when decoding the track.
11|basic  |     at com.sedmelluq.discord.lavaplayer.tools.ExceptionTools.wrapUnfriendlyExceptions(ExceptionTools.java:45) ~[lavaplayer-2.2.2.jar!/:na]
11|basic  |     at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.executeProcessingLoop(LocalAudioTrackExecutor.java:279) ~[lavaplayer-2.2.2.jar!/:na]
11|basic  |     at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.executeProcessingLoop(LocalAudioTrackExecutor.java:234) ~[lavaplayer-2.2.2.jar!/:na]
11|basic  |     at com.sedmelluq.discord.lavaplayer.container.mpeg.MpegAudioTrack.process(MpegAudioTrack.java:52) ~[lavaplayer-2.2.2.jar!/:na]
11|basic  |     at com.sedmelluq.discord.lavaplayer.track.DelegatedAudioTrack.processDelegate(DelegatedAudioTrack.java:25) ~[lavaplayer-2.2.2.jar!/:na]
11|basic  |     at com.github.topi314.lavasrc.saavn.SaavnAudioTrack.process(SaavnAudioTrack.java:89) ~[lavasrc-plugin-c5386f5.jar!/:na]
11|basic  |     at com.sedmelluq.discord.lavaplayer.track.DelegatedAudioTrack.processDelegate(DelegatedAudioTrack.java:25) ~[lavaplayer-2.2.2.jar!/:na]
11|basic  |     at com.github.topi314.lavasrc.mirror.MirroringAudioTrack.process(MirroringAudioTrack.java:55) ~[lavasrc-plugin-c5386f5.jar!/:na]
11|basic  |     at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.execute(LocalAudioTrackExecutor.java:109) ~[lavaplayer-2.2.2.jar!/:na]
11|basic  |     at com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager.lambda$executeTrack$2(DefaultAudioPlayerManager.java:339) ~[lavaplayer-2.2.2.jar!/:na]
11|basic  |     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]
11|basic  |     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]
11|basic  |     at java.base/java.lang.Thread.run(Thread.java:1583) ~[na:na]
11|basic  | Caused by: java.lang.IllegalStateException: Error from decoder 16394
11|basic  |     at com.sedmelluq.discord.lavaplayer.natives.aac.AacDecoder.decode(AacDecoder.java:209) ~[lavaplayer-2.2.2.jar!/:na]
11|basic  |     at com.sedmelluq.discord.lavaplayer.container.common.AacPacketRouter.processInput(AacPacketRouter.java:57) ~[lavaplayer-2.2.2.jar!/:na]
11|basic  |     at com.sedmelluq.discord.lavaplayer.container.mpeg.MpegAacTrackConsumer.consume(MpegAacTrackConsumer.java:79) ~[lavaplayer-2.2.2.jar!/:na]
11|basic  |     at com.sedmelluq.discord.lavaplayer.container.mpeg.reader.standard.MpegStandardFileTrackProvider.provideFrames(MpegStandardFileTrackProvider.java:75) ~[lavaplayer-2.2.2.jar!/:na]
11|basic  |     at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.executeProcessingLoop(LocalAudioTrackExecutor.java:261) ~[lavaplayer-2.2.2.jar!/:na]
11|basic  |     ... 11 common frames omitted
package com.github.topi314.lavasrc.saavn;
import com.github.topi314.lavasrc.ExtendedAudioTrack;
import com.github.topi314.lavasrc.LavaSrcTools;
import com.sedmelluq.discord.lavaplayer.container.mpeg.MpegAudioTrack;
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManager;
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
import com.sedmelluq.discord.lavaplayer.tools.JsonBrowser;
import com.sedmelluq.discord.lavaplayer.tools.io.PersistentHttpStream;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo;
import com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor;
import org.apache.http.client.methods.HttpGet;
import java.net.URI;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;

public class SaavnAudioTrack extends ExtendedAudioTrack {
    private static final String ALGORITHM = "DES/ECB/PKCS5Padding";
    
	private final SaavnAudioSourceManager sourceManager;

	public SaavnAudioTrack(AudioTrackInfo trackInfo, SaavnAudioSourceManager sourceManager) {
		this(trackInfo, null, null, null, null, null, false, sourceManager);
	}

	public SaavnAudioTrack(AudioTrackInfo trackInfo, String albumName, String albumUrl, String artistUrl, String artistArtworkUrl, String previewUrl, boolean isPreview, SaavnAudioSourceManager sourceManager) {
		super(trackInfo, albumName, albumUrl, artistUrl, artistArtworkUrl, previewUrl, isPreview);
		this.sourceManager = sourceManager;
	}
    
    public static String decryptUrl(String url) throws Exception {
		String key = "38346591";
		byte[] encryptedBytes = Base64.getDecoder().decode(url);
        SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "DES");
        Cipher cipher = Cipher.getInstance(ALGORITHM);
        cipher.init(Cipher.DECRYPT_MODE, keySpec);
        byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
        return new String(decryptedBytes);

       

	}

	private URI getTrackMediaURI() throws Exception {
		var data = new HttpGet(SaavnAudioSourceManager.MEDIA_API_BASE + this.getIdentifier());
		
		var json = LavaSrcTools.fetchResponseAsJson(this.sourceManager.getHttpInterface(), data);

		this.checkResponse(json, "Failed to get track details: ");
		var track_data = json.get(this.getIdentifier());
		var encrypted_media_url = track_data.get("encrypted_media_url").text();

		var playback_url = decryptUrl(encrypted_media_url);

		if (track_data.get("320kbps").asBoolean(false)) {
			playback_url = playback_url.replace("_96.mp4", "_320.mp4");
		} 

		System.out.println(playback_url);

		return new URI(playback_url);
		
	}

	private void checkResponse(JsonBrowser json, String message) throws IllegalStateException {
		if (json == null) {
			throw new IllegalStateException(message + "No response");
		}
		if (json.get(this.getIdentifier()).isNull()) {
			throw new IllegalStateException(message + "No track found");
		}
		
	}

	
	@Override
	public void process(LocalAudioTrackExecutor executor) throws Exception {
		try (var httpInterface = this.sourceManager.getHttpInterface()) {
			if (this.isPreview) {
				if (this.previewUrl == null) {
					throw new FriendlyException("No preview url found", FriendlyException.Severity.COMMON, new IllegalArgumentException());
				}
				try (var stream = new PersistentHttpStream(httpInterface, new URI(this.previewUrl), this.trackInfo.length)) {
					processDelegate(new MpegAudioTrack(this.trackInfo, stream), executor);
				}
			} else {
				try (var stream = new PersistentHttpStream(httpInterface, this.getTrackMediaURI(), this.trackInfo.length)) {
					processDelegate(new MpegAudioTrack(this.trackInfo, stream), executor);
				}
			}
		}
	}

	@Override
	protected AudioTrack makeShallowClone() {
		return new SaavnAudioTrack(this.trackInfo, this.albumName, this.albumUrl, this.artistUrl, this.artistArtworkUrl, this.previewUrl, this.isPreview, this.sourceManager);
	}

	@Override
	public AudioSourceManager getSourceManager() {
		return this.sourceManager;
	}

}
{
    "streams": [
        {
            "index": 0,
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "profile": "LC",
            "codec_type": "audio",
            "codec_tag_string": "mp4a",
            "codec_tag": "0x6134706d",
            "sample_fmt": "fltp",
            "sample_rate": "44100",
            "channels": 2,
            "channel_layout": "stereo",
            "bits_per_sample": 0,
            "initial_padding": 0,
            "id": "0x1",
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/44100",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 12708562,
            "duration": "288.176009",
            "bit_rate": "325074",
            "nb_frames": "12412",
            "extradata_size": 5,
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "non_diegetic": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "language": "und",
                "handler_name": "SoundHandler",
                "vendor_id": "[0][0][0][0]"
            }
        }
    ],
    "format": {
        "filename": "https://aac.saavncdn.com/201/f2472e5f1e27a80b11773e88628dc06e_320.mp4",
        "nb_streams": 1,
        "nb_programs": 0,
        "nb_stream_groups": 0,
        "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
        "format_long_name": "QuickTime / MOV",
        "start_time": "0.000000",
        "duration": "288.176009",
        "size": "11761419",
        "bit_rate": "326506",
        "probe_score": 100,
        "tags": {
            "major_brand": "isom",
            "minor_version": "512",
            "compatible_brands": "isomiso2mp41",
            "encoder": "Lavf57.82.101"
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant