NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public NextPVR Other Clients Old Stuff (legacy) MVP & NMT v
« Previous 1 … 80 81 82 83 84 … 115 Next »
Anyone tried playing .avs files yet (AviSynth)?

 
  • 0 Vote(s) - 0 Average
Anyone tried playing .avs files yet (AviSynth)?
jpenninkhof
Offline

Junior Member

Posts: 6
Threads: 0
Joined: Sep 2005
#21
2005-11-04, 08:43 AM
I thought it was as dirty as it gets... Btw: seems that we're all a bunch of dirty coders here... I kinda suspect that that's why Sub has never released any bit of his code yet (open source) Wink

Ps: They say that dirty coders also dress bad...
LilY0da
Offline

Senior Member

Posts: 442
Threads: 25
Joined: Jul 2005
#22
2005-11-04, 04:19 PM
Now don't you dare make fun of my flower shirt, torn jeans and flip flops
Smile
LilY0da
Offline

Senior Member

Posts: 442
Threads: 25
Joined: Jul 2005
#23
2005-11-05, 04:59 AM (This post was last modified: 2005-11-05, 07:03 AM by LilY0da.)
trying it out now, I'm amazed at all you can get with that getid3 library.
[Image: smilie_pop_eyes.gif]

EDIT: well, been working on the resize algorythm. to resize either to 640x480 or 352x240. It's been harder than I thought... Mostly because the 2 target sizes don't have the same aspect ratio pixel count wise, but are both supposed to contain a perfect 4/3 ratio image *sigh*
I think I got a version working, but will test it for a while before posting it.
LilY0da
Offline

Senior Member

Posts: 442
Threads: 25
Joined: Jul 2005
#24
2005-11-05, 09:20 PM (This post was last modified: 2005-11-06, 03:08 AM by LilY0da.)
Well here is the logic I chose.
I was trying to detect if the video content of the file was 4/3rd. You can sometimes get that from the video file ratio, but not always.
I had tons of videos in 352x240, or 720x480, or 480x480 (from my SVCD days), so even though the file doesn't have a 4/3rd ratio, the contents are a true 4/3rd video

So I decided to make an assumption at first that the contents were already 4/3rd if:
- either the file X/Y ratio is 4/3rd
- either the file X/Y are known combinations of NTSC formats
In that case, no borders, no cropping, straight resize to the MVP resolutions

In all other cases, I assume that the video content has a pixel ratio of 1 (meaning that if you open the video file in a media player classic window on your PC, it plays fine without having to stretch it), and I crop or add borders to get a true 4/3rd content first, then resize to the closest MVP resolution (which may not be 4/3rd, but will still contain a 4/3 image)

I decided that if the source width was >= 480, I'd resize to a 640x480, and if below, I'd resize to a 352x240 (containing a 320x240 video). But you can change that on the line that says "if ($VidWidthOrig >= 480) {"

Here's the code, which is more or less stolen from jpenninkhof's above
The other modifications are using Lanczos resize instead of Bicubic (seems a bit faster on my PC), and ConvertFPS instead of ChangeFPS, since ChangeFPS creates audio desynch for me
Code:
<?php

$frompath = '/media/Video/';
$refpath = '\\\\ROQUEFORT\\MEDIA\\VIDEO\\';
$topath = '/media/Video/avs/';

