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

TranscodeMain fails #171

Closed
mrieser opened this issue Mar 2, 2017 · 2 comments
Closed

TranscodeMain fails #171

mrieser opened this issue Mar 2, 2017 · 2 comments

Comments

@mrieser
Copy link

mrieser commented Mar 2, 2017

Using latest code version (#3d4a258) on macOS 10.12.3, Java 1.8.0_112.

I was able to use SequenceEncoder to transcode a series of png files into a mp4/h.264 movie.
When I tried to adapt the SequenceEncoder to create an Apple Prores file, it failed at the end with:

Exception in thread "Thread-0" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.rangeCheck(ArrayList.java:653)
	at java.util.ArrayList.get(ArrayList.java:429)
	at org.jcodec.codecs.h264.H264Utils.createAvcCFromPS(H264Utils.java:455)
	at org.jcodec.containers.mp4.muxer.FramesMP4MuxerTrack.setCodecPrivateIfNeeded(FramesMP4MuxerTrack.java:372)
	at org.jcodec.containers.mp4.muxer.FramesMP4MuxerTrack.finish(FramesMP4MuxerTrack.java:257)
	at org.jcodec.containers.mp4.muxer.MP4Muxer.finalizeHeader(MP4Muxer.java:139)
	at org.jcodec.containers.mp4.muxer.MP4Muxer.finish(MP4Muxer.java:120)

So I thought I first try the included Transcoder to see what I'm doing wrong, but using TranscodeMain also fails for me.

steps to reproduce:

  • checkout current code
  • mvn package -DskipTests=true (there is a failing test :-( )
  • cd target
  • Trying to encode as ProRes: java -cp jcodec-0.2.0.jar org.jcodec.api.transcode.TranscodeMain /path/to/img-%d.png -o:vc prores /path/to/myMovie.mov results in:
[INFO]	org.jcodec.containers.imgseq.ImageSequenceDemuxer.getMaxAvailableFrame (ImageSequenceDemuxer.java:143):	Max frame found: 6123
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.rangeCheck(ArrayList.java:653)
	at java.util.ArrayList.get(ArrayList.java:429)
	at org.jcodec.containers.mp4.muxer.MP4Muxer.movieHeader(MP4Muxer.java:175)
	at org.jcodec.containers.mp4.muxer.MP4Muxer.finalizeHeader(MP4Muxer.java:135)
	at org.jcodec.containers.mp4.muxer.MP4Muxer.finish(MP4Muxer.java:120)
	at org.jcodec.api.transcode.Transcoder.finishEncode(Transcoder.java:391)
	at org.jcodec.api.transcode.Transcoder.transcode(Transcoder.java:622)
	at org.jcodec.api.transcode.TranscodeMain.main(TranscodeMain.java:284)
  • Trying to encode as H.264: java -cp jcodec-0.2.0.jar org.jcodec.api.transcode.TranscodeMain /path/to/img-%d.png /path/to/myMovie.mp4 results in the same error message as above.

What am I doing wrong?

@svitvitskiy
Copy link
Collaborator

svitvitskiy commented Mar 2, 2017

Thank you for reporting. I think there are multiple issue however.

Re: adapting the SequenceEncoder to output ProRes.
Looking at the error message I think you've created video track with wrong codec. You need to locate the place where the output video track is created and check that you are passing Codec.PRORES and not Codec.H264.

Re: Transcoder problems.
I have located and fixed a couple of problems in this commit, however I can see that your problem is somewhat different. In your case the ImageSequenceDemuxer is able to find 6123 images, but none of them gets encoded into the output. I suspect the issue is with the PNG decoder. Could you send me or post somewhere a dozen of your PNGs so I can identify and fix the potential problem with my PNG decoder? Thanks!

@mrieser
Copy link
Author

mrieser commented Mar 3, 2017

Thanks for the updates, it now works!

Re: adapting SequenceEncoder to ProRes.
You were right, in one place I overlooked a H264, after changing it to Codec.PRORES it works.

Re: Transcoder.
With the latest code update it works now as well, even with the same files, so it does not seem to be a problem with the PNGs I used.

Btw: Your changes introduced a compilation error in Transcoder.java, line 264 (haha, what a coincidence), where you create a new BufferH264ES(...). I had to comment that line out in order to compile the code.

Thanks again for the changes!

@mrieser mrieser closed this as completed Mar 3, 2017
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

2 participants