H264 transcoding to mjpeg

215 views
Skip to first unread message

Gogo

unread,
Nov 4, 2009, 10:17:35 AM11/4/09
to xuggler-users
Hi

I need to transcode a H264 encoded file into mjpeg file.

For achieving the desired two layers will be involved in my
application because of design constraint and both layers are
independent.
1. Firsty I am extracting a video packet from container and ultimately
video raw data from packet.
2. Resampling raw data into jpeg image using xuggler.

I am first reading a h264 encoded file using container.readNextPacket
(IPacket packet) in a loop. In each iteration I am retrieving data
residing in packet using packet.getData(). After getting data from
each packet, data is being converted into a IPacket first and then
into IVideoPicture. For this conversion I need a decoder. Decoder is
intialized in the following manner:

IStreamCoder decoder = IStreamCoder.make(Direction.DECODING);

decoder.setCodec(ICodec.findDecodingCodec(ICodec.ID.CODEC_ID_H264));
// set other params

if (decoder.open() < 0) {
System.out.println("Unable to open an coder");
}


The issue I am getting is ERROR org.ffmpeg - [h264 @ 0xb608ea0] no
frame!

But if I use decoder retrieved from container I am able to transcode
files successfully.

I have uploaded my files on pastebin. Gven below is url of files being
uploaded:
Transcoder.java :- http://pastebin.com/m7cb4c33b
Resampler.java :- http://pastebin.com/m3b29a12d
MultipartGenerator.java :- http://pastebin.com/m28181c33
VideoPacket.java :- http://pastebin.com/d495bcca0

Main class is Transcoder.java. File path of input video file and
transcoded file can be changed in Transcoder.java. Variable having
source file path is named SRC_FILE_PATH and target file path is name
DEST_FILE_PATH.

Where I am doing wrong. Is it in initializing IStreamCoder or there is
some flaw in my approach?

Thanks
Gogo



Art Clarke

unread,
Nov 4, 2009, 11:11:40 AM11/4/09
to xuggle...@googlegroups.com
Hi Gogo,

Your problem is probably in initializing the StreamCoder on its own; when decoding the container sets up lots of extra data on the coder.  I haven't explicitly tried decoding H264 without a container myself, but I imagine you'd need at least the parameter sets (exposed as IStreamCoder.getExtraData()).

If you can remove the need to keep the container separate from the stream coder your job gets easier; otherwise start trying the different parameters settings on the IStreamCoder and/or start getting familiar with the IStreamCoder code (and the corresponding AVCodecContext it wraps in FFmpeg).

Hope that helps,

- 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.
Reply all
Reply to author
Forward
0 new messages