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
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 6th August 2020, 17:22   #1  |  Link
skywalker
Registered User
 
Join Date: Sep 2017
Posts: 37
Encoding script AviSynth with FFmpeg

Hey guys, how are you?

I would like to know if it is possible to encode an avisynth script using FFmpeg without loss of quality with. I want at maximum quality (lossless). I don't care if the videos are going to get big in size, I appreciate the quality more.

How do I do this step by step?

Can I create a bat file to do this?

What are the command lines to do this?

How do I do this step by step?

Can I create a bat file to do this?

What are the command lines for doing this?

If that is possible, could someone donate me a little time to teach me how to do this? I will be immensely grateful.

xD

Last edited by skywalker; 6th August 2020 at 17:51.
skywalker is offline   Reply With Quote
Old 6th August 2020, 17:26   #2  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,733
Lossless is going to be bigger in size so better just use the original video track.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 6th August 2020, 18:01   #3  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,695
Have you actually done any tests? I fully understand the quest for quality, but you may or may not be able to see the differences between various ways to encode a particular video, and you won't know for sure if you can see any differences until and unless you do your own tests.

First of all, you don't mention the source of your videos. Are they from a video camera? If so, they have already been massively compressed. The same statement applies to DVD, BD, streaming sources, etc. Unless you are in a studio and have the ability to capture uncompressed directly from the unaltered output of a professional video camera, your video source has already been compressed and will contain artifacts from that operation.

So, it makes zero sense to take such a source and store it as uncompressed.

You can use a "lossless" compression to at least make the file size smaller. It would be silly not to do this, because uncompressed not only consumes massive amounts of storage, but can be difficult to play back without hiccups.

My advice is to do tests, as I've already recommended, and to A/B between the original and h.264 or h.265 at a high bitrate.

ffmpeg can cut videos losslessly, and if that is all you want to do then something like this:

ffmpeg -i MAH05691.MP4 -ss 00:15:29.112 -c copy -t 00:07:14.250 Action_Cam_01.mp4

(which I took from something I actually did) will work. Just substitute your own timecodes.
johnmeyer is offline   Reply With Quote
Old 6th August 2020, 18:16   #4  |  Link
skywalker
Registered User
 
Join Date: Sep 2017
Posts: 37
Quote:
Originally Posted by johnmeyer View Post
Have you actually done any tests? I fully understand the quest for quality, but you may or may not be able to see the differences between various ways to encode a particular video, and you won't know for sure if you can see any differences until and unless you do your own tests.

First of all, you don't mention the source of your videos. Are they from a video camera? If so, they have already been massively compressed. The same statement applies to DVD, BD, streaming sources, etc. Unless you are in a studio and have the ability to capture uncompressed directly from the unaltered output of a professional video camera, your video source has already been compressed and will contain artifacts from that operation.

So, it makes zero sense to take such a source and store it as uncompressed.

You can use a "lossless" compression to at least make the file size smaller. It would be silly not to do this, because uncompressed not only consumes massive amounts of storage, but can be difficult to play back without hiccups.

My advice is to do tests, as I've already recommended, and to A/B between the original and h.264 or h.265 at a high bitrate.

ffmpeg can cut videos losslessly, and if that is all you want to do then something like this:

ffmpeg -i MAH05691.MP4 -ss 00:15:29.112 -c copy -t 00:07:14.250 Action_Cam_01.mp4

(which I took from something I actually did) will work. Just substitute your own timecodes.
Actually I have a video clip, it has an average of 5 minutes. I did an avisynth script with improvements for the video.

I usualy did the encoder to get the out video with MEGUI. But I wanted to make this encoder by FFmpeg using a variable bitrate rate. But I don't know how to do this for FFmpeg. I think that maybe this is better than in MeGui.
skywalker is offline   Reply With Quote
Old 6th August 2020, 18:40   #5  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,733
They both probably use the same encoder, if not the same version then quite close anyway. MeGUI is just a GUI.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 6th August 2020, 18:46   #6  |  Link
skywalker
Registered User
 
Join Date: Sep 2017
Posts: 37
Thank u guys.
skywalker is offline   Reply With Quote
Old 6th August 2020, 18:50   #7  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,420
So the video is being filtered by AviSynth, and you simply want to preserve that when encoding. What you want to do in that instance is to use a lossless format as an intermediate or archive copy, but use lossy at the distribution/viewing stage. Depending on the specs of the computer involved, it may not be able to cope with playing back a losslessly-encoded file in realtime, but you absolutely want to do all the editing or filtering in the lossless space.

The answer, of course, is this:
Code:
ffmpeg -i test.avs -vcodec CODECNAME -acodec copy output.avi
where CODECNAME is the name of the video format encoder in FFmpeg. You most probably want either ffv1 or ffvhuff, but there are others (you could even use libx264 or libx265 in lossless mode if you pass the correct options).
qyot27 is offline   Reply With Quote
Old 6th August 2020, 18:58   #8  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Do you believe that your source cannot be improved at all ?
(I've spent last two weeks 'improving' a DVD series, it is tedious but I did not do it without cause).
[EDIT: well 8 series]
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 6th August 2020, 19:06   #9  |  Link
skywalker
Registered User
 
Join Date: Sep 2017
Posts: 37
Quote:
Originally Posted by qyot27 View Post
The answer, of course, is this:
Code:
ffmpeg -i test.avs -vcodec CODECNAME -acodec copy output.avi
where CODECNAME is the name of the video format encoder in FFmpeg. You most probably want either ffv1 or ffvhuff, but there are others (you could even use libx264 or libx265 in lossless mode if you pass the correct options).
Thanks, but I have an error that says:
Code:
Script error: There is no function named 'FFVideoSource'.
My script.avs: Unknown error occurred
skywalker is offline   Reply With Quote
Old 6th August 2020, 19:09   #10  |  Link
skywalker
Registered User
 
Join Date: Sep 2017
Posts: 37
Quote:
Originally Posted by StainlessS View Post
Do you believe that your source cannot be improved at all ?
(I've spent last two weeks 'improving' a DVD series, it is tedious but I did not do it without cause).
[EDIT: well 8 series]
I do believe, and a lot. I've been trying my best DVD sources for a long time. It funy me.
skywalker is offline   Reply With Quote
Old 6th August 2020, 19:26   #11  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,420
Quote:
Originally Posted by skywalker View Post
Thanks, but I have an error that says:
Code:
Script error: There is no function named 'FFVideoSource'.
My script.avs: Unknown error occurred
You need to make sure the script is written correctly. Most GUIs get by with a certain amount of hand-holding, obfuscating where tools are installed, or relying on copies they provide themselves in directories they have control over rather than it being available system-wide; if you're setting the GUIs aside, you've got to make sure the right plugins are installed and that the script works under a normal AviSynth+ system installation and usage first. Then you can give it to FFmpeg.
qyot27 is offline   Reply With Quote
Old 6th August 2020, 20:13   #12  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,904
Exactly... Make sure you:

A) Have the latest Avisynth+ version installed: https://github.com/AviSynth/AviSynthPlus/releases
B) Have the right plugins inside the "C:\Program Files\Avisynth\Plugin+" directory
C) Make sure that if you're using Avisynth x64, your plugins are 64bit and your ffmpeg build is 64bit as well (same for 32bit) https://ffmpeg.zeranoe.com/builds/
D) Your environment is ok and your script is working

AVSMeter is your friend for checking the environment: https://forum.doom9.org/showthread.php?t=173259
AVSPmod is your friend for writing and testing scripts: https://forum.doom9.org/showthread.php?t=175823


Side note: unlike some other fella, I'm totally against GUIs like MeGUI. Although it's true that they use the very same things you would be using with a BAT like Avisynth, x264, x265, ffmpeg etc, they choose the options for you most of the time and you have little to no idea about what settings it's using. In particular, MeGUI has been using some rather controversial settings in x264 for years, while with a BAT you have total control over what's going on and what settings to use. So... I understand that it's gonna be a big step for you to switch from a GUI based approach to a command line one, but believe me, it's totally worth it and you'll never look back ever again.
FranceBB is offline   Reply With Quote
Old 6th August 2020, 21:19   #13  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
I don't agree on your sentiment against GUIs. Bat is one of the worst command languages that ever existed and one of the worst products MS ever created, so it's not particular good advice either and understanding PowerShell on a level that it's useful is actually hard, even for an experienced programmer, if it would be so easy there would be a lot more people here using console related tools, like for instance mpv.
stax76 is offline   Reply With Quote
Old 6th August 2020, 22:10   #14  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,904
Quote:
Originally Posted by stax76 View Post
if it would be so easy there would be a lot more people here using console related tools, like for instance mpv.
MPV is my favorite player on Linux. :P I use it all the time. Same goes for Windows, although I keep both MPC-HC and PotPlayer installed and updated "just in case".

Quote:
Originally Posted by stax76 View Post
understanding PowerShell on a level that it's useful is actually hard, even for an experienced programmer
C'mon, it's not so terribly bad; besides, there are some very good explanations (with tests) for free on the Microsoft Virtual Academy with functions, commands and other things explained directly by Jeffrey Snover (the inventor of PowerShell). I watched 'em all, they're definitely useful and Jeffrey is also kinda funny to listen to as he puts a joke every now and then to keep people entertained.


Anyway, I know that you're the author of Staxrip which has a UI. I've never used it, so I can't say anything about it, but since people find it useful, it's nice that you develop and maintain it, so well done . You see, I'm not against each and every GUI, in the sense that it's not like I would never use a GUI, "period", but the reason why I try to avoid them is 'cause most of the time devs just don't let users know what things are going on under the hood and take decisions for them, however if a GUI allows the user to choose everything and it's transparent about what is doing, then I have no problem about that and I'm actually in favor of it in that case. I'll show you an example: take AVID Media Composer. If you use it and apply a resizing filter for instance, you can easily draw and move x and y axes to decide how much you want to "zoom" in the image and then you can render your effect and export. Too bad that the "zoom" is actually a crop and upscale, so how does it do it? Which resizing kernel does it use? And what about interlaced contents? Another example would be 10bit contents "imported" in an 8bit timeline. What is it gonna do? Is it gonna truncate everything to get 8bit? Is it gonna apply some sort of dithering? And what about clips with a different framerate? Is it gonna use blending? Is it gonna duplicate frames? And how about denoise filters? How do they work? Are they both spatial and temporal? Which blocks/macroblock size are gonna be analysed? And how about the frames in the temporal denoise? And which Transform do they use? DFT? And at which bitdepth? And so on and on and on... I could go on forever... There are countless examples where GUIs don't really allow you to tweak parameters or know what is going on under the hood, which is why I love Avisynth and the command line and I hate closed source UI, 'cause I know EXACTLY what is going on in the command line while I have little to no clue about closed source UI...

Last edited by FranceBB; 6th August 2020 at 22:17.
FranceBB is offline   Reply With Quote
Old 7th August 2020, 09:51   #15  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
Quote:
Side note: unlike some other fella, I'm totally against GUIs like MeGUI.
Quote:
I know that you're the author of Staxrip which has a UI. I've never used it, so I can't say anything about it
I'm the original author and one of about 5 people that currently maintain it. So you never used it, can't say anything about it except that you are totally against it, that's amazing.

Quote:
Although it's true that they use the very same things you would be using with a BAT like Avisynth, x264, x265, ffmpeg etc, they choose the options for you most of the time and you have little to no idea about what settings it's using.
Sorry but your main argument is completely wrong, in staxrip there is a code preview and a code editor and the interaction between code and GUI is achieved by numerous methods like splitting the script into categorized sections, with macros, environment variables, script evaluation and script generation.

Last edited by stax76; 7th August 2020 at 10:16.
stax76 is offline   Reply With Quote
Old 7th August 2020, 11:31   #16  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,904
Quote:
Originally Posted by stax76 View Post
I'm the original author and one of about 5 people that currently maintain it. So you never used it, can't say anything about it except that you are totally against it, that's amazing.



Sorry but your main argument is completely wrong, in staxrip there is a code preview and a code editor and the interaction between code and GUI is achieved by numerous methods like splitting the script into categorized sections, with macros, environment variables, script evaluation and script generation.
You don't get it. I never said that I'm against StaxRip, I said that I never used it so I can't say anything about it. I'm against GUIs who don't allow users to choose settings and take decisions for them, in fact I quoted Avid Media Composer as an example. I said that I never used YOUR specific software so that I couldn't comment on that! I even "praised" you 'cause some people use it, what else do you want? XD
I'm gonna repeat it once again: I'm generally against GUIs who don't allow people to choose settings and take decisions for them, unlike the command line where you can choose everything. AVID Media Composer is an example. I even said that IF and only IF a GUI is transparent about what it's doing, then I have no problem with that and I also said that I know that you're an author of a GUI and that you might find yourself "attacked" by my statement, but that it wasn't referred to you specifically 'cause I never used Staxrip, so I can't comment about it (and I'm not planning to do so) but since users are using it you're absolutely right to maintain it and develop it so that it can help people out. You're helping the community and that's great.

Is it clear now?

I mean, don't get me wrong, I didn't really want to argue or upset you or make you angry, I mean, it wasn't my intention, but on the other hand, as I said before, I've seen many user interfaces that just don't allow users to choose things to make their life easier and I don't like that, that's why I don't like GUIs. Again, there are exceptions, sure, and if your program is one of the exceptions that allows users to do everything then great, I trust your words, but that's the way I think.

By the way, why are we even arguing about this? We're probably derailing the topic from its own original purpose. Let's call it off, shall we.

Last edited by FranceBB; 7th August 2020 at 11:40.
FranceBB is offline   Reply With Quote
Old 7th August 2020, 13:34   #17  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
It's not just this thread, you say it all the time. I'm also totally against many things (like totalitarianism) but I can keep it for me if it doesn't harm me and I'm not particularly well-informed and experienced about a topic.
stax76 is offline   Reply With Quote
Old 7th August 2020, 14:37   #18  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
Quote:
Originally Posted by FranceBB View Post
'cause I know EXACTLY what is going on in the command line while I have little to no clue about closed source UI
DGDemuxGUI (closed source) displays the command line that will be executed by DGDemux (CLI executable) and it allows all DGDemux options to be controlled. That's the best of both the CLI and GUI worlds.

You'd have to be out of your mind or a zealot to prefer using DGDemux directly (instead of via the GUI) unless you are doing batch operations. I also think you make a logical misstep in going from "GUI A is not transparent" to "I hate GUIs."

IIANM staxrip also allows the command lines to be viewed.


Last edited by videoh; 7th August 2020 at 14:49.
videoh is offline   Reply With Quote
Old 7th August 2020, 14:44   #19  |  Link
Hacker?pcs
Registered User
 
Join Date: Aug 2010
Posts: 40
Quote:
Originally Posted by videoh View Post
IIANM staxrip also allows the command lines to be viewed.
Any operation in StaxRip has the command line below which can be modified
Hacker?pcs is offline   Reply With Quote
Old 7th August 2020, 14:58   #20  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
That clinches it then!
videoh is offline   Reply With Quote
Reply


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 06:03.


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