Author Topic: Video Quality  (Read 28070 times)

islandjim

  • V3 Beta Tester
  • Full Member
  • *
  • Posts: 281
Video Quality
« on: February 19, 2008, 01:48:31 PM »
Good day all.

Are there setting where we make the quality of the videos better?

Thank you.

Shawn

  • Hero Member
  • *****
  • Posts: 2616
Re: Video Quality
« Reply #1 on: February 19, 2008, 06:32:51 PM »
There are a couple of settings you need to change in converter.php as well as a line to add.

First thing is to find this bit of code:
Code: [Select]
$mencoder_cmd = "$path_to_mencoder $raw_video_path -o $new_flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=800:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -vf scale=320:233 -srate 22050";and change the vbitrate from 800 to something higher.  I use 2000.  Change every vbitrate you see from 800 to a higher number like 2000.  There should be a total of 3 places to change.

That alone didn't help me however.  Through searching I found the answer in this post by Code187

Here's what you need to do:

In converter.php find this bit of code:
Code: [Select]
case 'wmv':
            //UNCOMMENT THIS LINE OUTPUTS VERY HIGH QUALITY FLV -- FLV FILE MUCH LARGER
            //$ffmpeg_cmd2 = "$config[path_to_ffmpeg] -i $raw_video_path -ab 64 -ar 44100 -b 300k -r 30 -s 720x480 -sameq $new_flv";
            $ffmpeg_cmd2 = "$config[path_to_ffmpeg] -i $raw_video_path -copyts -ar 44100 -s 320x240 $new_flv";

and replace it with this
Code: [Select]
case 'wmv':
            //UNCOMMENT THIS LINE OUTPUTS VERY HIGH QUALITY FLV -- FLV FILE MUCH LARGER
            $ffmpeg_cmd2 = "$config[path_to_ffmpeg] -i $raw_video_path -ab 64 -ar 44100 -b 300k -r 30 -s 400x304 -qmax 4 $new_flv";
            //$ffmpeg_cmd2 = "$config[path_to_ffmpeg] -i $raw_video_path -copyts -ar 44100 -s 320x240 $new_flv";

Note that not only did I uncomment the bit of code that was commented, but there are a few changes thanks to the info I found in this post by Code187.   Uncommenting the code alone will result in HUGE flv files.  What I did here is change -sameq to -qmax 4 which allows you to set the quality level for your converted FLV's.  The number represents the quality. The lower the number the better quality.  So -qmax 1 whould be the highest quality.   Code187 recommended using -qmax 5, however I found that -qmax 4 worked better for me.  Try different values and find one that suites you.

Now the problem here, is that bit only effects wmv files so what you need to do next is scroll down a bit and find this code:

Code: [Select]
 case 'avi':
            $ffmpeg_cmd2 = "$config[path_to_ffmpeg] -i $raw_video_path -copyts -ar 44100 -s 320x240 $new_flv";
            @exec("$ffmpeg_cmd2");

and replace it with this:
Code: [Select]
case 'avi':
     $ffmpeg_cmd2 = "$config[path_to_ffmpeg] -i $raw_video_path -ab 64 -ar 44100 -b 300k -r 30 -s 400x304 -qmax 4 $new_flv";
           // $ffmpeg_cmd2 = "$config[path_to_ffmpeg] -i $raw_video_path -copyts -ar 44100 -s 320x240 $new_flv";
            @exec("$ffmpeg_cmd2");
As you can see all we did here is take the same code and add it to the case 'avi': bit


Now that I've done that, my video quality is awesome!

Here is an example of the quality I get: (note that I am NOT using an HD hosting service of any kind)
Watch "National Geographic - Demo"



Several people have asked for a copy of my convertor.php file.  I have attached it to this post.  
USE IT AT YOUR OWN RISK!  Just make sure to make a backup copy of your existing convertor.php file before using this one, just in case. ;)
« Last Edit: October 01, 2009, 07:40:24 AM by Shawn »

coffee

  • Jr. Member
  • **
  • Posts: 133
Re: Video Quality
« Reply #2 on: February 20, 2008, 02:56:07 AM »
You also changed some numbers to 400x304 - is that the dimensions of the video?

What's the link to your videos website that shows the video quality?

Thanks.

Shawn

  • Hero Member
  • *****
  • Posts: 2616
Re: Video Quality
« Reply #3 on: February 20, 2008, 09:21:57 AM »
Yes that is the video dimensions.

Here's a link to one of my videos http://www.wildcast.tv/play.php?vid=139

