question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FrameGrab Can't detect format of MP4 after being resized with ffmpeg

See original GitHub issue

I’m creating a program that opens an MP4 file and returns the next frame as a BufferedImage upon request (Pretty much viewing an MP4 frame by frame).

My code is working fine on my original test MP4 but if I resize that MP4 using ffmpeg i get a

org.jcodec.api.UnsupportedFormatException: Could not detect the format of the input video.
	at org.jcodec.api.FrameGrab.createFrameGrab(FrameGrab.java:55)

Resize Command:

ffmpeg -i input.mp4 -s 1280x720 output.mp4

Code:

final FileChannelWrapper wrapper = NIOUtils.readableChannel(_FILE_);
final FrameGrab grab = FrameGrab.createFrameGrab(wrapper);

I’m pretty new to jcodec and media encoding/decoding in general so I’m not sure if this is a problem with my resize command, my code, or the library.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
svitvitskiycommented, Jun 22, 2020

I am not sure, doesn’t happen on my machine.

As an alternative, try importing all jcodec, jcodec-javase, jcodec-samples into your Eclipse or IntelliJ as maven projects. Then simply run the class FrameGrabDemo.

0reactions
TheStonedTurtlecommented, Jun 22, 2020

Running mvn clean install on my clone of the repo is giving me the below test failure.

Running org.jcodec.movtool.MetadataEditorTest
[INFO]	. (:0):	Relocating movie header to the end of the file.
[INFO]	. (:0):	Relocating movie header to the end of the file.
Tests run: 5, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.133 sec <<< FAILURE!
testKeyedWriteSlow(org.jcodec.movtool.MetadataEditorTest)  Time elapsed: 0.044 sec  <<< ERROR!
java.lang.NullPointerException
	at org.jcodec.movtool.MetadataEditorTest.keyedWriteSub(MetadataEditorTest.java:82)
	at org.jcodec.movtool.MetadataEditorTest.testKeyedWriteSlow(MetadataEditorTest.java:56)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to extract 1 screenshot for a video with ffmpeg at a given ...
FFMpeg can do this by seeking to the given timestamp and extracting exactly one frame as an image, see for instance ...
Read more >
ffmpeg Documentation
In particular, codec options are applied by ffmpeg after the stream ... If it cannot, ffmpeg will abort and all output files will...
Read more >
How to Extract Images from a Video Using FFmpeg
In this tutorial, we will be using the FFmpeg command-line tool to extract images from the video below using several different commands. Your...
Read more >
Resizing videos with ffmpeg/avconv to fit into static sized player
I'm trying to use avconv to use ffmpeg to resize (while retaining the aspect ratio) and making sure it fits into my player....
Read more >
Thumbnails & Screenshots using FFmpeg - OTTVerse
Learn how to generate thumbnails and screenshots using FFmpeg's ... Let's see how! ... and store them to JPG files after resizing them?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found