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

Invalid Nal Length Error In Playing Encrypted video online #11229

Open
MohsenNaderzadeh opened this issue Jun 26, 2023 · 6 comments
Open

Invalid Nal Length Error In Playing Encrypted video online #11229

MohsenNaderzadeh opened this issue Jun 26, 2023 · 6 comments
Assignees
Labels

Comments

@MohsenNaderzadeh
Copy link

Hi, I have an encrypted video stored on the server which I want to play in Exoplayer. I am using this repo custom datasource for playing encrypted video offline. For online playback, I added some code from Exoplayer DefaultHttpDataSource to implement the setupInputStream function from the server instead of the local file. The video plays but when I change the seekbar position after a few moments, I get an Invalid Nal Length Error and OnPlayerError is called. My Encryption Alghoritm is AES/CTR/NOPadding

@tianyif
Copy link
Contributor

tianyif commented Jun 27, 2023

Hi @MohsenNaderzadeh,

Did you try to reproduce the issue with the demo app? If the problem happens on the demo app, could you please provide us the media so that we can investigate on our end?

Thanks!

@droplet-js
Copy link

i have same issue

def exoplayer_version = "2.18.7"
implementation "com.google.android.exoplayer:exoplayer-core:${exoplayer_version}"
implementation "com.google.android.exoplayer:exoplayer-hls:${exoplayer_version}"
implementation "com.google.android.exoplayer:exoplayer-dash:${exoplayer_version}"
implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:${exoplayer_version}"
E/ExoPlayerImplInternal( 4684): Playback error
E/ExoPlayerImplInternal( 4684):   com.google.android.exoplayer2.ExoPlaybackException: Source error
E/ExoPlayerImplInternal( 4684):       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:644)
E/ExoPlayerImplInternal( 4684):       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:614)
E/ExoPlayerImplInternal( 4684):       at android.os.Handler.dispatchMessage(Handler.java:106)
E/ExoPlayerImplInternal( 4684):       at android.os.Looper.loop(Looper.java:219)
E/ExoPlayerImplInternal( 4684):       at android.os.HandlerThread.run(HandlerThread.java:67)
E/ExoPlayerImplInternal( 4684):   Caused by: com.google.android.exoplayer2.ParserException: Invalid NAL length
E/ExoPlayerImplInternal( 4684):       at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.readSample(Mp4Extractor.java:641)
E/ExoPlayerImplInternal( 4684):       at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:259)
E/ExoPlayerImplInternal( 4684):       at com.google.android.exoplayer2.source.BundledExtractorsAdapter.read(BundledExtractorsAdapter.java:127)
E/ExoPlayerImplInternal( 4684):       at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1039)
E/ExoPlayerImplInternal( 4684):       at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
E/ExoPlayerImplInternal( 4684):       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/ExoPlayerImplInternal( 4684):       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/ExoPlayerImplInternal( 4684):       at java.lang.Thread.run(Thread.java:929)

@MohsenNaderzadeh
Copy link
Author

Hi @tianyif, My video is encrypted with the encryption algorithm as I said, Can I play it with the demo app? Is it possible?

@icbaker
Copy link
Collaborator

icbaker commented Jun 30, 2023

If you've written a custom DataSource I recommend testing it with a subclass of DataSourceContractTest to check you implemented the interface correctly and fully. More info here: https://medium.com/google-exoplayer/standardising-datasource-implementations-through-testing-b7a8ab04f8d1

From the description (seeking breaks things) it sounds like possibly your implementation doesn't handle being closed and re-opened? Bit of a guess.

@icbaker icbaker assigned icbaker and unassigned tianyif Jun 30, 2023
@MohsenNaderzadeh
Copy link
Author

Hi @icbaker, I added DefaultHttpDataSourceContractTest as a test subclass of DataSourceContractTest. As a part of the test, I passed Exoplayer's own DefaultHttpDataSource as an implementation of the createDataSource function. All of the tests passed except for two that are related to Mockito and unit testing. I am currently unable to resolve these errors and run the test class successfully. Once I have resolved these issues and successfully run the test class, I will proceed to test my own custom data source. Please keep my issue open until I have resolved the errors and run the test class successfully.

@icbaker
Copy link
Collaborator

icbaker commented Jul 3, 2023

Not sure if you've already seen it, but you might want to take a look at our DefaultHttpDataSourceContractTest and the HttpDataSourceTestEnv it uses to set up serving test data at various URLs using Square's MockWebServer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants