Unable to convert QVGA video file into QCIF

85 views
Skip to first unread message

Amit

unread,
Jun 30, 2009, 9:16:15 AM6/30/09
to xuggler-users
Hi,

I am trying to convert the QVGA video file format into QCIF by
setting

IStreamCoder.setProperty("s","qcif");

but it didnt see any difference.

any idea, how can i achieve this?

amit

Art Clarke

unread,
Jun 30, 2009, 12:26:15 PM6/30/09
to xuggle...@googlegroups.com
We don't support the FFMPEG.c frame-size aliases (they are ffmpeg.exe options, not libav options if you want to know why).  Instead, you need to set the frame-size on each IStreamCoder (setWidth/setHeight) yourself.

- Art
--
http://www.xuggle.com/
xu‧ggle (zŭ' gl) v. To freely encode, decode, and experience audio and video.

Use Xuggle to get the power of FFMPEG in Java.

Amit

unread,
Jul 1, 2009, 3:44:12 AM7/1/09
to xuggler-users
Hi,

I have already tried the same earlier, I set the height and width of
the encoder as 144 x 176.

but it throws an WARN "picture is not of the same width as this
coder" and subsequently throws an error "Cannot write incomplete
packet".

and when i set the dimensions of IVideoPicture as 176x144 then again
it doesn't reflect any difference.





On Jun 30, 9:26 pm, Art Clarke <acla...@xuggle.com> wrote:
> We don't support the FFMPEG.c frame-size aliases (they are ffmpeg.exe
> options, not libav options if you want to know why).  Instead, you need to
> set the frame-size on each IStreamCoder (setWidth/setHeight) yourself.
>
> - Art
>
>
>
> On Tue, Jun 30, 2009 at 6:16 AM, Amit <amitajma...@gmail.com> wrote:
>
> > Hi,
>
> > I am trying to convert the QVGA video file format into QCIF by
> > setting
>
> > IStreamCoder.setProperty("s","qcif");
>
> > but it didnt see any difference.
>
> > any idea, how can i achieve this?
>
> > amit
>
> --http://www.xuggle.com/

Art Clarke

unread,
Jul 1, 2009, 10:10:44 AM7/1/09
to xuggle...@googlegroups.com
You need to call setComplete() on the IVideoPicture before passing it to encode.  This can either be done by using IStreamCoder.decodeVideo(...) to decode a packet into an IVideoPicture or you need to call it yourself.  Make sure you do that.

- Art
--

Amit

unread,
Jul 2, 2009, 3:06:45 AM7/2/09
to xuggler-users
Hi,

right now i am going through two different issues
1.) changing the resolution
2.) changing the format of picture

and both the above task can be done once i decode an incoming video
packet into an IVideoPicture, this pic contains the raw data of same
format. so far there is no issue with that.

now
1.) regarding changing the resolution from QVGA to QCIF

i tried the below code snippet,

IVideoPicture newPict = IVideoPicture.make(IPixelFormat.Type.YUV420P,
176, 144);
newPict.copy(pic);
newPict.setComplete(true, IPixelFormat.Type.YUV420P, 176, 144, 0);
outStreamCoder.encodeVideo(packet, newPict, 0)

but it gives me an error

12:17:01.875 [main] DEBUG com.xuggle.xuggler - error: width does not
match (../../../../../../../csrc/com/xuggle/xuggler/VideoPicture.cpp:
298)
12:17:01.875 [main] ERROR org.ffmpeg - [mpeg4 @ 0x2d31200] Error,
Invalid timestamp=0, last=0
Unable to encode into low resolution
12:17:01.875 [main] ERROR com.xuggle.xuggler - Error: cannot write
incomplete packet (../../../../../../../csrc/com/xuggle/xuggler/
Container.cpp:584)


2.) Regarding changing the format, i applied the below approach

i make another IvideoPicture of type RGB24 and put the raw picture
data (got after decoding the incoming video packet).
afterwards i called setComplete method.

you can see the step i followed, from the below code snippet

IVideoPicture jpegPict = IVideoPicture.make(IPixelFormat.Type.RGB24,
videoCoder.getWidth(),videoCoder.getHeight());
byte[] rawData = new byte[pic.getSize()]; //pic is a IvideoPicture
decoded from incoming video packet, contains data of type YUV420P
pic.get(0, rawData, 0, pic.getSize());
jpegPict.put(rawData, 0, 0, rawData.length);

jpegPict.setComplete(true, IPixelFormat.Type.RGB24,videoCoder.getWidth
(), videoCoder.getHeight(),timeStamp);

byte[] jpegPicture = jpegPict.getData().getByteArray(0,jpegPict.getSize
());
try {
File f = new File("samplejpeg.jpg");
FileOutputStream fileOutputStream = new FileOutputStream(
fileOutputStream.write(jpegPicture);
fileOutputStream.flush();
} catch (IOException e) { //
e.printStackTrace();
}

It does produce a jpg image, but could not open with any picture
viewer.

any comments on both issues.


also can you explain the IVideoPicture.put() and IVideoPicture.get()
method signature.


i have put my source code here for your ref.

http://pastebin.com/m381006ed

Amit

unread,
Jul 2, 2009, 7:53:35 AM7/2/09
to xuggler-users
hi,

my second issue (changing format and creating images)
solved ......wow .. :)

