DVD2SVCD: Avisynth: division by zero error

Discussion in 'MPEG-1 and MPEG-2 encoding (AVI to DVD)' started by xsktr97, Jul 30, 2003.

  1. xsktr97

    xsktr97 Member

    Joined:
    Jul 30, 2003
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    11
    When i was trying to convert an avi to a svcd using DVD2SVCD everything went smoothly with no errors, but when i play the file 8 min. in a black screne with Avisynth: division by zero appears. What is wrong and what should i do? I have the latest version of DVD2SVCD and i have already completed one successful svcd, but this one just won't work.
     
  2. Shoey

    Shoey Guest

    Give this a try m8.
    ===============================================
    If the AVI your encoding has a widescreen Aspect Ratio of 2.3:1, as we found above, DVD2SVCD does not have this as a setting to automate the encoding and it has to be adjusted manually, though it does get it right sometimes!
    a. In the Conversion tab, change the aspect ratio set to 16:9.
    b. Click on the Frameserver tab and change the Edit the Avisynth Script file to Edit as part of Video encoding.
    c. Now start the conversion as usual.
    d. Stay with the encoding and after the Audio has been extracted & converted and just before the actual encoding start, an AviSynth script window will pop up. In here we have to modify the numbers, this example will explain. Once the correct numbers have been entered, the AddBoarders statement added, then hit the Save button and then the OK button. The encoding will now continue as usual and result in the correct aspect ratio for the movie.


    eg: Our AVI had dimensions of, say, 512 x 224 ( X x Y ) as found above. This needs to be resized for a SVCD to 480 x 576 for PAL or 480 x 480 for NTSC. But the pixel aspect ratios of a PC monitor and a PAL or NTSC TV are not the same. PC Monitor pixels have a square pixel aspect ratio of 1:1 but pixel aspect ratio for PAL TV is 54:59 and for an NTSC TV is 11:10.

    So the correct resizing parameters for our AVI in this example would be:

    For PAL AVI:

    Calculated height = ((720 / X) x Y) / (54 / 59)
    =((720 / 512) x 224) / (54 / 59)
    = 344.16

    So the correct "Resize" statement in the AviSynth script would be:
    ...
    BiCubicResize(480,344,0.00,0.60)
    ...

    where the Calculated height of 344.16 has been rounded to 344 to be divisible by 4 (even better if divisible by 16).

    Then we add borders on top and bottom to fill the height up to 576 pixels.

    Correct borders = (576 - Calculated height) / 2
    = (576 - 344) / 2
    = 116

    So the correct "AddBorders" statement in the AviSynth script would be:
    ...
    BiCubicResize(480,344,0.00,0.60)
    AddBorders(0,116,0,116)
    ...

    For NTSC AVI:

    Calculated height = ((720 / X) x Y) / (11 / 10)
    = ((720 / 512) x 224) / (11 / 10)
    = 286.36

    So the correct "Resize" statement in the AviSynth script would be:
    ...
    BiCubicResize(480,288,0.00,0.60)
    ...

    where the Calculated height of 286.36 has been rounded up to 288 to be divisible by 4 (even better if divisible by 16).

    Then you have to add borders on top and bottom to fill the height up to 480 pixels.

    Correct borders = (480 - Calculated height) / 2
    = (480 - 288) / 2
    = 96

    So the correct "AddBorders" statement in the AviSynth script would be:
    ...
    BiCubicResize(480,288,0.00,0.60)
    AddBorders(0,96,0,96)
    ...


    NOTE 2. I would strongly suggest not to convert widescreen 2.3:1 acpect ratio AVI's to 16:9 SVCD's. You are struggling to maintain SVCD quality from a DivX, and chopping off any part of the pic is only going to make things worse, not better.

    If you want to convert AVI's with DVD2SVCD in Batch mode, but wait until the Audio is fully extracted first (only takes about a min) before you shut DVD2SVCD down. Then shut down BeSweet from the systray.


    Shoey :)
     
    Last edited by a moderator: Jul 31, 2003
  3. xsktr97

    xsktr97 Member

    Joined:
    Jul 30, 2003
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    11
    I did exactly what you said. The avi that I am trying to convert is 640 x 272 I edited the script to this
    BicubicResize(480,280,.00,.06)
    AddBorders(0,100,0,100)
    and once again the exact same thing happened. 7 minutes and 50 seconds in Avisynth: division by zero appears on the screen. What went wrong.
     
  4. xsktr97

    xsktr97 Member

    Joined:
    Jul 30, 2003
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    11
    Can someone help me?!!!
     
  5. xsktr97

    xsktr97 Member

    Joined:
    Jul 30, 2003
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    11
    i have figured out the problem. My avi has a few bad frames at 7:50 in. I have tried using avifixed to fix the bad frames but it doesn't work. I then cut out the bad frames of the movie (using VirtualDub), but when i play it the audio is 4 seconds off the video. I tried using avifixed to then fix the dub. That didn't work. I also tried AviFix (which failed). Dela, HELP ME!!
     
  6. Shoey

    Shoey Guest

    Take your converted mpeg2 file and try this m8.
    [bold]Audio is out by a constant amount throughout the movie. [/bold]
    1. This works for both VCD's and SVCD's. The basic principle is to De-multiplex the MPG file and Re-multiplex with MPEG2VCR applying an audio offset.

    2. Run TMPGEnc, click on File and select MPEG Tools. Select Simple De-multiplex tab and for Input, browse to your problem MPG. Video and Audio output names will be automatically generated. The Audio being *.MP2 and video being *.M1V or *.M2V. Click Run and wait until its finished. Exit TMPGEnc.

    3. Run MPEG2VCR and under Tools, select MPEG System Multiplexor. Browse for the Video *.M1V/*.M2V file after changing Files Type to All(*.*). Do the same for the Audio *.MP2 file. Now select MPEG-1 System Stream VCD or MPEG-2 Program Stream SVCD depending if its a VCD or SVCD that your trying to fix. Enter an output file name and click on AV-Sync button. Here you have to be able to estimate the amount of time the A/V sync is out. Look for people speaking, Gun fire, door slamming, etc where it is easier to match the sound to the event. If the Audio comes before the Video, then move the slider in +'ve direction to the amount you have estimated. Click on Done, then click Save. In a short time you will have a new MPG file, do NOT shut down MPEG2VCR. Now play the movie, preferably with WinDVD, to check if the sync is correct. If a small adjustment needs to be done (I never get it right first time!) then jump back to MPEG2VCR and adjust the slider a bit more in the direction that's needed. Hit Save again and when done, re-check the file. Repeat until it is fixed.

    4. Sometimes just a simple De-multiplex with TMPGEnc and a Multiplex with MPEG2VCR with NO audio offset applied can fix A/V sync problems. This is particularly true if using the FlaskMPEG/Panasonic Plug-in method for creating the MPG.

    5. If you now have the A/V sync correct at the start of the movie but is out near the end, then move onto the next solution.
    ===============================================
    [bold] Audio is in sync at start but progressively goes further out as you play the movie. [/bold]
    1. The basic principle involved here is to strip out the Audio file (de-mux) then stretch or compress the audio frequency, 44.1kHz, and re-sample to 44.1 Then convert to *.MP2 format and re-multiplex with video stream.

    2. Demux the MPG file so we can manipulate the Audio file. Run TMPGEnc, click on File and select MPEG Tools. Select Simple De-multiplex tab and for Input, browse to your problem MPG. Video and Audio output names will be automatically generated. The Audio being *.MP2 and video being *.M1V or *.M2V. Click Run and wait until its finished. Exit TMPGEnc.

    3. We now have to estimate the approx time, in seconds, that the audio is out of sync and nearest to the end of the movie as possible. Simply play the original movie with WinDVD or similar player. Windows Media Player is not recommended as it can A/V sync problems of its own. Move slider to near the end of the movie and look for speech, gun fire, explosions, door slamming, etc where you have a precise Audio to Video match up. Estimate the time difference and not the length of the movie. Lets say we find the Audio trails the Video by about 1 second and the movie length was 48 min or 2880 sec (the door slams and about 1 sec later we hear the thud).

    3. Run Goldwave and load in the *.MP2 file. Its also best to turn OFF the Undo feature to speed up the conversions (in Options / File...) Click on Effects and then Playback Rate. We need to change the 44100 Hz to sync the movie, use these formulae:

    New Hz (Audio trails Video) = (Movie length in sec + Out of Sync in sec)/(Movie length in sec) * 44100

    or

    New Hz (Audio precedes Video) = (Movie length in sec - Out of Sync in sec)/(Movie length in sec) * 44100

    So for our example, we have:

    New Hz = (48x60 + 1) / (43x60) * 44100 = 44115

    So change the Rate from 44100 to 44115 (or the number you calculated) and hit OK. Now click Effects again and select Resample. Change the 44115 (or what ever figure you have) back to 44100 and hit OK. Once the conversion is finished, hit Save. For Type select Wave (*.wav) and Attributes as 16bit, Stereo, Signed. Change File name if needed and hit Save. When it finish's answer No and exit the program.

    4. We now need to convert our WAV file back to an MP2 form. TMPGEnc is the simplest to use for this. Run TMPGEnc, and click File, then New Project to clear out old settings. For Stream Type select Audio Only and for Audio Source, browse to our new WAV file and Open it. Rename the Output file name to something different than the original MP2 file. Now click Settings and change the Bitrate from 192 to 224, this is ESSENTIAL for a VCD. Do NOT change any other settings except Normalize in Setting button (do this only if the audio appears low in volume). Then click OK and finally click Start. When done, exit TMPGEnc.

    5. Run MPEG2VCR and under Tools, select MPEG System Multiplexor. Browse for the original Video *.M1V/*.M2V file after changing Files Type to All(*.*). Do the same for the new fixed Audio *.MP2 file. Now select MPEG-1 System Stream VCD or MPEG-2 Program Stream SVCD depending if its a VCD or SVCD that your trying to fix. Enter an output file name (different from the original) and click Save. When done, play the new MPG file in WinDVD and check that A/V sync has been fixed. If its still out a bit, you need to start all over again from Point 3 changing the frequency Rate a bit higher or lower. Repeat until its fixed.

    Shoey :)_X_X_X_X_X_[small]Certified Computer Technician
    http://www.afterdawn.com/general/legal.cfm
    Mobo: MSI KT4VL-6712
    CPU: AthlonXP Barton 2500+
    Ram: 512 SD-DDR (PC-2700)
    nVidia GeForce4 MX440-8x
    Maxtor ATA\133 80 gig hd
    DVD-ROM: LiteOn LTD 165H
    CDRW: Memorex52MAXX 2452[/small]
     
    Last edited by a moderator: Aug 14, 2003

Share This Page