Before I made those changes the quality was so bad, the videos were unwatchable.
« Last Edit: March 05, 2008, 06:37:37 PM by ShawnX »

coffee

  • Jr. Member
  • **
  • Posts: 133
Re: Video Quality
« Reply #4 on: February 20, 2008, 04:37:40 PM »
Anyone else change that code like that for higher video quality, or use something else?

Thanks.

tiny29

  • Guest
Re: Video Quality
« Reply #5 on: February 20, 2008, 04:52:18 PM »
Anyone else change that code like that for higher video quality, or use something else?

Thanks.

i use flv files only and have best quality ;D

Shawn

  • Hero Member
  • *****
  • Posts: 2616
Re: Video Quality
« Reply #6 on: February 20, 2008, 05:09:57 PM »
Anyone else change that code like that for higher video quality, or use something else?

Thanks.

i use flv files only and have best quality ;D

That's cheating!  ;D

islandjim

  • V3 Beta Tester
  • Full Member
  • *
  • Posts: 281
Re: Video Quality
« Reply #7 on: February 20, 2008, 06:03:29 PM »
Clear, sharp images. very nice. I will be modifying. I know I sent a PM thanking you earlier when you replied to the post, but wanted to say again here, Thanks.

Jim

Shawn

  • Hero Member
  • *****
  • Posts: 2616
Re: Video Quality
« Reply #8 on: February 20, 2008, 06:07:33 PM »
No problem :)

frankie

  • Administrator
  • Hero Member
  • *****
  • Posts: 6143
  • PHPmotion Developer
Re: Video Quality
« Reply #9 on: February 20, 2008, 06:37:08 PM »
Hi ShawnX,

yeah the reason the wmv converted size is so much larger is because of the size 720x480;
 //UNCOMMENT THIS LINE OUTPUTS VERY HIGH QUALITY FLV -- FLV FILE MUCH LARGER
//$ffmpeg_cmd2 = "$config[path_to_ffmpeg] -i $raw_video_path -ab 64 -ar 44100 -b 300k -r 30 -s 720x480 -sameq $new_flv";

You can decrease the final size just by changing the scale size to your smaller size,e.g. 400x304
$ffmpeg_cmd2 = "$config[path_to_ffmpeg] -i $raw_video_path -ab 64 -ar 44100 -b 300k -r 30 -s 400x304 -sameq $new_flv";

I am working on a admin panel / video settings page.
Where the admin can select to turn video scaling on of off, and
if video scaling is turned on, pull down boxes to select their desired video conversion size,
as well as video quality, bit rates etc.

So in a nut shell each admin/webmaster will have total control over
how their sites videos are converted.

I hope to have this finished for the fiinal release of ver 2.
If you guys have any input as to what features you would
like to have, please let me know.

cheers
           


Shawn

  • Hero Member
  • *****
  • Posts: 2616
Re: Video Quality
« Reply #10 on: February 20, 2008, 07:18:03 PM »
that sounds great frankie!  Can't wait for that feature!  Thanks  ;D

islandjim

  • V3 Beta Tester
  • Full Member
  • *
  • Posts: 281
Re: Video Quality
« Reply #11 on: March 05, 2008, 03:37:26 PM »
You mention this will work with WMV and AVI, what about the rest, like MOV? I am going to attempt this change tonight from home but want to make sure this will work with mov

Thanks.
IJ

Shawn

  • Hero Member
  • *****
  • Posts: 2616
Re: Video Quality
« Reply #12 on: March 05, 2008, 06:39:35 PM »
Haven't tried uploading an mov yet.  Give it a shot and let us know if it works :)

mykidtv

  • Newbie
  • *
  • Posts: 13
Re: Video Quality
« Reply #13 on: March 05, 2008, 06:46:08 PM »
ShawnX - WOW. wow. WoW. wOw. That easy fix did the trick for my site.

What an immediate difference Crystal clear videos. The same video that had been pixelated is now (after re-upload) lear as a bell. It is like watching TV... well except for the buffering of course. LOL

Thanks so MUCH. And I am glad I edited early in the life of my site.

You can see how clear the video is here: http://www.mykid.tv/play.php?vid=89 . There are still some earluer videos online to see what I had been viewing. Ugghhh.


Shawn

  • Hero Member
  • *****
  • Posts: 2616
Re: Video Quality
« Reply #14 on: March 05, 2008, 07:01:11 PM »
Looks great!

I looked at one of your older videos, and that's pretty much how mine looked before doing those changes.   Glad it worked for you  :)