now only first one is left ...changing resolution from QVGA to
QCIF ...

any suggestion on this ...

Amit

unread,
Jul 2, 2009, 8:54:52 AM7/2/09
to xuggler-users
hi,

regarding changing the format i used IVideoResampler and then called
an Iconverter.toImage() method. this gives me the desired image.

like below

IVideoResampler resampler = IVideoResampler.make(videoCoder.getWidth
(),
videoCoder.getHeight(),
IPixelFormat.Type.BGR24, videoCoder.getWidth(),
videoCoder.getHeight(), IPixelFormat.Type.YUV420P);


IVideoPicture newBgrPict = IVideoPicture.make
(IPixelFormat.Type.BGR24, videoCoder.getWidth(),videoCoder.getHeight
());

resampler.resample(newBgrPict, pic);

IConverter converter = ConverterFactory.createConverter
(ConverterFactory.XUGGLER_BGR_24, newBgrPict);


BufferedImage bufferedImage = converter.toImage(newBgrPict);


System.out.println("buffered image created ");


Now i try to scale down the output picture into (176 * 144). I set the
height and width in the resampler and newBgrPict.

then i checked after resample, either newBgrPict is complete or not,
if it is not then i called

newBgrPict.setComplete(true, IPixelFormat.Type.BGR24, 176,144,
pic.getTimeStamp());

here again i got the same exception as before : "the picture is not
complete".


Every image has a definite pixel pattern. how could an image
resolution can be compressed by only copying it into another
IVideoPicture and setting its new dimension?

there must be some other way around to change the resolution of an
image.

what you say?




resolution

Art Clarke

unread,
Jul 2, 2009, 2:30:45 PM7/2/09
to xuggle...@googlegroups.com
Sorry Amit, but I'm having real toubble following everything here (you're moving much faster than I can keep up given that your source keeps changing).

But given that you worked around your original problem, you may want to try changing your resolution by creating a second IVideoResampler object and asking it to resample from QVGA to QCIF (i.e. don't use the ConverterFactory stuff).

Alternately you can ask the IVideoResample to resample colorspace and resize at the same time, but for some color-spaces there is a bug in FFmpeg that causes weird artifacts to occur.  Try that first though, and only if it doesn't work, set up two IVideoResample objects.

- Art
--
http://www.xuggle.com/
xu‧ggle (zŭ' gl) v. To freely encode, decode, and experience audio and video.

Use Xuggle to get the power of FFmpeg in Java.

Amit

unread,
Jul 3, 2009, 5:41:28 AM7/3/09
to xuggler-users
hi,

As soon i pass on width and height of output picture different from
the source picture in IVideoResampler, it throws an exception
even i have kept the format of the output picture same as source
picture.

IVideoResampler resampler = IVideoResampler.make(176,
144,IPixelFormat.Type.YUV420P,
videoCoder.getWidth
(),videoCoder.getHeight(),IPixelFormat.Type.YUV420P);

//videoCoder returns Height and Width as 240 * 320

IVideoPicture newPict = IVideoPicture.make(IPixelFormat.Type.YUV420P,
videoCoder.getWidth(),
videoCoder.getHeight());

if (resampler.resample(newPict, pic) < 0)
System.out.println("Resampling for changing resolution of (QVGA) YUV
picture into (QCIF) is not done");


if(!newPict.isComplete())
newPict.setComplete(true, IPixelFormat.Type.YUV420P, 176,144,
pic.getTimeStamp());


Any suggestions, how can i change the height and width of the output
picture, keeping the same format (YUV420P) ?
> Use Xuggle to get the power of FFmpeg in Java.

Art Clarke

unread,
Jul 3, 2009, 8:29:56 AM7/3/09
to xuggle...@googlegroups.com
What does the log message say when it fails to resample?  And are you using Xuggler 3.0?
--

Amit

unread,
Jul 3, 2009, 8:52:56 AM7/3/09
to xuggler-users
hi,

it gives below errors

18:21:34.046 [main] DEBUG com.xuggle.xuggler - error: output frame
height does not match expected value (../../../../../../../csrc/com/
xuggle/xuggler/VideoResampler.cpp:160)
Resampling of YuV format into bgr is not done
18:21:34.046 [main] DEBUG com.xuggle.xuggler - error: width does not
match (../../../../../../../csrc/com/xuggle/xuggler/VideoPicture.cpp:
298)
> Use Xuggle...
>
> read more »

Amit

unread,
Jul 3, 2009, 8:55:28 AM7/3/09
to xuggler-users
hi,

i m using xuggler 3.0.660.0
> ...
>
> read more »

Art Clarke

unread,
Jul 3, 2009, 1:55:48 PM7/3/09
to xuggle...@googlegroups.com
See the sample code I just sent in the other thread, and follow the rules I outlined there.

- Art
--
Reply all
Reply to author
Forward
0 new messages