Solved

convert ppm to Mplayer

Posted on 2004-08-21
30
396 Views
Last Modified: 2011-09-20
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

 
0
Comment
Question by:lanya
  • 15
  • 12
  • 3
30 Comments
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11860214
Do you want to generate a slide show?
0
 

Author Comment

by:lanya
ID: 11860565
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
 
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11860609
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.
0
 

Author Comment

by:lanya
ID: 11860640
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
 
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11860779
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.
0
 

Author Comment

by:lanya
ID: 11860875
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

 
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11861122
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.
0
 

Author Comment

by:lanya
ID: 11865731
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



0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11865834
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).
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11865929
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).
0
 
LVL 32

Expert Comment

by:ldbkutty
ID: 11869162
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 ...




0
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 500 total points
ID: 11869218
You have a problem with your xargs command. Try to do just a 'cat' command (ignore any potential problems with the order of the files for now):

cat output* | ppmtoy4m -F 25:1 | mpeg2enc -f2 -o ep.m1v

Does this work?
0
 

Author Comment

by:lanya
ID: 11869357
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
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11869510
Are you sure that your PPM files are correct? How did you create them?
0
 

Author Comment

by:lanya
ID: 11869596
actually the ppm images were given to me from an experimentation dept..
i am sure the ppm images are correct
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11869652
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?
0
 

Author Comment

by:lanya
ID: 11869678
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
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11870439
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

0
 
LVL 32

Expert Comment

by:ldbkutty
ID: 11875686
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...
0
 
LVL 32

Expert Comment

by:ldbkutty
ID: 11875822
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.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11875975
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?
0
 

Author Comment

by:lanya
ID: 11879714
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
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11879853
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

0
 

Author Comment

by:lanya
ID: 11880091

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

0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11880195
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.
0
 

Author Comment

by:lanya
ID: 11880557

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
 


0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11880730
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.
0
 

Author Comment

by:lanya
ID: 11886288
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 :-)
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11887549
So what was the problem?
0
 

Author Comment

by:lanya
ID: 11890086
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 :-)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now