LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-31-2009, 11:55 PM   #1
DragonM15
Member
 
Registered: Sep 2003
Location: USA
Distribution: Slackware (Multiple Versions)
Posts: 455

Rep: Reputation: 31
mencoder x264 using 720x480


Hi All,

I am converting mpeg files that my tv tuner card captured. When it captures those videos it captures them at 720x480.

These captures are 950 megs for every 30 minutes. This is obviously too big.

Right now I am using mencoder to do the conversions with the following command:

Code:
mencoder filename.mpg -nosound -vf pp=ci -ovc x264 -x264encopts pass=1:bitrate=1000:turbo:threads=3:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b -o /dev/null && mencoder filename.mpg -oac copy -vf pp=ci -ovc x264 -x264encopts pass=2:bitrate=1000:threads=3:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b -o filename.avi
These settings give me a 343 meg file every 30 minutes. I am looking to make a smaller file, somewhere in the lines of 150 megs for 30 minutes, or something roughly 700 megs for 2 hours rather than 1 while still having as high quality as possible.

If anyone has any ideas let me know,

Thanks
 
Old 11-01-2009, 01:01 PM   #2
almatic
Member
 
Registered: Mar 2007
Distribution: Debian
Posts: 547

Rep: Reputation: 67
you need to decrease the bitrate in order to get smaller files. You can use a bitrate calculator to find out about the right bitrate. It's also a good idea to decrease the resolution with lower bitrates in order to keep the quality as good as possible.
 
Old 11-01-2009, 01:37 PM   #3
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
why not try using variable bitrate, maybe something like adding:

Code:
crf=30:trellis=1:nr=500
but remove the bitrate option. The nr (noise reduction) is optional, but it help with noisy input, you'll get better quality and smaller output size. If you need better quality use lower crf value, maybe 25 or 20.

Last edited by H_TeXMeX_H; 11-01-2009 at 01:39 PM.
 
Old 11-01-2009, 02:02 PM   #4
DragonM15
Member
 
Registered: Sep 2003
Location: USA
Distribution: Slackware (Multiple Versions)
Posts: 455

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by almatic View Post
you need to decrease the bitrate in order to get smaller files. You can use a bitrate calculator to find out about the right bitrate. It's also a good idea to decrease the resolution with lower bitrates in order to keep the quality as good as possible.
Yes, I know that a lower bitrate will give me smaller files, however with the resolution that I am at now, if i go lower than 1000 it gets noticeable pixelation. I have not tried the bitrate calculator, but I will give that a shot.
 
Old 11-01-2009, 02:03 PM   #5
DragonM15
Member
 
Registered: Sep 2003
Location: USA
Distribution: Slackware (Multiple Versions)
Posts: 455

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by H_TeXMeX_H View Post
why not try using variable bitrate, maybe something like adding:

Code:
crf=30:trellis=1:nr=500
but remove the bitrate option. The nr (noise reduction) is optional, but it help with noisy input, you'll get better quality and smaller output size. If you need better quality use lower crf value, maybe 25 or 20.
I will also try out your additions directly. Thanks for the advice.

Also, what would a good scale down be from 720x280. I have been looking around, and there is controversy about tv supposedly being 4x3, but video output being 720x480 which isnt 4x3. Just wondering what a good scaledown would be?

Thanks

Last edited by DragonM15; 11-01-2009 at 02:04 PM.
 
Old 11-01-2009, 05:41 PM   #6
DragonM15
Member
 
Registered: Sep 2003
Location: USA
Distribution: Slackware (Multiple Versions)
Posts: 455

Original Poster
Rep: Reputation: 31
I think that bitrate calculator needs some updating, because it claims i should be able to go at 400k rather than the 1000 I am using now. Sure I can do that but it would look like crap. Also, whenever I add crf=30:trellis=1:nr=500 to my command it tells me the x264 codec cannot be initialized on the 2nd pass.

My command is:
Code:
mencoder filename.mpg -nosound -vf pp=ci -ovc x264 -x264encopts crf=30:trellis=1:nr=500:pass=1:bitrate=1000:turbo:threads=3:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b -o /dev/null && mencoder filename.mpg -oac copy -vf pp=ci -ovc x264 -x264encopts crf=30:trellis=1:nr=500:pass=2:bitrate=1000:threads=3:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b -o filename.avi
Should I put the crf/trellis/nr options somewhere else?

