aws / amazon-kinesis-video-streams-parser-library

Amazon Kinesis Video Streams parser library is for developers to include in their applications that makes it easy to work with the output of video streams such as retrieving frame-level objects, metadata for fragments, and more.
Apache License 2.0
103 stars 52 forks source link

[BUG} LTR video decoding issue (already handled by latest JCodec codebase) #153

Closed mrgiba closed 2 years ago

mrgiba commented 2 years ago

Logging Add relevent parser library logging. IMPORTANT NOTE: Please make sure to NOT share AWS access credentials under any circumstance! Please make sure they are not in the logs.

2022-02-07 18:31:33 ERROR FrameDecodingWorker:Error decoding frame
java.lang.RuntimeException: long term
at org.jcodec.codecs.h264.decode.RefListManager.reorder(RefListManager.java:156)
at org.jcodec.codecs.h264.decode.RefListManager.buildRefListP(RefListManager.java:79)
at org.jcodec.codecs.h264.decode.RefListManager.getRefList(RefListManager.java:42)
at org.jcodec.codecs.h264.decode.SliceDecoder.decodeFromReader(SliceDecoder.java:71)
at org.jcodec.codecs.h264.H264Decoder$FrameDecoder.decodeFrame(H264Decoder.java:152)
at org.jcodec.codecs.h264.H264Decoder.decodeFrameFromNals(H264Decoder.java:103)
at <manually hidden>.streamprocessor.worker.FrameDecodingWorker.decodeH264Frame(FrameDecodingWorker.java:137)
at <manually hidden>.streamprocessor.worker.FrameDecodingWorker.doProcess(FrameDecodingWorker.java:95)
at <manually hidden>.streamprocessor.worker.FrameDecodingWorker.process(FrameDecodingWorker.java:75)
at com.amazonaws.kinesisvideo.parser.utilities.FrameVisitor$FrameProcessor.process(FrameVisitor.java:82)
at com.amazonaws.kinesisvideo.parser.utilities.FrameVisitor$FrameVisitorInternal.visit(FrameVisitor.java:119)
at com.amazonaws.kinesisvideo.parser.mkv.MkvDataElement.accept(MkvDataElement.java:120)
at com.amazonaws.kinesisvideo.parser.mkv.visitors.CompositeMkvElementVisitor.visitAll(CompositeMkvElementVisitor.java:66)
at com.amazonaws.kinesisvideo.parser.mkv.visitors.CompositeMkvElementVisitor.visit(CompositeMkvElementVisitor.java:53)
at com.amazonaws.kinesisvideo.parser.mkv.MkvDataElement.accept(MkvDataElement.java:120)
at com.amazonaws.kinesisvideo.parser.mkv.visitors.CompositeMkvElementVisitor.visitAll(CompositeMkvElementVisitor.java:66)
at com.amazonaws.kinesisvideo.parser.mkv.visitors.CompositeMkvElementVisitor.visit(CompositeMkvElementVisitor.java:53)
at com.amazonaws.kinesisvideo.parser.mkv.MkvDataElement.accept(MkvDataElement.java:120)
at com.amazonaws.kinesisvideo.parser.mkv.StreamingMkvReader.apply(StreamingMkvReader.java:131)
at com.amazonaws.kinesisvideo.parser.utilities.consumer.GetMediaResponseStreamConsumer.processWithFragmentEndCallbacks(GetMediaResponseStreamConsumer.java:40)
at <manually hidden>.streamprocessor.Main$1$1.process(Main.java:222)
at com.amazonaws.kinesisvideo.parser.examples.ContinuousGetMediaWorker.run(ContinuousGetMediaWorker.java:82)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)

Describe the bug amazon-kinesis-video-streams-parser-library to consume frames from a Kinesis Video Stream and a frame decoding issue around lack of LTR support on the video is being a blocker. This seems to be a JCodec issue, according to https://github.com/jcodec/jcodec/issues/379, something which has already been fixed in the latest JCodec codebase Therefore, my request is for amazon-kinesis-video-streams-parser-library to upgrade its JCodec dependency from 0.2.3 to their latest codebase. I'll also appreciate if there is a quick workaround to overcome the issue

