Link to home
Start Free TrialLog in
Avatar of lanya
lanya

asked on

convert ppm to Mplayer

Hello experts

  i would like to get help regarding the ppm input images to Mplayer in linux.
How can i convert the ppm images of size 768*576 into mpeg2 or dvd or any acceptable format  by Mplayer(video player) without scaling the images.
please suggest me what format can be used and how it can be used.

please inform me if i am not clear in my problem definition

Thanx in advance

 
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

Do you want to generate a slide show?
Avatar of lanya
lanya

ASKER

Dear Experts

 i would like to show the changes in all the ppm output images each of which is of size 768*576
in a single video...
i have  concatenated all the output files from a directory and used "ppmtoy4m"  command.
please inform me if i should give more details.

thanx in advance
 
lanya, I still don't understand what you want to do. So it's not a slide show? Do you want to combine a number of PPM images into a movie (e.g. 300 images for a 10 second movie with 30 images per second)? Please provide more details.
Avatar of lanya

ASKER

Dear Expert
yeah..its correct.....i need to combine a number may be around 900 ppm images into a single movie.

i have used "cat"  command to combine all my output images from a directory and used "ppmtoy4m"

as u have said i need to combine this 900 images each of which is of size 768*576 into a single movie without scaling...please inform me if i am not still proper in defining my problem.

thanx for ur patience
 
OK, this makes it clear.
You've done the first step, and ended up with a y4m encoded file, which is not yet a MPEG file. You need to run mpeg2enc (or a similar encoder):

cat *.ppm | ppmtoy4m | mpeg2enc -o output.mpg

This will use the defaults for all mpeg2enc settings, and will therefore produce a MPEG1 file, which can be played by mplayer.

You may not have mpeg2enc (some distributions don't provide this for licensing reasons - SuSE 9.1 does for example not come with it). Let me know if you need any pointers to locate mpeg2enc for your distribution.
Avatar of lanya

ASKER

Dear Expert
thanks for earliest responses..
i have tried with executing the above command "mpeg2enc -f 8  -o output.m1v" instead of output.mpg...
one more problem is since the ppm is 768*576 size,there is some error like the horizontal size is more than the DVD format in Mplayer.
i would like to get output movie without any scaling format to the original image. or is there any other format which suits this image size into video player...

please inform me if more details is necessary

thanks for ur patience

 
with "-f 8" you specify that you want output in DVD format. Use one of the generic formats (e.g. 0 for generic MPEG1 or 3 for generic MPEG2). mplayer should not care about the size of the images.
Avatar of lanya

ASKER

Khkremer
  i tried for generic formats instead of dvd. but i still have some problems.i dont know how ro solve this problem
ERROR:  generic format must specify bit rate ...
could you kindly help me how should i use the generic formats and overcome this problem
if possible please reply me soon....

inform me if i am not clear in explaining my problem



MPEG2 limits the size to 720x576 pixels, so you cannot create a MPEG2 movie (sorry for not noticing this earlier). You can however create a MPEG1 encoded movie by using -f 0
I don't have mplayer, so I cannot verify that the movie can actually be played with it, but it works without any problems with Quicktime (on a Mac).
I just verified that a movie created from ppm images with a size of 768x576 pixels will work with mplayer (I used -f 0 to encode the y4v stream).
Khkremer
  i just tried now for the movie using
    ls -1 output* | sort | xargs -n1 ppmtoy4m -F 25:1 | mpeg2enc -f 0 -o ep.m1v
 
but i am not able to produce movie .
       ++ WARN: Error reading frame header (1): codeparameter out of range!  
      xargs: ppmtoy4m: terminated by signal 13  

could you kindly suggest me how to do with this problem .
thanks for ur patience and ur replies
please help me out ...




ASKER CERTIFIED SOLUTION
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lanya

ASKER

Khkremer
sorry for disturbing you again and again...

    cat output* | ppmtoy4m -F 25:1 | mpeg2enc -f2 -o ep.m1v
 i have raw bad ppm magic number error....
 
thanks for ur patience
Are you sure that your PPM files are correct? How did you create them?
Avatar of lanya

ASKER

actually the ppm images were given to me from an experimentation dept..
i am sure the ppm images are correct
What do you get when you run this command:
file output*

This will try to detect the file format for all your output files. Are there any files in this directory that start with output, but are not PPM files?
Avatar of lanya

ASKER

when i executed  file output*   it started with ppm images only

output00000.ppm: PPM "rawbits" image data
output00001.ppm: PPM "rawbits" image data
output00002.ppm: PPM "rawbits" image data
output00003.ppm: PPM "rawbits" image data
output00004.ppm: PPM "rawbits" image data
Do you get any other file format when you run this command. I understand that you have many images, so it's probably not feasible to manually check the output. Try this instead:

file output* | grep -v rawbits

This will print all files that do not contain the term rawbits

Khkremer
  i used the command u have specified to check the files...
the files are all in "rawbits" image data..
what could be wrong for bad ppm magic number error?

thank you very much for ur kind patience and for all replies...
Dear Mods and khkremer,

Again Confusion as I said in the CS post. I assure not to repeat this problem again.

If you still feel this is a multiple account, my friend 'lanya' has no objection to close her account.

I hope EE will not go for that option, as there is no need for me to have a new account while i already have unlimited points.

Thanks for understanding.

 - ldbkutty.
I'll just continue to work on this problem until a moderator tells me otherwise. From your post in CS, I figure we can do this in German :-)

But let's get back to the question: There is something strange going on: If you only have valid PPM images, you should not run into this error. Let's try with a much smaller subset of images:
Try to process only ten images to determine if the problem is due to invalid images, or something else:

cat output0000?.ppm | ppmtoy4m -F 25:1 | mpeg2enc -f2 -o ep.m1v

This will process all images from 0 to 9. Does this also produce the error?

What happens when you run this command:

cat output*ppm > all_ppms.dat
Do you get an error message about a too long command line?
Avatar of lanya

ASKER

Khkremer

i have tried with ten ppm images ...when executing cat output0000?.ppm ,there is no problem.but when piped to ppmtoy4m it generates "bad raw ppm magic"

and when executing cat output*ppm >all_ppms.dat
there is no error message generated..

what could be done with this error? please help me out
thanks for ur patience
What Linux system are you running? Did the ppmtoy4m version you are using come with your distribution, or did you compile and install it yourself? Which version of ppmtoy4m are you using?

We are looking at two potential problems:
Your ppmtoy4m cannot handle your PPM files
One or more or your PPM files are bad, but do contain the correct header (which means that 'file' fill recognize them as PPMs)

What happens when you use just one PPM file?
cat output00000.ppm | ppmtoy4m -F 25:1 | mpeg2enc -f2 -o ep.m1v

Avatar of lanya

ASKER


when executed with one ppm image then there is no error for bad raw ppm magic..!!!

  and size of one ppm is 1322514
  and the one in ep(mplayer) is 29778.is this correct to have different size?

i am working with
 suse linux 2.4.22m

and i really dont know which version of ppmtoy4m is used in my working place...
thanks for ur patience

WHich version of SuSE is that (e.g. 8.0, 8.1,9.0, 9.1)?

Let's try this now with two images:

cat output0000[01].ppm | ppmtoy4m -F 25:1 | mpeg2enc -f2 -o ep.m1v

The size difference is OK, because the images will be compressed when you run mpeg2enc. They are uncompressed in the PPM format.
Avatar of lanya

ASKER


when executed with two images there is no error for bad ppm magic...

linux kernel is 2.4.22m
and the version of SuSe is 7.2
thanks for ur patience
 


This is a fairly old version of SuSE. I have to do some "software archeology" to find out what version of the mpegtools this came with.

Now that we know that it works for two images, try to add more and more images to see if you can find out which image causes the problem. My next attempt would be to try with four images:

cat output0000[0123].ppm | ppmtoy4m -F 25:1 | mpeg2enc -f2 -o ep.m1v

... and then with 8 ... and whenever you come to the point that it reports the error, try to do a binary search to pinpoint the image that causes the problem.
Avatar of lanya

ASKER

khkremer
  thanks for your wonderful help so far...with your idea to check each and every image and with my colleagues help, i figured out the problem....
thanks for ur patience and quickest responses :-)
So what was the problem?
Avatar of lanya

ASKER

Khkremer
  the problem was with my ppm images....
we found that there was an extra pixel added up in one ppm image and which when used for concatenation to next image made all these problems .it was not able to recognise the pictures as ppm image ....

as u pointed out that there is mistake:
     Your ppmtoy4m cannot handle your PPM files
     One or more or your PPM files are bad, but do contain the correct header (which means that 'file' fill recognize them as PPMs)
  helped to figure out this problem
thank you once again for ur patience and best and quick responses :-)