Thanks
 
Old 11-02-2009, 04:17 AM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
Oh, that's because crf won't work with 2 pass (I forgot), ok try this, this I know will work, I tested it:

Code:
mencoder filename.mpg -nosound -vf pp=ci -ovc x264 -x264encopts qp=30:trellis=1:nr=500:pass=1:turbo:threads=3:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b -o /dev/null && mencoder filename.mpg -oac copy -vf pp=ci -ovc x264 -x264encopts qp=30:trellis=1:nr=500:pass=2:threads=3:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b -o filename.avi
Also, for best possible quality and smallest size I would do (remove turbo and threads):

Code:
mencoder filename.mpg -nosound -vf pp=ci -ovc x264 -x264encopts qp=30:trellis=1:nr=500:pass=1:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b -o /dev/null && mencoder filename.mpg -oac copy -vf pp=ci -ovc x264 -x264encopts qp=30:trellis=1:nr=500:pass=2:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b -o filename.avi
Remember that if it still does not look good, use a lower qp= value (25 or 20), and if there's lots of noise in the input video, use a higher nr= value (800 or 1000).

Last edited by H_TeXMeX_H; 11-02-2009 at 04:38 AM.
 
Old 11-02-2009, 10:33 AM   #8
DragonM15
Member
 
Registered: Sep 2003
Location: USA
Distribution: Slackware (Multiple Versions)
Posts: 455

Original Poster
Rep: Reputation: 31
Alright, I am testing that now. I will do 2 tests, one with threads and one without. If not using threads made things better in the end I would go for it, but I wish you could encode multiple videos at once. So say instead of doing one video at a time, do 4 (quad-core) if threads are disabled. But as I found out before, you cant do that. Reason I was trying to encode multiple at once is because using x264 with anywhere from 5-8 threads, it still only uses about 75% CPU. I know everyone says thats because of x264's efficiency, but why wont it use 100%? I am not bottle-necking at the hard drive, because there is barely any drive thrashing at all. Just curious if anyone knows why encoding with x264 wont give full system utilization?

Thanks

Last edited by DragonM15; 11-02-2009 at 10:44 AM.
 
Old 11-03-2009, 01:23 PM   #9
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
Quote:
Originally Posted by DragonM15 View Post
Alright, I am testing that now. I will do 2 tests, one with threads and one without. If not using threads made things better in the end I would go for it, but I wish you could encode multiple videos at once. So say instead of doing one video at a time, do 4 (quad-core) if threads are disabled. But as I found out before, you cant do that.
But, what do you mean you can't do that, I do that all the time. It's true that I usually use ffmpeg, but I just tried it with mencoder right now, using 4 cores to encode 4 videos at once and it was no problem. Just remember to add the

Code:
-passlogfile logname
option to specify different logfiles if you are encoding in the same directory, otherwise the logfiles will clobber. You could also do them all in different directories without this option and it will work fine.
 
Old 11-04-2009, 06:40 AM   #10
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
Is your source even 720x480? That's the dvd format. You capture card might only be seeing 640x480. Make that change and save yourself a lot of bits (and cpu cycles). The DVD format is also 7500k in terms of bitrate. But that varies depending on the player. Sometimes as low as 5000k on older players. But that's still 2GB per hour-ish. Lower than that and you're loosing more quality than a DVD. x264 can yield good results in terms of compression to quality ratio. ffmpeg defaults to 200k for a bitrate. If you really want to save your filesize, then change your resolution. 320x240 is 1/4th the information of 640x480, albeit a bit youtube-ish.
 
Old 11-04-2009, 02:25 PM   #11
DragonM15
Member
 
Registered: Sep 2003
Location: USA
Distribution: Slackware (Multiple Versions)
Posts: 455

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by H_TeXMeX_H View Post
But, what do you mean you can't do that, I do that all the time. It's true that I usually use ffmpeg, but I just tried it with mencoder right now, using 4 cores to encode 4 videos at once and it was no problem. Just remember to add the

