View Full Version : Image encoding with MPlayer and X264
sword_zero001
8th August 2010, 19:26
Hello, I'm trying to use these programs to encode an image sequence, I' using this command:
mencoder mf://*.png -mf fps=25 -vf scale=640 360,harddup -ovc x264 -x264encopts threads=auto:frameref=5:bframes=0:nob_pyramid:nob_adapt:direct_pred=auto:subq=6:mixed_refs:nodct_decimate:no_psnr -nosound -ofps 25 -noskip -of rawvideo -o output.264
It encodes the images but it gives me a video in whick a frame repeats itself through the video (it alternates between the normal video and another frame from the begginning).
Also I would like to know how to make the encoding lossless.
Thanks in advance.
nm
10th August 2010, 13:52
Hello, I'm trying to use these programs to encode an image sequence, I' using this command:
mencoder mf://*.png -mf fps=25 -vf scale=640 360,harddup -ovc x264 -x264encopts threads=auto:frameref=5:bframes=0:nob_pyramid:nob_adapt:direct_pred=auto:subq=6:mixed_refs:nodct_decimate:no_psnr -nosound -ofps 25 -noskip -of rawvideo -o output.264
You are missing a colon in the scale filter parameters. Should be: -vf scale=640:360,harddup
There could also be a problem in the naming of your PNG files, so that they are not sorted in the proper order by the * wildcard. What naming convention are you using?
The libx264 version that your MEncoder binary uses is old since nob_pyramid is accepted. Nowadays it requires a parameter (none, normal, strict). Your x264 settings seem a bit random too. Recent MEncoder versions support x264 presets and tunings, which make rational choices easier.
Also I would like to know how to make the encoding lossless.
-x264encopts crf=0, but it won't be entirely lossless for PNG input since x264 doesn't support encoding in RGB colorspaces, so MEncoder will convert RGB to YV12 first.
sword_zero001
15th August 2010, 05:37
Sorry about my late reply (I was on a travel), the colon didn't do anything but changing the names from (0,1,...,10,etc) to (000,001,...,010) worked.
The second part where you tell me something about parameters I don't get anything except that my software is old.
And finally would it be lossless if I use another type of image? Like TGA, TIFF, etc. Or with another software?
Thanks for the help.
nm
15th August 2010, 12:25
Sorry about my late reply (I was on a travel), the colon didn't do anything
Well, at least it fixed your filtering chain.
The second part where you tell me something about parameters I don't get anything except that my software is old.
That, and you should use x264 presets instead of all those parameters.
And finally would it be lossless if I use another type of image? Like TGA, TIFF, etc. Or with another software?
Completely lossless conversion from RGB images to H.264 is simply not possible with current x264. Some commercial encoders may support the necessary colorspace, but you'd also need a compatible decoder.
What's the purpose of your encodes? Do you really need RGB or is the video converted to YV12 anyway at some point?
If you are keeping the original images and the H.264 stream is only used as a mezzanine file for simple editing/re-encoding, YV12 may be fine.
If you want to delete the original files after putting them to a single video file, use a lossless format that supports RGB.
Huffyuv, FFV1 and Ut are popular free alternatives. Lagarith is also common on Windows, but there have been some issues with it.
sword_zero001
15th August 2010, 19:17
What I want to do is this I have a Video and I want to cut a piece which I would edit like PNGs then encode it again and join it with the original video.
I'm awful with command line parameters (I found one on the web and then edited it until it worked for me), What parameters should I use with the updated x264 and mencoder?
nm
16th August 2010, 01:36
What I want to do is this I have a Video and I want to cut a piece which I would edit like PNGs then encode it again and join it with the original video.
What is the colorspace of the source video? That determines what is the ideal way to edit the video. Converting YV12 to RGB and then back to YV12 isn't the best idea unless the editing operations can only be done in RGB colorspace because of software limitations.
How are you going to join the H.264-encoded sequence to the original video? Encode everything to lossless H.264 and then concatenate?
I'm awful with command line parameters (I found one on the web and then edited it until it worked for me), What parameters should I use with the updated x264 and mencoder?
For a quick lossless encode, maybe something like this:
-x264encopts preset=faster:tune=film:threads=auto:crf=0
sword_zero001
16th August 2010, 18:42
What is the colorspace of the source video? That determines what is the ideal way to edit the video. Converting YV12 to RGB and then back to YV12 isn't the best idea unless the editing operations can only be done in RGB colorspace because of software limitations.
Now that I think about it I don't NEED the whole lossless thing is more like I wanted to know how to do it. I can just cut from a point where the angle changes. And save the modified part with high quality.
How are you going to join the H.264-encoded sequence to the original video? Encode everything to lossless H.264 and then concatenate?
I'm joining it with the method here (http://forum.videohelp.com/threads/311380-MP4-with-H264-AAC-cutting-and-replacing-frames?p=1922437&mode=linear#post1922437), haven't tried it though.
For a quick lossless encode, maybe something like this:
-x264encopts preset=faster:tune=film:threads=auto:crf=0
About that I thought you meant that my code for image encoding was unnecesarely long not the one for lossless coding. I used this one for lossless coding though it's x264 not mencoder. x264.exe -q0 -m1 --output "output.mp4" "input.avi"
nm
16th August 2010, 22:15
I'm joining it with the method here (http://forum.videohelp.com/threads/311380-MP4-with-H264-AAC-cutting-and-replacing-frames?p=1922437&mode=linear#post1922437), haven't tried it though.
That should work in principle, but there may be some settings that shouldn't be changed in the middle of playback. Otherwise some decoders may get confused. I'd try to match the encoding settings of the source or re-encode everything.
About that I thought you meant that my code for image encoding was unnecesarely long not the one for lossless coding. I used this one for lossless coding though it's x264 not mencoder. x264.exe -q0 -m1 --output "output.mp4" "input.avi"
I was talking about your image encoding command line, obviously, since I haven't seen the other one before. Here's a lossy-but-high-quality example with slower settings:
-x264encopts preset=slower:tune=film:threads=auto:crf=18
sword_zero001
17th August 2010, 04:14
As I said before I'm really bad at command line, from what I understand to get a 640x360 25fps video from the images I use this:
mencoder mf://*.png -mf fps=25 -vf scale=640:360,harddup -ovc x264 -x264encopts preset=slower:tune=film:threads=auto:crf=18 -nosound -ofps 25 -noskip -of rawvideo -o output.264
nm
17th August 2010, 10:40
As I said before I'm really bad at command line, from what I understand to get a 640x360 25fps video from the images I use this:
mencoder mf://*.png -mf fps=25 -vf scale=640:360,harddup -ovc x264 -x264encopts preset=slower:tune=film:threads=auto:crf=18 -nosound -ofps 25 -noskip -of rawvideo -o output.264
Yes, that looks ok.
sword_zero001
17th August 2010, 22:06
I get this error message:
VDec: vo config request - 640 x 360 (preferred colorspace: RGB 24-bit)
VDec: using RGB 24-bit as output csp (no 5)
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 rgb24 to yuv420p using MMX2
SwScaler: using 4-tap MMX scaler for horizontal luminance scaling
SwScaler: using 4-tap MMX scaler for horizontal chrominance scaling
SwScaler: using 1-tap MMX "scaler" for vertical scaling (YV12 like)
SwScaler: 640x360 -> 640x360
FATAL: Cannot initialize video driver.
Exiting...
nm
17th August 2010, 22:16
The actual error message is before that, in the first lines of output if it's about the x264 parameters as I suspect.
It probably says that one of the parameters in x264encopts is not valid. You need a very fresh MEncoder SVN (from July or August) and a recent libx264 to use the presets through MEncoder.
sword_zero001
17th August 2010, 22:40
Okay, I made a mistake, that error message is from the old x264, the new one worked though as you said it's pretty slow.
Thanks for everything
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.