Mencoder lame errors, and mpeg to avi batch process
The Set Up: I'm running Ubuntu Gutsy, 7.10, and I've got mencoder, ffmpeg, and have installed every codec I can think of (Specifics listed below). I have a Sony HD video camera which writes everything in an uncompressed MPEG format. The camera connects by USB and behaves like an external hard disk - no need for DV capture utilities, just simple file transfers. The frame rate of the files is 30fps, and the size can be either 720X480, or 640X480. The video camera splits video at the 2 GB mark. I'm not sure of the exact megabyte to time ratio, but usually a 40 minute to an hour recording will result in two files, the first being exactly 2 GB, and the second a little over 1 GB. The Goals: What I want to do is store these recordings in a smaller more manageable format, like AVI. Ideally, what I'd like to do is: 1. Append the files together. They are always numbered like so: m2u00066.mpg, m2u00067.mpg, m2u00068.mpg. So, assuming that I want to merge all videos in a directory, append them in order of file number. 2. De-interlace. 3. Save in a reasonably high quality but smaller format, like an AVI. I understand that smaller file format equals some quality loss, but I don't need to preserve original quality, I just need a result that is clear. What I've Done: I found this script, mpg2avi, which uses mencoder to make the conversion. The results are an avi file of acceptable quality. http://www.linuxquestions.org/linux/answers/Applications_GUI_Multimedia/Batc... The problems: 1. Despite having lame installed, it keeps giving an audio codec not found error (reproduced below). 2. Does not seem to handle the 720X480 size. 3. I don't think it deinterlaces the video. 4. Has no option to append videos together. The question: Can these errors be resolved, and then the de-interlacing and appending functions added? Thank you for any advice. - - - - - Here are the errors I am seeing: MEncoder 2:1.0~rc2-0ubuntu1~gutsy1 (C) 2000-2007 MPlayer Team CPU: Intel(R) Pentium(R) D CPU 2.80GHz (Family: 15, Model: 6, Stepping: 2) CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1 Compiled with runtime CPU detection. success: format: 0 data: 0x0 - 0x7dc70000 MPEG-PS file format detected. VIDEO: MPEG2 720x480 (aspect 3) 29.970 fps 9100.0 kbps (1137.5 kbyte/s) [V] filefmt:2 fourcc:0x10000002 size:720x480 fps:29.97 ftime:=0.0334 ========================================================================== Opening audio decoder: [liba52] AC3 decoding with liba52 Using SSE optimized IMDCT transform Using MMX optimized resampler AUDIO: 48000 Hz, 2 ch, s16le, 448.0 kbit/29.17% (ratio: 56000->192000) Selected audio codec: [a52] afm: liba52 (AC3-liba52) ========================================================================== Opening video filter: [expand osd=1] Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1 Opening video filter: [scale w=740 h=480] ========================================================================== Opening video decoder: [mpegpes] MPEG 1/2 Video passthrough VDec: vo config request - 720 x 480 (preferred colorspace: Mpeg PES) The selected video_out device is incompatible with this codec. Try appending the scale filter to your filter list, e.g. -vf spp,scale instead of -vf spp. VDecoder init failed :( Opening video decoder: [libmpeg2] MPEG 1/2 Video decoder libmpeg2-v0.4.0b Selected video codec: [mpeg12] vfm: libmpeg2 (MPEG-1 or 2 (libmpeg2)) ========================================================================== Audio LAVC, couldn't find encoder for codec mp3. - - - - - Here are the contents of the script: #!/bin/bash #mpg2avi (Convert mpeg streams into high quality mpeg4 avi with mp3 audio) #requirements: mplayer #Begin clear # variables version=0.2b current_directory=$( pwd ) # video bitrate (1100 = around 500 MB movie size) vbitrate=1100 echo -e "* mpg2avi v${version}" # remove spaces for i in *.[Mm][Pp][Gg]; do mv "$i" `echo $i | tr ' ' '_'`; done > /dev/null 2>&1 & # remove uppercase for i in *.[Mm][Pp][Gg]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
/dev/null 2>&1 &
# convert mpg movies into avi's with mencoder for i in *.[Mm][Pp][Gg]; do nice -n 10 mencoder $i -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=$vbitrate:vhq:vqmin=2:vlelim=-4:vcelim=9:lumi_mask=0.05:dark_mask=0.01 -vf pp=md -vf scale=720:480, -oac lavc -lavcopts acodec=mp3:abitrate=128 -o "`basename "$i"`.avi";echo "Conversion done";done exit; - - - - - And here is some additional informational output: $ mencoder -ovc help MEncoder 2:1.0~rc2-0ubuntu1~gutsy1 (C) 2000-2007 MPlayer Team CPU: Intel(R) Pentium(R) D CPU 2.80GHz (Family: 15, Model: 6, Stepping: 2) CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1 Compiled with runtime CPU detection. Available codecs: copy - frame copy, without re-encoding. Doesn't work with filters. frameno - special audio-only file for 3-pass encoding, see DOCS. raw - uncompressed video. Use fourcc option to set format explicitly. nuv - nuppel video lavc - libavcodec codecs - best quality! vfw - VfW DLLs, read DOCS/HTML/en/encoding-guide.html. qtvideo - QuickTime DLLs, currently only SVQ1/3 are supported. libdv - DV encoding with libdv v0.9.5 xvid - XviD encoding x264 - H.264 encoding $ mencoder -oac help MEncoder 2:1.0~rc2-0ubuntu1~gutsy1 (C) 2000-2007 MPlayer Team CPU: Intel(R) Pentium(R) D CPU 2.80GHz (Family: 15, Model: 6, Stepping: 2) CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1 Compiled with runtime CPU detection. Available codecs: copy - frame copy, without re-encoding (useful for AC3) pcm - uncompressed PCM audio mp3lame - cbr/abr/vbr MP3 using libmp3lame lavc - FFmpeg audio encoder (MP2, AC3, ...) twolame - Twolame MP2 audio encoder faac - FAAC AAC audio encoder -- Dave M G Ubuntu 7.10
Dave M G wrote:
# convert mpg movies into avi's with mencoder for i in *.[Mm][Pp][Gg]; do nice -n 10 mencoder $i -ovc lavc -lavcopts
vcodec=mpeg4:vbitrate=$vbitrate:vhq:vqmin=2:vlelim=-4:vcelim=9:lumi_mask=0.05 :dark_mask=0.01 -vf pp=md -vf scale=720:480, -oac lavc -lavcopts acodec=mp3:abitrate=128 -o "`basename "$i"`.avi";echo "Conversion done";done
exit;
Try changing '-oac lavc -lavcopts acodec=mp3:abitrate=128' to '-oac mp3lame -lameopts br=128' This is supposed to be the better way to do it, but you could also change acodec=mp3 to acodec=libmp3lame in your original script.
John Brown wrote:
Dave M G wrote:
# convert mpg movies into avi's with mencoder for i in *.[Mm][Pp][Gg]; do nice -n 10 mencoder $i -ovc lavc -lavcopts
vcodec=mpeg4:vbitrate=$vbitrate:vhq:vqmin=2:vlelim=-4:vcelim=9:lumi_mask=0.05 :dark_mask=0.01 -vf pp=md -vf scale=720:480, -oac lavc -lavcopts acodec=mp3:abitrate=128 -o "`basename "$i"`.avi";echo "Conversion done";done
exit;
Try changing '-oac lavc -lavcopts acodec=mp3:abitrate=128' to '-oac mp3lame -lameopts br=128'
Or even better: -oac mp3lame -lameopts preset=standard
Phil, John, Thank you for responding.
-oac mp3lame -lameopts preset=standard
This worked great. For appending files together... a person on my local Linux users group said that MPEG files could be concatenated together using a simpe "cat" command which seems to work. And for de-interlacing... seems that I might have to use ffmpeg for that. Thank you for your advice. -- Dave M G
Dave M G wrote:
And for de-interlacing... seems that I might have to use ffmpeg for that.
Heavens no. -vf pp=lb or -vf yadif=0 Take your pick. pp=lb is a bit softer than yadif but is faster and produces fewer artifacts. yadif=0 is more precise but can produce artifacting on certain material (bits of the image not deinterlaced, some "chattering" on high contrast horizontal lines, etc.)
James, Thank you for responding.
-vf pp=lb or -vf yadif=0
Am I doing something wrong in my syntax? I tried both of these and neither seemed to de-interlace the files at all. This is the command with the pp=lb option: mencoder $file.mpg -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=$vbitrate:vhq:vqmin=2:vlelim=-4:vcelim=9:lumi_mask=0.05:dark_mask=0.01 -vf pp=lb -vf scale=720:405, -oac mp3lame -lameopts preset=standard -o fileout.avi -- Dave M G
On Saturday, 01 December 2007 at 05:38, Dave M G wrote:
James,
Thank you for responding.
-vf pp=lb or -vf yadif=0
Am I doing something wrong in my syntax? I tried both of these and neither seemed to de-interlace the files at all.
This is the command with the pp=lb option:
mencoder $file.mpg -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=$vbitrate:vhq:vqmin=2:vlelim=-4:vcelim=9:lumi_mask=0.05:dark_mask=0.01 -vf pp=lb -vf scale=720:405, -oac mp3lame -lameopts preset=standard -o ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fileout.avi
Only the last -vf option has any effect. Just put all used filters in the same -vf option list. Regards, R. -- MPlayer developer and RPMs maintainer: http://mplayerhq.hu http://rpm.livna.org There should be a science of discontent. People need hard times and oppression to develop psychic muscles. -- from "Collected Sayings of Muad'Dib" by the Princess Irulan
Dominik, Thank you for responding.
Only the last -vf option has any effect. Just put all used filters in the same -vf option list.
And with that all the errors I was looking for help on have been cleared up nicely. I still have to get this aspect ratio situation under control, but I'm pursuing that in another thread. Thank you to everyone for getting me on track. -- Dave M G
On Friday 30 November 2007, Dave M G wrote:
Can these errors be resolved, and then the de-interlacing and appending functions added?
To append, rather than the for loop to convert one at a time, why not just do: mencoder `ls *.mpg | sort` [encoding option] -o joinedvideo.avi -- Dave
participants (6)
-
Dave M G -
DaveG -
Dominik 'Rathann' Mierzejewski -
James Hastings-Trew -
John Brown -
Phil Ehrens