Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6577241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:36:38+00:00 2026-05-25T15:36:38+00:00

i am trying to encode videos into 3gp format using xuggler, i somehow got

  • 0

i am trying to encode videos into 3gp format using xuggler, i somehow got it to work, work as in the program stopped throwing errors and exceptions, but the new file that is created does not have any video. Now there is no error or exception for me to work with so i have stuck a wall.
EDIT: Note the audio is working as it shud.

This is the code for the main function where the listeners are configured

IMediaReader reader = ToolFactory.makeReader(“/home/hp/mms/b.flv”);

    IMediaWriter writer = ToolFactory.makeWriter("/home/hp/mms/xuggle/a_converted.3gp", reader);

    IMediaDebugListener debugListener = ToolFactory.makeDebugListener();
    writer.addListener(debugListener);

    ConvertVideo convertor = new ConvertVideo(new File("/home/hp/mms/b.flv"), new File("/home/hp/mms/xuggle/a_converted.3gp"));
    // convertor.addListener(writer);
    reader.addListener(writer);
    writer.addListener(convertor);

    while (reader.readPacket() == null)
        ;

And this is the code for the convertor that i wrote.

public ConvertVideo(File inputFile, File outputFile)
{
    this.outputFile = outputFile;
    reader = ToolFactory.makeReader(inputFile.getAbsolutePath());
    reader.addListener(this);
}
private IVideoResampler videoResampler = null;
private IAudioResampler audioResampler = null;

@Override
public void onAddStream(IAddStreamEvent event)
{
    if (writer == null)
    {
        writer = ToolFactory.makeWriter(outputFile.getAbsolutePath(), reader);

    }

    int streamIndex = event.getStreamIndex();
    IStreamCoder streamCoder = event.getSource().getContainer().getStream(streamIndex).getStreamCoder();

    if (streamCoder.getCodecType() == ICodec.Type.CODEC_TYPE_AUDIO)
    {
        streamCoder.setFlag(IStreamCoder.Flags.FLAG_QSCALE, false);
        writer.addAudioStream(streamIndex, 0, 1, 8000);
    }
    else if (streamCoder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO)
    {
        streamCoder.setFlag(IStreamCoder.Flags.FLAG_QSCALE, false);
        streamCoder.setCodec(ICodec.findEncodingCodecByName("h263"));
        writer.addVideoStream(streamIndex, 0, VIDEO_WIDTH, VIDEO_HEIGHT);

    }
    super.onAddStream(event);
}

// //
@Override
public void onVideoPicture(IVideoPictureEvent event)
{
    IVideoPicture pic = event.getPicture();
    if (videoResampler == null)
    {
        videoResampler = IVideoResampler.make(VIDEO_WIDTH, VIDEO_HEIGHT, pic.getPixelType(), pic.getWidth(), pic.getHeight(), pic.getPixelType());
    }
    IVideoPicture out = IVideoPicture.make(pic.getPixelType(), VIDEO_WIDTH, VIDEO_HEIGHT);
    videoResampler.resample(out, pic);

    IVideoPictureEvent asc = new VideoPictureEvent(event.getSource(), out, event.getStreamIndex());
    super.onVideoPicture(asc);
    out.delete();
}

@Override
public void onAudioSamples(IAudioSamplesEvent event)
{
    IAudioSamples samples = event.getAudioSamples();
    if (audioResampler == null)
    {
        audioResampler = IAudioResampler.make(1, samples.getChannels(), 8000, samples.getSampleRate());
    }
    if (event.getAudioSamples().getNumSamples() > 0)
    {
        IAudioSamples out = IAudioSamples.make(samples.getNumSamples(), samples.getChannels());
        audioResampler.resample(out, samples, samples.getNumSamples());

        AudioSamplesEvent asc = new AudioSamplesEvent(event.getSource(), out, event.getStreamIndex());
        super.onAudioSamples(asc);
        out.delete();
    }
}

I just cant seem to figure out where the problem is. I wud be thankful if someone wud plz point me in the right direction.

EDIT: If i see the properties of my newly encoded video, its audio properties are set and its video properties are not i.e in video properties, dimension= 0 x 0, frame rate= N/A and codec= h.263. The problem here is the 0 x 0 dimension.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:36:38+00:00Added an answer on May 25, 2026 at 3:36 pm

    well i found the answer, well not exactly the answer but a way to do what i was doing. Right now i am not quiet sure why my code was not working but the hre u can find the solution that worked for me. the author here just makes a seperate resizer class, adds it as a listener to the reader,. It has the onPictureEvent method overridden. Then he makes another class MyVideoListener and overrides the onAddStream method and adds it as a listener to the writer. and then he links the two parts by adding writer as a listener to resizer. works like a a charm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to encode some denotational semantics into Agda based on a program I
I'm trying to encode a URL using the HttpUtility.UrlEncode() method, why am I getting
Weve recently been trying to work on an application that uses pandastream to encode
I am trying to encode an array which contains floats and NaN into JSON
I am trying to encode a video from raw YUV to MPEG-2 using the
I'm trying to encode a simple hierarchy in my records, but I'm running into
I'm trying to encode and upload two (or more) images from Flash using JPGEncoder.
I'm trying to create simple application with Xuggler, which has to encode sequence of
I'm trying to get ffmpeg to encode several individual JPEG images into a video
I have several videos that I am trying to process using OpenCV and Qt

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.