SDK version number amazon-kinesis-video-streams-parser-library version 1.0.15

To Reproduce This is part of the logic of an backend application to process frames coming from a Kinesis Video Stream

Expected behavior Frame decoding should work properly

Screenshots If applicable, add screenshots to help explain your problem. N/A

Desktop (please complete the following information):

Additional context

niyatim23 commented 2 years ago

Hi @mrgiba, it looks like you are using an older version of the library. To avoid having any security vulnerabilities, we suggest that you upgrade to v1.2.2. For the jcodec issue, please refer to the steps here

mrgiba commented 2 years ago

@niyatim23 Could you please attest amazon-kinesis-video-streams-parser-library compatibility with the latest JCodec code ?

niyatim23 commented 2 years ago

Hi @mrgiba, I have not understood your question completely, can you please clarify what do you expect from us? If this was an inquiry about the version of jcodec we use, the latest release of the amazon-kinesis-video-streams-parser-library uses 0.2.3 of jcodec. We are not seeing any build issues with the same on Mac and Ubuntu on our end.

mrgiba commented 2 years ago

I was just looking for a thumbs up from Kinesis team around using the latest JCodec codebase on the amazon-kinesis-video-streams-parser-library

mrgiba commented 2 years ago

As a side discussion, is there a big difference around log classloading between versions 1.0.15 and 1.2.2 ? I did a quick testing moving my application to version 1.2.2 and I am now getting errors like this:

log4j:ERROR Could not instantiate class [com.amazonaws.services.lambda.runtime.log4j.LambdaAppender].
java.lang.ClassNotFoundException: com.amazonaws.services.lambda.runtime.log4j.LambdaAppender
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) 
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) 
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) 
    at java.base/java.lang.Class.forName0(Native Method) 
    at java.base/java.lang.Class.forName(Class.java:315) 
    at org.apache.log4j.helpers.Loader.loadClass(Loader.java:190) 
    at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:304) 
    at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123) 
    at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:755) 
    at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:738) 
    at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:630) 
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:516) 
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:577) 
    at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:504) 
    at org.apache.log4j.LogManager.<clinit>(LogManager.java:119) 
    at org.slf4j.impl.Reload4jLoggerFactory.<init>(Reload4jLoggerFactory.java:67) 
    at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:72) 
    at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:45) 
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150) 
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124) 
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417) 
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362) 
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388) 
    at <manually hidden>.Main.<clinit>(Main.java:57) 
niyatim23 commented 2 years ago

Yes, quite a few packages have been updated. You can find the list of the same in the release notes.

mrgiba commented 2 years ago

Too odd. My application is not even using Lambda

mrgiba commented 2 years ago

Testing each version in my application, I noticed the java.lang.ClassNotFoundException: com.amazonaws.services.lambda.runtime.log4j.LambdaAppender happens on version 1.2.0 onwards

Any thoughts ? Any relation with https://github.com/aws/amazon-kinesis-video-streams-parser-library/blob/master/src/main/resources/log4j.properties ?

niyatim23 commented 2 years ago

I have not seen that error in the past. I'm not sure about what could be causing it. Can you please build the parser library independently with the steps on the README.md and check if you still see this error?

mrgiba commented 2 years ago

The error also happens if I build the parser library independently and import into my application

mrgiba commented 2 years ago

Adding a simple log4j.properties to the src/main/resources of my application was enough to overcome the ClassNotFoundException:

log = .
log4j.rootLogger = INFO

Adding a log4j2.xml file to the same folder didn't have the same effect though

With such an additional hurdle overcome, I'll now follow with the instructions to generate the library including the latest jcodec codebase and validate if the decoding issue is resolved

mrgiba commented 2 years ago

Validation just completed. Decoding problem was resolved