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.NullPointerException: Attempt to invoke interface method 'boolean com.otaliastudios.transcoder.source.DataSource.isInitialized()' on a null object reference #177

Open
Kanishk251296 opened this issue Jul 31, 2022 · 5 comments

Comments

@Kanishk251296
Copy link

Kanishk251296 commented Jul 31, 2022

String srcPath = "/storage/emulated/0/Download/sample.mp3";
String desPath = "/storage/emulated/0/Download/hmm.aac";
            Log.e(TAG, "onActivityResult: "+srcPath);
            DefaultAudioStrategy strategy = DefaultAudioStrategy.builder()
                    .channels(DefaultAudioStrategy.CHANNELS_AS_INPUT)
                    .channels(1)
                    .channels(2)
                    .sampleRate(DefaultAudioStrategy.SAMPLE_RATE_AS_INPUT)
                    .sampleRate(44100)
                    .sampleRate(30000)
                    .bitRate(DefaultAudioStrategy.BITRATE_UNKNOWN)
                    .build();
            Transcoder.into(desPath)
                    .addDataSource(srcPath)
                    .setAudioTrackStrategy(strategy)
                    .setListener(new TranscoderListener() {
                        @Override
                        public void onTranscodeProgress(double progress) {
                            Log.e(TAG, "onTranscodeProgress: ");
                        }

                        @Override
                        public void onTranscodeCompleted(int successCode) {
                            Log.e(TAG, "onTranscodeCompleted: ");
                        }

                        @Override
                        public void onTranscodeCanceled() {
                            Log.e(TAG, "onTranscodeCanceled: ");
                        }

                        @Override
                        public void onTranscodeFailed(@NonNull Throwable exception) {
                            Log.e(TAG, "onTranscodeFailed: "+exception);
                        }
                    }).transcode();
 Whenever i a running this code i am getting this error
 
 
 **

2022-07-31 17:39:10.337 10749-10822/com.example.transcoder I/TranscodeEngine: transcode(): called...
2022-07-31 17:39:10.338 10749-10822/com.example.transcoder I/DataSources: initializing videoSources...
2022-07-31 17:39:10.338 10749-10822/com.example.transcoder E/TranscodeEngine: Unexpected error while transcoding.
java.lang.NullPointerException: Attempt to invoke interface method 'boolean com.otaliastudios.transcoder.source.DataSource.isInitialized()' on a null object reference
at com.otaliastudios.transcoder.source.DataSourceWrapper.isInitialized(DataSourceWrapper.java:99)
at com.otaliastudios.transcoder.internal.DataSources.init(DataSources.kt:25)
at com.otaliastudios.transcoder.internal.DataSources.(DataSources.kt:35)
at com.otaliastudios.transcoder.internal.DataSources.(DataSources.kt:17)
at com.otaliastudios.transcoder.internal.transcode.TranscodeEngine$Companion.transcode(TranscodeEngine.kt:33)
at com.otaliastudios.transcoder.internal.transcode.TranscodeEngine.transcode(Unknown Source:2)
at com.otaliastudios.transcoder.Transcoder$1.call(Transcoder.java:102)
at com.otaliastudios.transcoder.Transcoder$1.call(Transcoder.java:99)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)
2022-07-31 17:39:10.340 10749-10749/com.example.transcoder E/ContentValues: onTranscodeFailed: java.lang.NullPointerException: Attempt to invoke interface method 'boolean com.otaliastudios.transcoder.source.DataSource.isInitialized()' on a null object reference
2022-07-31 17:39:10.394 10749-10749/com.example.transcoder V/ImeFocusController: onWindowFocus: DecorView@56cf556[MainActivity] softInputMode=STATE_UNSPECIFIED|ADJUST_PAN**

@Deepfreezed
Copy link

Deepfreezed commented Aug 9, 2022

I am also getting this error when using .addDataSource(srcPath).

Although, this is working .addDataSource(context, uri).

@Kanishk251296
Copy link
Author

I am also getting this error when using .addDataSource(srcPath).

Although, this is working .addDataSource(context, uri).

Actually i have tried that also
i am still getting the same error

@HafizUmer4
Copy link

I am also getting this error when using .addDataSource(srcPath).

Although, this is working .addDataSource(context, uri).

Now working fine

@tfidmmatthew
Copy link

How did you fix it?

@HafizUmer4
Copy link

How did you fix it?

Just pass Uri like this--------> (Uri uri = Uri.fromFile(new File(input.getAbsolutePath()));)

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

4 participants