Code:
-passlogfile logname
option to specify different logfiles if you are encoding in the same directory, otherwise the logfiles will clobber. You could also do them all in different directories without this option and it will work fine.
I mean that if I open 2 terminal windows, and have them running mencoder to convert 2 seperate videos, it will do the first pass, but whenever it goes to do the 2nd pass where it is actually generating the file causes a problem where it says the x264 codec could not be initialized. I tried this both on windows and linux with the same result. However I have never added the -passlogfile flag. Would a simple logfile be the issue? I will test that directly.

Also, sorry for the delay, but I tested the mencoder command listed above and am impressed. I also added a scaling option to bring the resolution down to 560:320 which gives me the filesize I need, and also looks perfectly fine on my TV which was what I wanted. That was running without turbo and threads, it shrunk down to 172MB. However on my desktop LCD if I make that full screen it gets rather pixelated, but that is to be expected. All in all I like the improvements.

Thanks
 
Old 11-04-2009, 06:30 PM   #12
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
The logfile / passfile is a hardcoded name. If you don't override it, or do the conversions in dedicated / separate directories, they'll try to use the same file, and step on each others toes. Bear in mind that x264 is still in development, so it's not as polished as it might be someday.
 
Old 11-05-2009, 12:35 AM   #13
DragonM15
Member
 
Registered: Sep 2003
Location: USA
Distribution: Slackware (Multiple Versions)
Posts: 455

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by Shadow_7 View Post
The logfile / passfile is a hardcoded name. If you don't override it, or do the conversions in dedicated / separate directories, they'll try to use the same file, and step on each others toes. Bear in mind that x264 is still in development, so it's not as polished as it might be someday.
Yeah, I realize that. If I to separate encodings in different directories it works great, however if I try to encode 2 videos in the same directory, even with your added switch it still fails upon pass 2.

Thanks for your help
 
Old 11-05-2009, 12:43 PM   #14
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
Quote:
Originally Posted by DragonM15 View Post
I mean that if I open 2 terminal windows, and have them running mencoder to convert 2 seperate videos, it will do the first pass, but whenever it goes to do the 2nd pass where it is actually generating the file causes a problem where it says the x264 codec could not be initialized. I tried this both on windows and linux with the same result. However I have never added the -passlogfile flag. Would a simple logfile be the issue? I will test that directly.

Also, sorry for the delay, but I tested the mencoder command listed above and am impressed. I also added a scaling option to bring the resolution down to 560:320 which gives me the filesize I need, and also looks perfectly fine on my TV which was what I wanted. That was running without turbo and threads, it shrunk down to 172MB. However on my desktop LCD if I make that full screen it gets rather pixelated, but that is to be expected. All in all I like the improvements.

Thanks
So basically you would have to run each command with a different logfile name so that they dump data gathered from the first pass to separate files ... imagine if they write to the same file, like happens by default.

Also if you are using mplayer to play videos you can run something like this to reduce pixelation:

Code:
mplayer -vo gl:cscale=1:lscale=1:yuv=4 -vf pp -autoq 100 -dr file.avi
You can also try "yuv=3" instead of 4 if the colors are in black and white. This works best with nvidia card and drivers.
 
Old 11-05-2009, 08:31 PM   #15
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
Low bitrates will yield pixelation. You can forgo some pixelation by changing the colorspace / numbers of colors in use. Or by changing the resolution. Simpler data yields better compression. A higher quality source does too. I capture from my TV card in HuffYuv, then compress that to DVD quality. A bit of a space hog(40GB+ per hour), but yeilds decent results.

So what results would you be happy with? Change the colorspace to 16 bit B&W (-pix_fmt gray16le in ffmpeg) and save a ton of bits in the result. Not always desireable, but sometimes good enough. When space is more important than than content.

$ ffmpeg -pix_fmt list
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mencoder & x264 help steve51184 Linux - Software 14 05-21-2009 04:58 AM
Green screen after video conversion, AVI to MP4 using Mencoder,Mplayer,FFmpeg,x264, manuken Linux - Newbie 4 10-29-2008 06:40 PM
Mencoder: x264 [error]: no ratecontrol method specified PsypherPunk Linux - Software 1 01-12-2008 08:45 AM
Converting DVD to x264 w/ Mencoder out of sync? carl0ski Linux - Desktop 1 01-12-2007 07:04 AM
Why can't I get 720x480 on my TV-OUT? newmoon Linux - General 0 07-28-2005 01:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration