aiilab / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

av_interleaved_write_frame() error -22 while writing interleaved video frame #488

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Running the code at the end of the question

What is the expected output? 
All frame to be recorded

What do you see instead?
Every few frames I get this exception:

org.bytedeco.javacv.FrameRecorder$Exception: av_interleaved_write_frame() error 
-22 while writing interleaved video frame.
  at org.bytedeco.javacv.FFmpegFrameRecorder.record(FFmpegFrameRecorder.java:720)
  at org.bytedeco.javacv.FFmpegFrameRecorder.record(FFmpegFrameRecorder.java:624)
  at org.bytedeco.javacv.FrameRecorder.record(FrameRecorder.java:290)

What version of the product are you using? On what operating system?
Android 4.4.4, Nexus 5, JavaCV 0.8

Please provide any additional information below.
Hi,

I am initializing FFmpegFrameGrabber to read from a video file, recorded in the 
past using FFmpegFrameRecorder,
and I want to send this video to an rtmp server using FFmpegFrameRecorder.

So far, I was able to do it, however I do have one problem, not all of the 
frames are delivered
from the file to the server, one in a few frames cause the FFmpegFrameRecorder 
to throw the exception mentioned above.

FYI, I am rotating the video since android preview frame is 90 degrees rotated, 
using the method below.

// Reader initilization part:
FFmpegFrameGrabber mGrabber = new FFmpegFrameGrabber("path-to-file recorded 
from camera using FFMpegFrameRecorder in the past");
mGrabber.start();

// Writer initilization part:
FFmpegFrameRecorder mFrameRecorder = new 
FFmpegFrameRecorder("/sdcard/Movies/Camra/final.flv", height, width, 1);
mFrameRecorder.setFormat("flv");
mFrameRecorder.setSampleRate(videoProfile.audioSampleRate);
mFrameRecorder.setFrameRate(videoProfile.frameRate);
mFrameRecorder.setVideoBitrate(videoProfile.bitRate);
mFrameRecorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
mFrameRecorder.setVideoOption("preset", "ultrafast");
mFrameRecorder.start();

// Actual reading-writing:
Frame frame;
while ((frame = getFrame()) != null) {
    mFrameRecorder.setTimestamp(timestamp);

    if (frame.image != null) {
        frame.image = rotateImage(frame.image);
    }

    mFrameRecorder.record(frame);
}

// Rotate function:
private opencv_core.IplImage rotateImage(opencv_core.IplImage frame) {
    if (mRotation != 0) {
        opencv_core.IplImage destination;
        if (mRotation != 180) {
            if (mRotatedImage == null) {
                mRotatedImage = opencv_core.cvCreateImage(opencv_core.cvSize(frame.height(), frame.width()), frame.depth(), frame.nChannels());
            }

            destination = mRotatedImage;
            opencv_core.cvTranspose(frame, destination);
        } else {
            destination = frame;
        }

        if (mRotation == 90)
            opencv_core.cvFlip(destination, destination, 1);
        else if (mRotation == 270)
           opencv_core.cvFlip(destination, destination, 0);
        else if (mRotation == 180)
           opencv_core.cvFlip(destination, destination, -1);

        return destination;
   }

   return frame;
}

Original issue reported on code.google.com by ShukyChe...@gmail.com on 14 Oct 2014 at 9:00

GoogleCodeExporter commented 9 years ago
Could you please try again with JavaCV 0.9? 

And please report any additional issues here if possible:
https://github.com/bytedeco/javacv/issues

Thank you

Original comment by samuel.a...@gmail.com on 15 Oct 2014 at 1:09

GoogleCodeExporter commented 9 years ago
Hi Samuel,

thanks for your response, but using JavaCV 0.9 causes me this exception:

java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol 
"av_input_audio_device_next" referenced by "libjniavdevice.so"...
    at java.lang.Runtime.loadLibrary(Runtime.java:364)
    at java.lang.System.loadLibrary(System.java:526)
    at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
    at org.bytedeco.javacpp.Loader.load(Loader.java:410)
    at org.bytedeco.javacpp.Loader.load(Loader.java:353)
    at org.bytedeco.javacpp.avdevice.<clinit>(avdevice.java:18)
    at org.bytedeco.javacv.FFmpegFrameGrabber.<clinit>(FFmpegFrameGrabber.java:104)

After some searching, I ran into this 
http://stackoverflow.com/questions/25272343/javacv-on-android-unsatisfiedlinkerr
or-from-libjniavdevice-so-dlopen-failed-c
question on Stackoverflow.

Do you know how can I solve it?

Thanks

Original comment by ShukyChe...@gmail.com on 15 Oct 2014 at 2:10

GoogleCodeExporter commented 9 years ago
Move to https://github.com/bytedeco/javacv/issues/40

Original comment by ShukyChe...@gmail.com on 15 Oct 2014 at 10:42