function processfile($frompath, $refpath, $filename) {
    $TargetFPS = "29.97";  // Target Framerate for the MVP (NTSC)
    $GoodFormats = "720x480,480x480,352x480,352x240"; // List of valid resolutions (NTSC)

    $retval = "";
    require_once('/var/www/getid3-1.7.4/getid3/getid3.php');
    $getid3 = new getID3;
    $getid3->encoding = 'UTF-8';
    $getid3->Analyze($frompath . $filename);
    $retval .= "# File:             " . @$getid3->filename . "\r\n";
    $retval .= "# Playtime:         " . @$getid3->info['playtime_string']  . "\r\n";
    $retval .= "#\r\n";
    $retval .= "# - Format:         " . @$getid3->info['video']['fourcc'] . "\r\n";
    $retval .= "# - Codec:          " . @$getid3->info['video']['codec'] . "\r\n";
    $retval .= "# - Mode:           " . @$getid3->info['video']['bitrate_mode'] . "\r\n";
    $VidWidthOrig = @$getid3->info['video']['resolution_x'];
    $VidHeightOrig = @$getid3->info['video']['resolution_y'];
    $VideoRatio = $VidWidthOrig/$VidHeightOrig;
    $SourceResolution = $VidWidthOrig ."x". $VidHeightOrig;
    $retval .= "# - Resolution:     $SourceResolution\r\n";
    $retval .= "#   ratio:          $VideoRatio\r\n";
    $AssumeVideoContentIsFourThirds = true;
    if ($VideoRatio == 4/3) $retval .= "#   Assuming source contents is 4/3 because of source ratio\r\n";
    elseif (eregi($SourceResolution,$GoodFormats))  $retval .= "#   Assuming source contents is 4/3 because of source format\r\n";
    else $AssumeVideoContentIsFourThirds = false;
    if ($VidWidthOrig >= 480) {
        $retval .= "#   Width greater or equal than 480 pixel, will resize to 640x480\r\n";
        $MVPWidth = 640;
        $MVPHeight = 480;
        }
    else {
        $retval .= "#   Width less than 480 pixel, will resize to 352x240\r\n";
        $MVPWidth = 352;
        $MVPHeight = 240;
        }
    $retval .= "# - Frame rate:     " . @$getid3->info['video']['frame_rate'] . "\r\n";
    $retval .= "# - Bit-rate:       " . @$getid3->info['video']['bitrate'] . "\r\n";
    $retval .= "# - Aspect ratio:   " . @$getid3->info['video']['pixel_aspect_ratio'] . "\r\n";
    $retval .= "# - Frame rate:     " . @$getid3->info['video']['frame_rate'] . "\r\n";
    $retval .= "# - Total frames:   " . @$getid3->info['video']['total_frames'] . "\r\n";
    $retval .= "#\r\n";
    $retval .= "# Audio:\r\n";
    $retval .= "# - Format:         " . @$getid3->info['audio']['dataformat'] . "\r\n";
    $retval .= "# - Codec:          " . @$getid3->info['audio']['codec'] . "\r\n";
    $retval .= "# - Channels:       " . @$getid3->info['audio']['channels'] . "\r\n";
    $retval .= "# - Sample rate:    " . @$getid3->info['audio']['sample_rate'] . "\r\n";
    $retval .= "# - Bitrate:        " . @$getid3->info['audio']['bitrate'] . "\r\n";
    $retval .= "\r\n";
    $retval .= "DirectShowSource(\"" . $refpath . str_replace('/', '\\', $filename) . "\", " . @$getid3->info['video']['frame_rate'] . ")\r\n";
    $retval .= "ConvertToYUY2\r\n";
    //if the source doesn't need resizing, do nothing
    if ($SourceResolution == $MVPWidth."x".$MVPHeight) {$retval .= "# No resize needed\r\n";}
    //if we assume the content video is 4/3rd, straight resize, no calculations, borders or cropping
    elseif (($AssumeVideoContentIsFourThirds == true) && (@$getid3->info['video']['pixel_aspect_ratio'] == 1)) $retval .= "LanczosResize($MVPWidth, $MVPHeight)\r\n";
    else {
        // Find what the true 4/3rd Width is for the MVP target height
        $VidWidthNew = $MVPHeight*4/3;
        $VidHeightNew = round($VidWidthNew/$VideoRatio);
        if ($VidHeightNew % 2) $VidHeightNew--;
        $TargetResolution = $VidWidthNew ."x". $VidHeightNew;
        $retval .= "# Target 4/3rd Resolution:     $TargetResolution\r\n";
        // $VidWidthNew and $VidHeightNew are the true 4/3 dimensions.
        // But, since the MVP takes only 640x480 and 352x240,
        // and will resize to 4/3 even if the AVS output isn't,
        // we have to ensure the *contents* of the AVS image are true 4/3,
        // even if the target AVS might not be (like 352x240)
        // So resize the video to the correct Video Height, and correct *MVP* width
        $retval .= "LanczosResize($MVPWidth, $VidHeightNew)\r\n";
        $Difference = $MVPHeight - $VidHeightNew;
        if ($Difference > 0) {
            $Border = $Difference / 2;
            $retval .= "AddBorders(0, $Border, 0, $Border)\r\n";
            }
        elseif ($Difference < 0) {
            $Excess = abs($Difference / 2);
            $retval .= "Crop(0,$Excess,0,-$Excess)\r\n";
            }
        }
    $retval .= "ConvertFPS(".$TargetFPS.")\r\n";
    return $retval;        
}

function searchdir ( $path , $maxdepth = -1 , $mode = "FULL" , $d = 0 ) {
echo "Entering ".$path."\n";
if ( substr($path,strlen($path)-1) != '/' ) $path .= '/'; // add a trailing '/'
$dirlist = array ();
if ($mode != "FILES" ) $dirlist[] = $path;
if ($CurrentDirectory = opendir($path)) {
    while ( false !== ( $file = readdir ( $CurrentDirectory ) ) ) {
        if ( $file != '.' && $file != '..' ) {
            $file = $path . $file ;
            if ((!is_dir($file)) && ($mode != "DIRS")) $dirlist[] = $file ;
            elseif ( $d >=0 && $d < $maxdepth ) {
                $result = searchdir ( $file . '/' , $maxdepth , $mode , $d + 1 ) ;
                $dirlist = array_merge ( $dirlist , $result ) ;
                }
            }
        }
    closedir ( $CurrentDirectory ) ;
    }
if ( $d == 0 ) { natcasesort ( $dirlist ) ; }
return ( $dirlist ) ;
}

function String2File($sIn, $sFileOut) {
    $rc = false;
    @mkdir($Dir, 0770);
    do {
        if (!($f = fopen($sFileOut, "wa+"))) {
        $rc = 1;
        break;
        }
        if (!fwrite($f, $sIn)) {
            $rc = 2;
            break;
            }
        $rc = true;
        } while (0);
    if ($f) fclose($f);
    return ($rc);
    }


echo "<PRE>\n";
$files = searchdir($frompath, 1);
foreach ($files as $file) {
    $filename = substr($file, strlen($frompath));
    if (substr($filename, strrpos($filename,'.')+1) == "avi") {
        $Dir = substr($topath . $filename, 0, strrpos($topath . $filename,'/'));
        echo "Creating directory: $Dir\n";
        @mkdir($Dir, 0770);
        echo "Creating AVS file for ".$frompath.$filename."\n";
        String2File(processfile($frompath, $refpath, $filename), $topath . substr($filename,0,strlen($filename)-3) . 'avs' );
        }
    elseif (substr($filename, strrpos($filename,'.')+1) == "mpg") {
        $Dir = substr($topath . $filename, 0, strrpos($topath . $filename,'/'));
        echo "Creating directory: $Dir\n";
        @mkdir($Dir, 0770);
        echo "Creating SymLink for  ".$frompath.$filename."\n";
        @symlink($frompath . $filename, $topath . $filename);
    }
}
echo "</PRE>\n";



?>

TO DO LIST:
- I need to add a flag in the AVS file that you can edit by hand, and will prevent the script from overwriting the AVS. This is used in case you decide to modify an AVS manually
- I need to do the subtitle thingy
- I need more info on PAL videos, what the standard formats are, what the contents are (is it a 1.333 or 1.222 image inside, is the file format 1.333 or 1.222, is it stretched or not, etc...) to make a script that can handle PAL and NTSC based on a variable you set.

I need help from you video savvy euros here regarding the last point. Post here and help us Smile
pBS
Offline

Posting Freak

Posts: 4,829
Threads: 182
Joined: Aug 2005
#25
2005-11-12, 02:09 AM
did ya ever get the colors to come out right LilY0da? mine's swapped blue and red..Sad
.avs plays same on WMP but the avi plays fine..
i also don't get sound through my MVP either...wondering what is up with that..
anyone ever try using Audiograph plugin? makes cool visuals for audio files...[and you can seek!] i get a nice waveform graph but no audio..Sad
i'm using the ffdshow decoder for a DIVX fourcc avi file.
tried colorspace conversions but no difference..

if i can get this to work i'm gonnna make an audio visualizer plugin Big Grin
Hardware: HDHR Prime, HDPVR 1212, Raspberry pi2, VFD display w/LCDSmartie
LilY0da
Offline

Senior Member

Posts: 442
Threads: 25
Joined: Jul 2005
#26
2005-12-01, 07:19 PM
oh wow, sorry pBS, never saw your post in this thread... The "new post" function doesn't always return all posts, it seems

OK for your color problem, try to add the lines below
Code:
SwapUV()
ConvertToYUY2()

Also, I don't see the problem anymore when I use DirectShowSource() instead of AVISource(). So try both and see what works Smile
pBS
Offline

Posting Freak

