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 7752381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:47:09+00:00 2026-06-01T11:47:09+00:00

This must be a very stupid question, but how does one recode with Xuggler?

  • 0

This must be a very stupid question, but how does one recode with Xuggler?
Simplified I have:

IMediaReader reader = ToolFactory.makeReader(sourceUrl);      
IMediaWriter writer = ToolFactory.makeWriter(url, reader);

MediaSegmenterWriter writerListener = new MediaSegmenterWriter();
writer.open();
while (reader.readPacket() == null)
   do {
     } 
while(false);

Now, I want to recode the file in the reader to another bitrate and resolution. How do I do that? On creating the writer I have tried to add IMediaStreams with a copy of the original coder with the necessary changes, but that does not work:

    int numStreams = reader.getContainer().getNumStreams();
    for(int i = 0; i < numStreams; i++)
    {
        final IStream stream = reader.getContainer().getStream(i);
        final IStreamCoder coder = stream.getStreamCoder();

        IStreamCoder newCoder = IStreamCoder.make(IStreamCoder.Direction.ENCODING, coder);
        if(newCoder == null ){
            continue;
        }
        writer.getContainer().addNewStream(i);

        int streams = writer.getContainer().getNumStreams();
        System.out.println("Current amount of streams in writer: " + streams);

        System.out.println("Coder: " + coder.toString());
        if (coderSetting != null && newCoder != null){
            if (newCoder.getCodecType().equals(ICodec.Type.CODEC_TYPE_VIDEO)) {
                newCoder.setWidth(320);
                newCoder.setHeight(240);                   
            } 
            IStream outputStream = writer.getContainer().getStream(i);
            outputStream.setStreamCoder(newCoder);
            newCoder.open();
          }
    }

But this just gives the same result as leaving the code out (e.g. 1920×1080 from original)

Also tried to add a listener to the writer and replace the coder, but either got an error (coder already opened_ or no effect. (on onOpen, onAddStream, onOpenCoder))

I looked for tutorials, but non seem to do this simple operation.

Any help would be REALLY appreciated!!!

  • 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-06-01T11:47:10+00:00Added an answer on June 1, 2026 at 11:47 am

    In order to resize the content as well as recode you need to create a MediaToolAdapter like:

    private static class MediaResizer extends MediaToolAdapter {
        private IVideoResampler videoResampler = null;
        private int mediaHeight;
        private int mediaWidth;
    
        public MediaResizer (int aHight, int aWidth) {
            mediaWidth = aWidth;
            mediaHeight = aHeight;
        }
    
        @Override
        public void onVideoPicture(IVideoPictureEvent event) {
            // In case of audio only, do not re-size as it is not needed
            if(job.role == MediaRole.MediaRoleEnum.LS_AUDIO) super.onVideoPicture(event);
    
            IVideoPicture pic = event.getPicture();
    
            if (videoResampler == null) {
                videoResampler = IVideoResampler.make(job.getCoderSettings().width, job.getCoderSettings().height, pic.getPixelType(), pic.getWidth(), pic.getHeight(), pic.getPixelType());
            }
    
            IVideoPicture out = IVideoPicture.make(pic.getPixelType(), mediaWidth, mediaHeight);
            videoResampler.resample(out, pic);
    
            IVideoPictureEvent asc = new VideoPictureEvent(event.getSource(), out, event.getStreamIndex());
            super.onVideoPicture(asc);
    
            out.delete();
        }
    
    }
    

    You add this as a listener to your reader, and then your writer to you resized. It should be something like:

     IMediaReader reader = ToolFactory.makeReader(sourceUrl);
     MediaResizer resizer = new MediaResizer(job);
     IMediaWriter currentWriter = ToolFactory.makeWriter(destinationDir, reader);
    
     reader.addListener(resizer);
     resizer.addListener(currentWriter);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This must be a very stupid newbie question, but I have spent my whole
This must be a really stupid question, but I'm still very green when it
this is a really stupid question but I have a deadline and I'm very
This might be a very stupid question, but I have to ask it anyway.
This may be a stupid question but how does one actually run the 'Build'
This must be a very stupid question, but I just can't get it to
This must be a stupid question, but nevertheless I find it curious: Say I
This must be a very simple question, but I don't seem to be able
This must be a very basic question for Java developers, but what is the
this must be very simple but it's monday morning.. I have a label and

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.