Zarxrax
02-27-2013, 05:38 PM
I am going to go over the process of what is typically involved in the creation of an AMV Hell or AMV Minis.
The process has changed greatly over the years, and I am always trying to figure out ways to further automate and streamline the entire process. The following represents what I am doing for AMV Hell 6.
The entries
First of all, the process begins by allowing people to send me their videos and video info.
Originally, this had been handled by email. But email ended up being rather inefficient and confusing at times. With gmail, conversations often got all mixed up. Messages from different people may end up in the same conversation threads, or replies from someone could end up in a separate conversation than their original message. It was just really hard to track everything accurately.
To help make things more straightforward, I set up a system whereby users can enter their video data into a simple form, and then it gets made into a private forum thread. This has a number of good advantages, mainly:
- each video is separated out into its own thread
- conversation with the creator about that specific video stays in one place
- video information is in a consistent format
- it can easily be shared with other people, such as someone who has been appointed to be a judge
Processing the videos
Once I have viewed the videos, and managed to figure out which ones are going to be used in the final project, the next step is processing the videos to make sure that they are all in a consistent format and to fix up any glaring technical problems. For this, I primarily use Avisynth, specifically with the AvsPmod editor.
To begin with, all of the videos are gathered into a single folder. Then, I run an AvsPmod macro that I have created (basically a python script) which generates an AVS script for each video file.
AMV_Minis Batch.py
import os
# Get the directory containing source files
dirname = avsp.GetDirectory()
if dirname:
# Generate each of the avisynth scripts
for filename in os.listdir(dirname):
fullname = os.path.join(dirname, filename)
nospacefilename = filename.replace(' ', '_')
nospacefullname = os.path.join(dirname, nospacefilename)
if os.path.isfile(fullname):
# Get the extension-based template string
srctxt = avsp.GetSourceString(fullname)
# Create the script string
scripttxt = srctxt + '\n' + 'minis(resize=1, cropp=0, deint=1)'
# Write the script text to a file
f = open(nospacefullname + '.avs', 'w')
f.write(scripttxt)
f.close()
The scripts that are generated are fairly simple, they just contain 2 lines. One to import the video file, and another that is a special avisynth function I have created to do all of the heavy processing.
amvminis.avsi
#resize: 0 = none; 1 = auto (default); 2 = 640x480; 3 = 848x480;
#cropp: 0 = none (default); 1 = auto
#deint: 0 = none; 1 = tfm (default); 2 = tdeint
function minis(clip c, int "resize", int "cropp", int "deint")
{
resize = default(resize, 1)
cropp = default(cropp, 0)
deint = default(deint, 1)
video = c.ConvertToYV12()
video = (deint==1) ? video.tfm() : video
video = (deint==2) ? video.tdeint(mode=2,type=3) : video
video = (cropp==1) ? video.AutoCrop(0) : video
video = (resize==1 && float(video.width) / float(video.height) < 1.4) ? video.spline36resize(640,480) : video
video = (resize==1 && float(video.width) / float(video.height) >= 1.4) ? video.spline36resize(848,480) : video
video = (resize==2) ? video.spline36resize(640,480) : video
video = (resize==3) ? video.spline36resize(848,480) : video
video = (video.framerate>=29.9 && video.framerate<=30.0) ? video.Tdecimate().ChangeFPS("ntsc_film") : video.ChangeFPS("ntsc_film")
video = video.SSRC(48000)
video = (video.width == 640) ? video.AddBorders(104,0,104,0) : video
return video
}
Now this function does a number of useful things. It resizes all of the videos to 848x480 while trying to guess if it should be 4:3 or 16:9 (based on the original resolution). If it guesses wrong, I can manually override the choice. There is also an option to automatically crop off black borders. This is especially useful because for some reason, a ton of people send me files where the ENTIRE video is encapsulated by huge borders on all sides, or they send me a 16:9 letter boxed video which shouldnt be letterboxed. The function also tries to remove any interlacing, and it makes sure the framerate is set to 23.976. It also set the audio to a sample rate of 48000hz.
For the most part, this function takes care of everything for me, but I still need to open every script and visually check it, to see whether I need to change the aspect ratio or crop.
Also at this stage, this is where I may discover that a file is unusable for some technical reason. Generally, I can't load MOV or DV files. Sometimes WMV files fail in a weird way where the frames get out of sync with the audio. 95% of WMV files work, but there are always a couple that might give me problems. Please dont send me MOV, DV, or WMV files.
I also sometimes find that someone has exported their video with 6 channel audio. That will cause it to fail as well.
At this point in the stage, it can sometimes be too late for someone to fix their video, because I am already getting everything put together. Its important that you subscribe to the entries forum so you can get email notifications when I reply to your threads. Otherwise you may never find out that I had a problem with your video at the last minute.
Once the scripts are generated, and I have visually inspected each one, I have a batch script that I run on all of the AVS files to normalize the audio. I use replaygain technology which seems to do an excellent job at keeping the audio levels the same across videos.
wavegain.bat
@echo off
::AVSGain: apply Replaygain to AVS files
if %1X==X goto ALL
:LOOP
for %%I in (%1) do (
echo Applying replaygain to %%I
echo.>>%%~fsI
"F:\AMV Minis\COMMON\wavi.exe" %%I - | "F:\AMV Minis\COMMON\wavegain2.exe" --gain 5 - -e echo AmplifydB^(%%TRACK_GAIN%%^) ^>^> %%~fsI
)
SHIFT
@if %1X==X goto END
@goto LOOP
:ALL
for /f "delims=" %%I in ('dir *.avs /b') do (
echo Applying replaygain to %%I
echo.>>%%~fsI
"F:\AMV Minis\COMMON\wavi.exe" %%I - | "F:\AMV Minis\COMMON\wavegain2.exe" --gain 5 - -e echo AmplifydB^(%%TRACK_GAIN%%^) ^>^> %%~fsI
)
:END
This batch script basically pipes the audio from each avs script into a commandline app called wavegain2, which calculates the amount of audio adjustment that needs to occur, and then writes a line into the avs script to adjust by that amount.
Once that is done, next I use virtualdub to batch encode all of the AVS scripts to AVI files using the UTvideo lossless codec.
And that finishes up that part!
Continued in next post...
The process has changed greatly over the years, and I am always trying to figure out ways to further automate and streamline the entire process. The following represents what I am doing for AMV Hell 6.
The entries
First of all, the process begins by allowing people to send me their videos and video info.
Originally, this had been handled by email. But email ended up being rather inefficient and confusing at times. With gmail, conversations often got all mixed up. Messages from different people may end up in the same conversation threads, or replies from someone could end up in a separate conversation than their original message. It was just really hard to track everything accurately.
To help make things more straightforward, I set up a system whereby users can enter their video data into a simple form, and then it gets made into a private forum thread. This has a number of good advantages, mainly:
- each video is separated out into its own thread
- conversation with the creator about that specific video stays in one place
- video information is in a consistent format
- it can easily be shared with other people, such as someone who has been appointed to be a judge
Processing the videos
Once I have viewed the videos, and managed to figure out which ones are going to be used in the final project, the next step is processing the videos to make sure that they are all in a consistent format and to fix up any glaring technical problems. For this, I primarily use Avisynth, specifically with the AvsPmod editor.
To begin with, all of the videos are gathered into a single folder. Then, I run an AvsPmod macro that I have created (basically a python script) which generates an AVS script for each video file.
AMV_Minis Batch.py
import os
# Get the directory containing source files
dirname = avsp.GetDirectory()
if dirname:
# Generate each of the avisynth scripts
for filename in os.listdir(dirname):
fullname = os.path.join(dirname, filename)
nospacefilename = filename.replace(' ', '_')
nospacefullname = os.path.join(dirname, nospacefilename)
if os.path.isfile(fullname):
# Get the extension-based template string
srctxt = avsp.GetSourceString(fullname)
# Create the script string
scripttxt = srctxt + '\n' + 'minis(resize=1, cropp=0, deint=1)'
# Write the script text to a file
f = open(nospacefullname + '.avs', 'w')
f.write(scripttxt)
f.close()
The scripts that are generated are fairly simple, they just contain 2 lines. One to import the video file, and another that is a special avisynth function I have created to do all of the heavy processing.
amvminis.avsi
#resize: 0 = none; 1 = auto (default); 2 = 640x480; 3 = 848x480;
#cropp: 0 = none (default); 1 = auto
#deint: 0 = none; 1 = tfm (default); 2 = tdeint
function minis(clip c, int "resize", int "cropp", int "deint")
{
resize = default(resize, 1)
cropp = default(cropp, 0)
deint = default(deint, 1)
video = c.ConvertToYV12()
video = (deint==1) ? video.tfm() : video
video = (deint==2) ? video.tdeint(mode=2,type=3) : video
video = (cropp==1) ? video.AutoCrop(0) : video
video = (resize==1 && float(video.width) / float(video.height) < 1.4) ? video.spline36resize(640,480) : video
video = (resize==1 && float(video.width) / float(video.height) >= 1.4) ? video.spline36resize(848,480) : video
video = (resize==2) ? video.spline36resize(640,480) : video
video = (resize==3) ? video.spline36resize(848,480) : video
video = (video.framerate>=29.9 && video.framerate<=30.0) ? video.Tdecimate().ChangeFPS("ntsc_film") : video.ChangeFPS("ntsc_film")
video = video.SSRC(48000)
video = (video.width == 640) ? video.AddBorders(104,0,104,0) : video
return video
}
Now this function does a number of useful things. It resizes all of the videos to 848x480 while trying to guess if it should be 4:3 or 16:9 (based on the original resolution). If it guesses wrong, I can manually override the choice. There is also an option to automatically crop off black borders. This is especially useful because for some reason, a ton of people send me files where the ENTIRE video is encapsulated by huge borders on all sides, or they send me a 16:9 letter boxed video which shouldnt be letterboxed. The function also tries to remove any interlacing, and it makes sure the framerate is set to 23.976. It also set the audio to a sample rate of 48000hz.
For the most part, this function takes care of everything for me, but I still need to open every script and visually check it, to see whether I need to change the aspect ratio or crop.
Also at this stage, this is where I may discover that a file is unusable for some technical reason. Generally, I can't load MOV or DV files. Sometimes WMV files fail in a weird way where the frames get out of sync with the audio. 95% of WMV files work, but there are always a couple that might give me problems. Please dont send me MOV, DV, or WMV files.
I also sometimes find that someone has exported their video with 6 channel audio. That will cause it to fail as well.
At this point in the stage, it can sometimes be too late for someone to fix their video, because I am already getting everything put together. Its important that you subscribe to the entries forum so you can get email notifications when I reply to your threads. Otherwise you may never find out that I had a problem with your video at the last minute.
Once the scripts are generated, and I have visually inspected each one, I have a batch script that I run on all of the AVS files to normalize the audio. I use replaygain technology which seems to do an excellent job at keeping the audio levels the same across videos.
wavegain.bat
@echo off
::AVSGain: apply Replaygain to AVS files
if %1X==X goto ALL
:LOOP
for %%I in (%1) do (
echo Applying replaygain to %%I
echo.>>%%~fsI
"F:\AMV Minis\COMMON\wavi.exe" %%I - | "F:\AMV Minis\COMMON\wavegain2.exe" --gain 5 - -e echo AmplifydB^(%%TRACK_GAIN%%^) ^>^> %%~fsI
)
SHIFT
@if %1X==X goto END
@goto LOOP
:ALL
for /f "delims=" %%I in ('dir *.avs /b') do (
echo Applying replaygain to %%I
echo.>>%%~fsI
"F:\AMV Minis\COMMON\wavi.exe" %%I - | "F:\AMV Minis\COMMON\wavegain2.exe" --gain 5 - -e echo AmplifydB^(%%TRACK_GAIN%%^) ^>^> %%~fsI
)
:END
This batch script basically pipes the audio from each avs script into a commandline app called wavegain2, which calculates the amount of audio adjustment that needs to occur, and then writes a line into the avs script to adjust by that amount.
Once that is done, next I use virtualdub to batch encode all of the AVS scripts to AVI files using the UTvideo lossless codec.
And that finishes up that part!
Continued in next post...