Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 22nd February 2011, 00:45   #1  |  Link
BlueToast
Registered User
 
BlueToast's Avatar
 
Join Date: Jul 2009
Location: Missouri, US
Posts: 68
Take II: Splitting or rendering into YouTube-friendly 15 minute video parts

Original thread here.

Here is a scenario that I am having trouble with. I have these files from my camcorder:
ISREAL1.MOD
ISREAL2.MOD
ISREAL3.MOD
ISREAL4.MOD

The containers contain both video and audio. I got the following information from SMPlayer:
Quote:
Demuxer used is mpegps

Video
Resolution of 720x480 (1.3333 aspect ratio)
Bitrate of 8900 kbps
Framerate of 29.970
Format is 0x10000002
Selected codec is ffmpeg2

Audio
Format is 8192
Bitrate is 384 kbps
Rate is 48000 Hz
Channels is 2
Selected codec is ffac3
Using MeGUI and tools, I generated D2Vs for each of these MODs, followed by AVS scripts. These videos need to be deinterlaced. Here is the AVS script I use for all four:
Quote:
LoadPlugin("C:\Program Files (x86)\megui\tools\dgindex\DGDecode.dll")
DGDecode_mpeg2source("F:\location\to\file\ISREAL#.d2v", info=3)
LoadPlugin("C:\Program Files (x86)\megui\tools\avisynth_plugin\ColorMatrix.dll")
ColorMatrix(hints=true, interlaced=true, threads=0)
Load_Stdcall_Plugin("C:\Program Files (x86)\megui\tools\yadif\yadif.dll")
Yadif(order=1)
#crop
#resize
#denoise
The audio was demuxed during the D2V creation:
ISREAL1 T80 2_0ch 384Kbps DELAY 0ms.ac3
ISREAL2 T80 2_0ch 384Kbps DELAY 0ms.ac3
ISREAL3 T80 2_0ch 384Kbps DELAY 0ms.ac3
ISREAL4 T80 2_0ch 384Kbps DELAY -154ms.ac3

I have already passed the four MODs through the x264 encoder at a bitrate of 8900 kbps and have four soundless .264 files.

This is what I want to do:
* Join the four .264 videos
* Join the four .ac3 audio files
* Mux the resulting video file with the resulting audio file
* Split the massive container into 14-minute parts for uploading to YouTube

This is what I need done or want done by the end:
* Deinterlaced video content
* 14-minute parts for YouTube
* Highest quality possible (since the videos themselves are 8900 kbps, then 8900 kbps would be the bitrate at which I encode)

This is what I have tried:
* mkvmerge (GUI) and tsMuxeR (GUI); mkvmerge doesn't support .ts or .m2ts
* mkvmerge (GUI); tried to join audios and videos and mux it all together, but in the end it didn't work no matter what I tried

__________________
Intel C2Q Q9450 Yorkfield 12MB L2-Cache @ 3.2GHz, G.Skill 2x2GB DDR2-1000 (PC2 8000) DC, Corsair 750TX, ATI VisionTek Radeon HD4850 512MB, 500GB Seagate Barracuda 7200.11 SATA-II, 200GB Maxtor IDE-150
BlueToast is offline   Reply With Quote
Old 24th February 2011, 16:52   #2  |  Link
BlueToast
Registered User
 
BlueToast's Avatar
 
Join Date: Jul 2009
Location: Missouri, US
Posts: 68
I hate to bump
__________________
Intel C2Q Q9450 Yorkfield 12MB L2-Cache @ 3.2GHz, G.Skill 2x2GB DDR2-1000 (PC2 8000) DC, Corsair 750TX, ATI VisionTek Radeon HD4850 512MB, 500GB Seagate Barracuda 7200.11 SATA-II, 200GB Maxtor IDE-150
BlueToast is offline   Reply With Quote
Old 24th February 2011, 20:03   #3  |  Link
mariush
Registered User
 
Join Date: Dec 2008
Posts: 589
Container is MPG PS, video is mpeg 2, audio is ac3 ...

I would ...
1. index them with dgindex
2. extract the ac3 files, optionally decompress each one to WAV or just leave them ac3
3. load each clip into the avs script :

clip1_v = mpeg2source("clip1.d2v")
clip1_a = directshowsource("clip1.ac3")
clip1_a = clip1_a.DelayAudio(0.0) <--- optional, delay it but whatever is necessary, -0.154 for the last clip in your case

clip1 = audiodub(clip1_v,clip1_a)

(repeat for the other 3)

clip_final = clip1+clip2+clip3+clip4

yadif

clip_final (last line in script to tell avisynth what to serve in the end)

run the avs through x264 ...

x264 --tune film --preset slower --pass 1 --bitrate 4096 -o output.mkv script.avs
x264 --tune film --preset slower --pass 2 --bitrate 4096 -o output.mkv script.avs

you get a 4mbps mkv video with just the video part. 4 mbps for 720x480 SD content should be more than enough to preserve the quality and keep the size low. More than 6 mbps shouldn't make much of a difference but if have the upload bandwidth go for 8 mbps (8192), i don't care..
Youtube will convert it to about 480x360 600-800 kbps and 640x480 1 mbps so this bitrate you choose is just high enough to preserve some quality. If you want to force youtube to preserve more quality, you could try adding black borders around the video so that the frame becomes 1280x720 and then youtube will use around 2-2.5 mbps.

Run the avs through megui, encode to mp3 128-160 kbps and you get a mp3 file.

download and run mkvtoolsnix , mux the mkv (video part) with the mp3 (audio part) , go to options and tell it to split it after 14 minutes.
mariush is offline   Reply With Quote
Old 24th February 2011, 20:21   #4  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by mariush View Post
clip_final = clip1+clip2+clip3+clip4

yadif

clip_final (last line in script to tell avisynth what to serve in the end)
With that last line, you throw away the result of yadif.
Perhaps you meant the yadif line to be
clip_final = yadif(clip_final)

or just remove the last line and end with yadif.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 24th February 2011, 20:40   #5  |  Link
mariush
Registered User
 
Join Date: Dec 2008
Posts: 589
When I was saying Yadif , I was saying it in a general way , like "yadif everything" . I agree, it's not clear.

Should be more like clip_final = yadif(clip_final)

Not sure you can end up with just yadif, without entering clip_final on the last line, as there was never assigned anything to "this", or whatever the default variable is. Everything was set to clip1_v, clip1_a, clip2_v, clip2_a and so on ...
mariush is offline   Reply With Quote
Old 24th February 2011, 20:53   #6  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
You could potentially end with "yadif(clip_final)", but not "clip_final = yadif(clip_final)", as a script can never end with an assignment.

You're right that nothing was previously assigned to 'last' (not 'this'), and for that reason yadif needs to be given an explicit argument of clip_final.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 25th February 2011, 04:40   #7  |  Link
BlueToast
Registered User
 
BlueToast's Avatar
 
Join Date: Jul 2009
Location: Missouri, US
Posts: 68
Thanks, will try this when I get the opportunity!
__________________
Intel C2Q Q9450 Yorkfield 12MB L2-Cache @ 3.2GHz, G.Skill 2x2GB DDR2-1000 (PC2 8000) DC, Corsair 750TX, ATI VisionTek Radeon HD4850 512MB, 500GB Seagate Barracuda 7200.11 SATA-II, 200GB Maxtor IDE-150
BlueToast is offline   Reply With Quote
Old 20th May 2011, 03:22   #8  |  Link
BlueToast
Registered User
 
BlueToast's Avatar
 
Join Date: Jul 2009
Location: Missouri, US
Posts: 68
Ok. So I use mkvmerge to mux and split. Here is the problem:

The first part does not work. All the parts except for the first part works fine as they should. When I run any of the handful parts in SMPlayer, it shows no video and 1 second of audio from the beginning before ending the render. On YouTube the first part video is frozen on the first frame (or the frame of whichever time you skip to in the video) and the audio rolls fine; http://www.youtube.com/watch?v=qB7yLuDvBMw. But all the other videos are fine.

I used pretty much the same set of AViSynth scripts at http://forum.doom9.org/showthread.php?t=161196 (http://www.youtube.com/watch?v=NiVpqPpwIxI) -- except this was just muxed, not muxed+split. So I am thinking it is mkvmerge's fault.

OneFitsAll.avs
Code:
v1 = Import("G:\Temp\Leeland\LEELAND1.avs")
a1 = NicAC3Source("G:\Temp\Leeland\LEELAND1 T80 2_0ch 384Kbps DELAY 0ms.ac3")
a1 = DelayAudio(a1, 0)
v1 = v1.AudioDub(a1)

v2 = Import("G:\Temp\Leeland\LEELAND2.avs")
a2 = NicAC3Source("G:\Temp\Leeland\LEELAND2 T80 2_0ch 384Kbps DELAY 0ms.ac3")
a2 = DelayAudio(a2, 0)
v2 = v2.AudioDub(a2)
v2 = v2.FadeOut(125)

Dissolve(v1, v2, 125) # 125 frames = 5s @ 25fps
LEELAND1.avs
Code:
LoadPlugin("C:\Program Files (x86)\megui\tools\dgindex\DGDecode.dll")
DGDecode_mpeg2source("G:\Temp\Leeland\LEELAND1.d2v", info=3)
LoadPlugin("C:\Program Files (x86)\megui\tools\avisynth_plugin\ColorMatrix.dll")
ColorMatrix(hints=true, interlaced=true, threads=0)
Load_Stdcall_Plugin("C:\Program Files (x86)\megui\tools\yadif\yadif.dll")
Yadif(order=1)
#crop
Spline36Resize(1280,720) # Spline36 (Neutral)
#denoise
LEELAND2.avs
Code:
LoadPlugin("C:\Program Files (x86)\megui\tools\dgindex\DGDecode.dll")
DGDecode_mpeg2source("G:\Temp\Leeland\LEELAND2.d2v", info=3)
LoadPlugin("C:\Program Files (x86)\megui\tools\avisynth_plugin\ColorMatrix.dll")
ColorMatrix(hints=true, interlaced=true, threads=0)
Load_Stdcall_Plugin("C:\Program Files (x86)\megui\tools\yadif\yadif.dll")
Yadif(order=1)
#crop
Spline36Resize(1280,720) # Spline36 (Neutral)
#denoise
FYI, the .264 (RAWAVC) file renders perfectly fine in SMPlayer.
__________________
Intel C2Q Q9450 Yorkfield 12MB L2-Cache @ 3.2GHz, G.Skill 2x2GB DDR2-1000 (PC2 8000) DC, Corsair 750TX, ATI VisionTek Radeon HD4850 512MB, 500GB Seagate Barracuda 7200.11 SATA-II, 200GB Maxtor IDE-150

Last edited by BlueToast; 20th May 2011 at 03:28.
BlueToast is offline   Reply With Quote
Old 20th May 2011, 08:14   #9  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Is there some reason you're not joining them when creating the D2V project file right at the beginning?

And aren't these things 4:3? If so, won't resizing them to 1280x720 make them play with the wrong aspect ratio? Yes, I know mariush suggested that, but his suggestion also involved padding with black bars so you don't ruin the aspect ratio. Me, I'd just resize to 640x480 and be done with it (perhaps after a slight crop from the sides). It's not as if this will make a whole lot of difference, given YouTube's encoding practices.

And if you're having trouble making YouTube compatible MKVs, encode it using XviD at quant 2 or 3 and upload that. It'll have no problems with XviD AVIs. And if you upload 720x480 videos to YouTube, it'll keep that 1.5:1 ratio and it'll play with the wrong aspect ratio (they won't be resized to 640x480). You can correct that with a tag, but it's better to do a proper resize to begin with, in my opinion.
manono is offline   Reply With Quote
Old 20th May 2011, 16:13   #10  |  Link
BlueToast
Registered User
 
BlueToast's Avatar
 
Join Date: Jul 2009
Location: Missouri, US
Posts: 68
Quote:
Originally Posted by manono View Post
Is there some reason you're not joining them when creating the D2V project file right at the beginning?
I am not sure I understand? :?

I have multiple segments directly from my camcorder in .MOD files that I am generating the D2Vs from (hence multiple D2Vs, v1+a1, v2+a2, v3+a3, etc).

Quote:
Originally Posted by manono View Post
And aren't these things 4:3?
The original videos themselves are 16:9, so resizing them is not a problem.

The only parts of this thread that are currently relevant to my situation is the part about splitting into 15-minute parts to which mkvmerge was suggested. In the OP I think I used 4:3 just to know how to handle it in a scenario like that.

Here's a memory refresh. I did three videos using essentially the same AVS scripts and literally the same encoding and muxing procedures. I used the same encoding profile at 4000kbps on x264 (64-bit) with the 'Automated high quality' thing selected for 3-pass encoding. Here are the three videos:

This one gives massive coloring artifacts. I don't know what is wrong. The .264 is just fine! =(
http://www.youtube.com/watch?v=eilwQYpFuCk

This one is in fact longer than the one above, yet gives no problems at all. Everything is fine in this video. This video and the one above were recording using the same camcorder. So why is this one fine and the above not when the same procedures and same AVS scripts were used?
http://www.youtube.com/watch?v=B1o4A-WyWKY

This is the video when I first made the AVS scripts I used for the above two. Works perfectly fine -- same procedures.
http://www.youtube.com/watch?v=NiVpqPpwIxI
__________________
Intel C2Q Q9450 Yorkfield 12MB L2-Cache @ 3.2GHz, G.Skill 2x2GB DDR2-1000 (PC2 8000) DC, Corsair 750TX, ATI VisionTek Radeon HD4850 512MB, 500GB Seagate Barracuda 7200.11 SATA-II, 200GB Maxtor IDE-150
BlueToast is offline   Reply With Quote
Old 20th May 2011, 16:22   #11  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Quote:
Originally Posted by BlueToast View Post
I am not sure I understand? :?

I have multiple segments directly from my camcorder in .MOD files that I am generating the D2Vs from (hence multiple D2Vs, v1+a1, v2+a2, v3+a3, etc).
You can open all at the same time in DGIndex and get a D2V project file for all four together as well as a single audio file. Then you can use a single AviSynth script.
Quote:
The original videos themselves are 16:9, so resizing them is not a problem.
OK, but I was just going by this:

Quote:
Resolution of 720x480 (1.3333 aspect ratio)
I figured 1.3333 aspect ratio was another way of saying 4:3. I don't know what else it could mean in that context.
manono is offline   Reply With Quote
Old 20th May 2011, 16:43   #12  |  Link
BlueToast
Registered User
 
BlueToast's Avatar
 
Join Date: Jul 2009
Location: Missouri, US
Posts: 68
Quote:
Originally Posted by manono View Post
You can open all at the same time in DGIndex and get a D2V project file for all four together as well as a single audio file. Then you can use a single AviSynth script.

OK, but I was just going by this:


I figured 1.3333 aspect ratio was another way of saying 4:3. I don't know what else it could mean in that context.
Alright, now I am confused.

The original .MOD segments are 720x480. With the AViSynth scripts I am upscaling them to 1280x720 to take advantage of the significant leap from a 0.5Mbps bitrate to a 2Mbps bitrate on YouTube.

I did this to three videos in total. The first video I did this to (and thus the creation of scripts I used for the latter) is http://www.youtube.com/watch?v=NiVpqPpwIxI.

Of the latter two, the longer and larger one works perfectly fine on YouTube under the same scripts, same procedures, same everything. Why does the other one have the gray artifacting? Both videos should either work or should not work, unless there is a glitch or something somewhere.. or that this might be a hit or miss situation on YouTube?

Quote:
You can open all at the same time in DGIndex and get a D2V project file for all four together
Could you provide me a script example? :?

Thanks man, I appreciate your time and help!
__________________
Intel C2Q Q9450 Yorkfield 12MB L2-Cache @ 3.2GHz, G.Skill 2x2GB DDR2-1000 (PC2 8000) DC, Corsair 750TX, ATI VisionTek Radeon HD4850 512MB, 500GB Seagate Barracuda 7200.11 SATA-II, 200GB Maxtor IDE-150
BlueToast is offline   Reply With Quote
Old 20th May 2011, 16:59   #13  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Quote:
Originally Posted by BlueToast View Post
Could you provide me a script example? :?
Making a D2V has nothing to do with the script. Open all 4 at the same time in DGIndex. Use the 'Add' button if you have to. It's just a suggestion as I don't see the point of encoding four separate times if it can all be done at once.

However, I don't make MKVs and can't help you with that part of it. But I do have close to a thousand videos on YouTube and they've all been created as XviD AVIs. And there's never any problem splitting up large XviD files.
manono is offline   Reply With Quote
Old 20th May 2011, 18:12   #14  |  Link
BlueToast
Registered User
 
BlueToast's Avatar
 
Join Date: Jul 2009
Location: Missouri, US
Posts: 68
Quote:
Originally Posted by manono View Post
Making a D2V has nothing to do with the script. Open all 4 at the same time in DGIndex. Use the 'Add' button if you have to. It's just a suggestion as I don't see the point of encoding four separate times if it can all be done at once.

However, I don't make MKVs and can't help you with that part of it. But I do have close to a thousand videos on YouTube and they've all been created as XviD AVIs. And there's never any problem splitting up large XviD files.
Alright, I do have a question about XviD. One time I tried out XviD to compare to x264. From my comparison, I found XviD to be several grades worse than x264 in quality. What did I do wrong? =(

EDIT: Regarding DGIndex, I will try out your suggestion. I used MeGUI to create the indexes from DGIndex -- which did it one video file at a time. I took a quick look at DGIndex directly and I see that it is fairly easy and self-explanatory to use. I will give your suggestion of having one D2V a try. This should totally simplify some things, thanks! =D

EDIT2: Wait, if I did that, how would I crossfade ~125 frames (~5s) between SegmentA and SegmentB?
__________________
Intel C2Q Q9450 Yorkfield 12MB L2-Cache @ 3.2GHz, G.Skill 2x2GB DDR2-1000 (PC2 8000) DC, Corsair 750TX, ATI VisionTek Radeon HD4850 512MB, 500GB Seagate Barracuda 7200.11 SATA-II, 200GB Maxtor IDE-150

Last edited by BlueToast; 20th May 2011 at 18:16.
BlueToast is offline   Reply With Quote
Old 20th May 2011, 18:31   #15  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
You didn't say anything about crossfades before. I expect you'd have to split up the videos within the single script and then apply the fades.

Quote:
I found XviD to be several grades worse than x264 in quality. What did I do wrong? =(
How should I know? Bitrate, maybe? As I said before, do a quant 2 (or 3) encode and it'll look fine. After YouTube gets through butchering it I doubt there'll be any noticeable difference between a video encoded as x264 and one encoded as XviD. The XviD one will be larger in size, though, for the same quality as an x264 video.
manono is offline   Reply With Quote
Old 21st May 2011, 18:20   #16  |  Link
BlueToast
Registered User
 
BlueToast's Avatar
 
Join Date: Jul 2009
Location: Missouri, US
Posts: 68
Quote:
Originally Posted by manono View Post
You didn't say anything about crossfades before. I expect you'd have to split up the videos within the single script and then apply the fades.


How should I know? Bitrate, maybe? As I said before, do a quant 2 (or 3) encode and it'll look fine. After YouTube gets through butchering it I doubt there'll be any noticeable difference between a video encoded as x264 and one encoded as XviD. The XviD one will be larger in size, though, for the same quality as an x264 video.
How would you split a single video (via single .d2v index) within a single script to apply crossfades? Would it first be something like...
Code:
v1 = v1.Trim(initial, final) # Frames between initial and final = v1
And then eventually ending with a Dissolve(v1, v2, v3, ..., 125)?

While two different XviD-encoded muxes are uploading to YouTube (going to compare and see the differences between the MKV vs MP4 mux), I have a side question.



Say I have a 640x480 video. The resolutions I could fit it in for are 720x480 (height is already in place), 1280x720, or 1080p. (a) One method would be to upscale width-to-width and then apply a centered crop, but this could potentially result in some things at the top and bottom being cut out (this is entirely up to me/whoever does this as to whether this method would work for their particular video because on some videos it would be fine to do). (b) The second, possibly more common method, would be to upscale height-to-height if necessary and add black bars to both left and right sides. How would you add black bars to both sides in a script?
__________________
Intel C2Q Q9450 Yorkfield 12MB L2-Cache @ 3.2GHz, G.Skill 2x2GB DDR2-1000 (PC2 8000) DC, Corsair 750TX, ATI VisionTek Radeon HD4850 512MB, 500GB Seagate Barracuda 7200.11 SATA-II, 200GB Maxtor IDE-150
BlueToast is offline   Reply With Quote
Old 22nd May 2011, 00:15   #17  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
I don't work with dissolves much so perhaps someone else can help. The few times I've dissolved something I had to be very careful how I did it so I didn't lose audio synch. If the audio isn't a concern (if it doesn't have to match up with the video), then dissolves are done as described in the AviSynth page on them:

http://avisynth.org/mediawiki/Dissolve

And rather than having 4 different clips to dissolve into each other, you'd be splitting your single clip up:

X=Last
A=X.Trim(aa,bb)
B=X.Trim(cc,dd)

and so on. Play around with it. It's not hard to figure out.

As for how to turn a 640x480 video into a 1280x720 one, scale to 720p and add black bars to the sides:

Lanczos4Resize(960,720)
AddBorders(160,0,160,0)

The other way is to crop from the top and bottom and scale up:

Crop(0,60,0,-60) # or any combination from top and bottom totaling 120
Lanczos4Resize(1280,720)

And when scaling up by a lot, I always use NNEDI3 for that:]

Crop(0,60,0,-60)
nnedi3_rpow2(rfactor=2,cshift="lanczosresize",fwidth=1280,fheight=720)

And then sharpen afterwards. Unlike some others, I don't really see the point of uploading something in Hi-Def to YouTube that's from a Standard-Def source. A lot of the time you or the people you want to view your video won't get it streamed smoothly and they'll just get mad at the stuttery playback and the waits for buffering. I'm happy uploading a decent quality 640x480 video, often filtering it to make it more compressible so it looks better after being reencoded by them.
manono is offline   Reply With Quote
Reply

Tags
15-minute parts, joining, merging, splitting, youtube

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:54.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.