LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   mencoder problem converting *.jpg to .avi (https://www.linuxquestions.org/questions/linux-software-2/mencoder-problem-converting-%2A-jpg-to-avi-322764/)

whistl 05-12-2005 10:49 AM

mencoder problem converting *.jpg to .avi
 
I am running ubuntu 5.04, and want to convert a series of JPEG snapshots taken from an internet camera into a "movie" file. The output format isn't critical - mpeg, xvid, quicktime, mjpeg - I really don't care, anything viewable from mplayer or xine is fine.

I'm trying to get mencoder to do this, since it claims it can, and while the most recent version number 1.0pre7-3.3.5 compiles and executes normally, the output movie flickers and crashes mplayer. Xine only flickers. By flicker, I mean it displays a black frame between every video frame. Doesn't seem to matter what video codec I use, the result is nearly identical.

I also tried using the mencoder deb package that is available under Ubuntu's Synaptic package manager, but that older version of mencoder crashes with Segmentation Fault when it comes time to write the output file.

Does anyone know how I can get this to work? The command line options I'm using come straight from the examples in the man page and other documents.

Or does anyone know of some other Linux package I can use to perform this task?

Thanks in advance!



Here's the command line I'm using:

/usr/local/bin/mencoder mf://*.jpg -mf type=jpg \
-ovc lavc -lavcopts vcodec=mpeg2video:aspect=4/3 \
-o Test.avi


And here's the output that command generates:

MEncoder 1.0pre7-3.3.5 (C) 2000-2005 MPlayer Team
CPU: Advanced Micro Devices Athlon 4 /Athlon MP/XP Palomino (Family: 6, Stepping: 2)
Detected cache-line size is 64 bytes
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 0
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE

File not found: 'frameno.avi'
Failed to open frameno.avi
success: format: 16 data: 0x0 - 0x0
[demuxer] mf support.
[mf] search expr: *.jpg
[mf] number of files: 36 (144)
VIDEO: [IJPG] 0x0 24bpp 25.000 fps 0.0 kbps ( 0.0 kbyte/s)
[V] filefmt:16 fourcc:0x47504A49 size:0x0 fps:25.00 ftime:=0.0400
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1 (-1=autodetect) osd: 1
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffmjpeg] vfm:ffmpeg (FFmpeg MJPEG decoder)
==========================================================================
Writing AVI header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
VDec: vo config request - 640 x 480 (preferred csp: Planar 422P)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
VDec: using Planar 422P as output csp (no 1)
Movie-Aspect is undefined - no prescaling applied.
SwScaler: reducing / aligning filtersize 1 -> 4
SwScaler: reducing / aligning filtersize 1 -> 4
SwScaler: reducing / aligning filtersize 1 -> 1
SwScaler: reducing / aligning filtersize 9 -> 8

SwScaler: BICUBIC scaler, from Planar 422P to Planar YV12 using MMX2
videocodec: libavcodec (640x480 fourcc=3267706d [mpg2])
ODML: vprp aspect is 4:3.
Pos: 1.4s 36f ( 0%) 6fps Trem: 0min 0mb A-V:0.000 [4398:0]
Flushing video frames

Writing AVI index...
Fixing AVI header...
ODML: vprp aspect is 4:3.

Video stream: 4398.500 kbit/s (549812 bps) size: 791730 bytes 1.440 secs 36 frames

m_yates 05-12-2005 11:38 AM

I'm not certain, but it may be your choice of codec. Did you try with mpeg4? As example:
Code:

/usr/local/bin/mencoder mf://*.jpg -mf w=800:h=600:fps=25:type=jpg -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o Test.avi

whistl 05-12-2005 12:38 PM

Quote:

Originally posted by m_yates
I'm not certain, but it may be your choice of codec. Did you try with mpeg4? As example:
Code:

/usr/local/bin/mencoder mf://*.jpg -mf w=800:h=600:fps=25:type=jpg -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o Test.avi

Yes, I tried other codecs. xvid, mpeg4. No difference. Flicker still there.

tencheese 05-31-2005 05:33 PM

I actually have a very similar problem. I am wanting to convert a large number of jpeg images to an AVI (or mpeg, anything, but preferably AVI) for playback on a Windows machine. But I am unable to play back any of the resulting movie files. I have also tried just about all of the output options. Usually I use the Windows machine for this process but I have more than a million jpegs in the sequence so I don't dare :)

I am using mencoder 1.0pre7 on linux-2.4.2 i586. Mencoder appeared to compile and install without problems, and the encode process throws up no errors. The resulting files have an unknown 4cc code of "FMP4" which I have not seen before and appears to be unheard of. I am using an identical command line to whistl.

whistl 06-01-2005 08:52 AM

workaround found
 
I downloaded MJPEGTOOLS (http://mjpeg.sourceforge.net), and while reading it's docs, happened to learn that the Imagemagick "convert" tool is able to convert multiple jpeg images into an MNG format movie. Xine is able to play MNG movies (MNG is to PNG what MJPEG is to JPEG), so my problem is solved.

One of my friends found an MNG codec for windows on the net somewhere, and was able to view my movie on his windows box. Sorry, but I don't know where he got it, but you can try http://www.libpng.org/pub/mng/ or just google "MNG codec windows".

pwalden 06-26-2005 01:53 PM

Somehow I think this is related to a problem with the mf://*.jpg specification.

I have nearly a 1000 jpegs.

The first 100 frames of the rendered movie seem to alternate between a the first and a blank frame, then it switches to alternating between the first and a frame much further along. As the movie progresses, the frames slowly change but always are out of order.

I have submitted a bug report.

Mencoder seems the only option at this point. I tried convert and it blew out my system with overload. MS Moviemaker, croaks with this many files too.

whistl 06-26-2005 08:58 PM

I was able to solve this problem using the ImageMagick "convert" utility and the MPEG2ENCODE utility, part of the MPEG2 reference codec, which can be downloaded from http://www.mpeg.org/ or ftp://ftp.mpegtv.com/pub/mpeg/mssg/m...dec_v12.tar.gz . It was easy to compile, and once installed, "convert" uses it with the "m2v" (mpeg2 video) type.

convert *.jpg m2v:movie.mpg

It does take a lot of resources to complete. Convert first translates every JPEG frame into YUV format (stored as temporary files in /tmp), and finally all the YUV frames are fed to mpeg2encode to create the .mpg movie file. On my AMD Sempron 2800 with 512 Mb RAM, converting 720 jpegs (640x480) to a MPEG2 movie takes 100% CPU, 1.5Gb virtual memory (it was paging like mad) and about 35 minutes clock time. I'm sure it would be a lot quicker, if I could afford a 2Gb RAM upgrade and separate SATA disk drives for the data and /tmp directories.

Good Luck!

zestychen 06-28-2005 02:42 PM

If you can read this Whistl or anyone else with experience with ImageMagick, please help.

my email is frank78 [A T} gmail.com. Help is greatly appreciated. Basically I'm stuck in a bind of not enough documentation in regards to the writing of avis. I hope to use convert too, but am always "missing a codec". How would I go about obtaining the correct AVI codec for IM?

whistl 06-29-2005 07:35 AM

Sorry, Imagemagick only has limited support for reading some AVI files, and none for writing them.

If you need AVI output, you'll have to find some other solution.

zestychen 06-29-2005 01:32 PM

Thanks for the reply.

Actually, MPEG would be just as convinient. Do you think it would be possible to get your email? I am unsure about how to proceed in terms of compiling and using the MPEG2ENCODE tool you provided. I am rather new at Unix in general and would appreciate the help.


All times are GMT -5. The time now is 08:56 AM.