Posts: 4,829
Threads: 182
Joined: Aug 2005
#27
2005-12-05, 01:43 PM
found that too after i posted but have been having terrible sync/stability problems reading mp3's and some avi's from directshowsource..[actually mpasource cuz i can't get directshowsource to work at all really]
i got a file to play that will 'visualize' the audio of an mp3 while you listen to it but the mp3 reading seems to really suck on the cpu and crashes before end quite frequently..you have same probs? if i could get this to work stably,i could make a slideshow with music that would work on mvp and 'visualizations' too but it's seems really buggy for me..any special plugins that you use and what ver. avisynth?
seeing tons of possibilities..Smile
will upload a screenshot later of it working on the mvp..
Hardware: HDHR Prime, HDPVR 1212, Raspberry pi2, VFD display w/LCDSmartie
pBS
Offline

Posting Freak

Posts: 4,829
Threads: 182
Joined: Aug 2005
#28
2005-12-05, 01:59 PM
here's what it looks like but i have to do too much to get it to work reliably..
[notably, caching the mp3 like crazy, lowering volume of audio, then graphing it,then re-adding the original audio back to final output] cuz high peaks of audio seem to crash the audiograph plugin...
any suggestions?
i'm new to avs but have tried everything obvious...
Hardware: HDHR Prime, HDPVR 1212, Raspberry pi2, VFD display w/LCDSmartie
LilY0da
Offline

Senior Member

Posts: 442
Threads: 25
Joined: Jul 2005
#29
2005-12-05, 02:59 PM
No I haven't attempted something that extreme Smile
My experience so far on a clean machine (reinstalled XP after my mobo crash a couple weeks ago) is that you'd need
Divx3
Divx4 (say no to "play all div3 content", otherwise you'll have to install another codec fir div3 audio)
Xvid (for whatever ain't caught by the 2 above)
VobSub
Avisynth
VSFilter (adds the VobSub features to Avisynth)

I am still working on the version with the subtitles. I'm struggling a bit, since I now have to do 2 resizes. My CPU on local playback is around 60% utilization, so that's a bit high. And I have an athlon 3000. So I'm not too surprised you're facing CPU problems Undecided
pBS
Offline

Posting Freak

Posts: 4,829
Threads: 182
Joined: Aug 2005
#30
2005-12-08, 01:56 AM
also figured out why i couldn't get sound on my MVP,i was using mencoder to transcode and it doesn't handle .avs sound yet..[but hopefully soon]
seems to work fine with the gbpvr transcoder tho Smile
i thin my problem is with the audiograph plugin cuz it seems i can now play mp3's reliably with directshowsource...but with audiograph it's still a bit buggy and i get pops occasionally..

just started using AVE [AVS Visual Editor] to help build the avs scripts and it really helps with the complex graphs. [and also has context sensitive help for plugins]

i'm working on a slideshow plugin that will allow slideshows of pics with sound and transitions[!] that will work on MVP[!] and that seems to be really easy on cpu [at least for avs part,still has to transcode to MVP but it works well so far..Smile]
most of it is building the script, but i'm gonna need some help making the plugin part...[should be fairly simple,just selecting pics and music to show,will probably just have random transitions..[not selectable]]
any volunteers? lol
[i just need to break down and learn c#... syntax shmintax..lol one of these days..]

oh and now i only see 60-70 cpu too....i think it was one of the mp3 decoders i was using..[i use ffdshow for my divx,etc]
interestingly enough,i was able to ff thru the mp3 in real-time,with visual!
Hardware: HDHR Prime, HDPVR 1212, Raspberry pi2, VFD display w/LCDSmartie
« Next Oldest | Next Newest »

Users browsing this thread: 4 Guest(s)

Pages (4): « Previous 1 2 3 4 Next »


Possibly Related Threads…
Thread Author Replies Views Last Post
  Mucic not playing complete tracks Jaggy 8 7,081 2017-03-18, 12:53 AM
Last Post: Jaggy
  Problems Playing on PCH-A100 but OK on the PC jksmurf 34 23,466 2014-09-09, 05:23 AM
Last Post: jksmurf
  No audio on MKV files on the PCH pcostanza 3 3,813 2011-11-22, 02:21 AM
Last Post: pcostanza
  MVP Crashes when playing some video files szkoda 7 4,824 2011-06-30, 11:16 AM
Last Post: HtV
  NMT A100 stopped playing video srhutch 12 5,642 2011-04-30, 02:14 PM
Last Post: srhutch
  Freeze to black screen when stopping wmv, mkv, some avi files jksmurf 6 3,405 2010-03-18, 09:24 PM
Last Post: mvallevand
  Watching .TS files on my MVP, not in GBPVR emulation mode Probedude 1 1,960 2010-03-16, 11:32 AM
Last Post: mvallevand
  No sound playing trailers or other .mpg files through mvp navyblue 3 2,820 2009-05-16, 03:51 AM
Last Post: Pengu
  playing divx file on the PCH (and MVP too)? jksmurf 5 2,506 2009-02-22, 04:29 AM
Last Post: mvallevand
  mvp crash when playing mpg1 karfan 2 1,868 2009-01-07, 05:29 PM
Last Post: karfan

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode