Error using avisynth script as input to ffmpeg
Asked Answered
N

2

7

I've searched the internet and haven't found a solution. I hope this question does not come off as a duplicate.

I have the following files in the same folder:

  • ffmpeg.exe (32-bit version)
  • IN.mp4 (video codec - AVC , audio codec - PCM)
  • RUN_FILE.bat and RUN_AVS.bat batch files
  • SCRIPT.avs (avisynth script file)
  • MSharpen.dll (sharpening filter for avisynth)

The text within RUN_FILE.bat:

ffmpeg -i "IN.mp4" -c:v libx264 -crf 24 -c:a libmp3lame -aq 2 OUT.mp4

The text within RUN_AVS.bat:

ffmpeg -i "SCRIPT.avs" -c:v libx264 -crf 24 -c:a libmp3lame -aq 2 OUT.mp4

The text within SCRIPT.avs (3 lines):

LoadPlugin("D:\MSharpen.dll")

DirectShowSource("D:\IN.MP4")

MSharpen(15,150) 

If I try loading the avisynth script with an external program such as media player classic it works fine (and sharpens the video frames).

Going to the command line and running RUN_FILE.bat works as expected, however running RUN_AVS.bat I get the following error (see screenshot):

error message

I find this confusing as ffmpeg is configured with --enable-avisynth.

I'd appreciate help with this - This is part of a larger and very important project (automatically scanning a folder with hundreds of video files, sharpening and re-encoding them to another folder with the same filenames).

Nimwegen answered 30/3, 2015 at 8:56 Comment(4)
avisynth stuff changed a few days ago a bit in FFmpeg, do older versions work better? Can other programs that read avisynth stuff read those files?Tallage
Other programs can definitely read those avs files, as I wrote in my original post. To be specific - media player classic, megui and x264.exe work fine. I did try different combinations of ffmpeg and avisynth (32-bit vs. 64 bit etc.) but don't remember if I tried using 2 old versions of both. I'll try now.Nimwegen
does a simpler script work in FFmpeg like Version()Tallage
'... try loading the avisynth script with an external program ...' This is a sign of 32bit version conflict. Moreover, If you want to know which error message exactly avs script yields, try loading it in VirtualDub firstErrata
N
1

Well... it seems it was a matter of versions after all.

rogerdpack's remark is what made me systematically try old versions of ffmpeg etc. I gave his answer +1 but I think an answer should be such that it is a full solution for the question, so I'm writing my own answer. Hope you understand rogerdpack :-)

Anyway, here's the combination that worked for me (I hope posting URLs is OK):

FFMPEG 32-bit version 2.5.2 (downloaded from http://ffmpeg.zeranoe.com/)

Avisynth 2.5.8 (downloaded from official build)

MSharpen plugin for avisynth (downloaded from MSharpen official link).

Make sure you copied MSharpen.dll to the avisynth plugin folder beforehand and restarted your computer. In my case the plugin folder is C:\Program Files (x86)\AviSynth 2.5\plugins.

BTW I'm running Windows 7 Ultimate with SP1 (64 bit) with an Intel i5-3570K, 16GB ram etc. Maybe I should have stated that in the OP.

For what it's worth, here's my solution.

The folder and file layout is as following:

I have a main folder; the name does not matter - let's call it 'MAIN'. Within 'MAIN' I have 2 files and 2 folders.

The 2 files are:

  1. ffmpeg.exe (version 2.5.2, 32-bit)
  2. BatchConvert.bat

The 2 folders are:

  1. Source (contains all the video files)
  2. Target (will contain the encoded output video files)

The file BatchConvert.bat has the following text:

for %%a in ("Source*.*") do @echo DirectShowSource("%%a") >> "batchScript.avs" && @echo MSharpen(10,120) >> "batchScript.avs" && ffmpeg -i "batchScript.avs" -n -c:v libx264 -crf 24 -c:a libmp3lame -b:a 192k "Target\%%~na.mp4" && del "batchScript.avs" pause

The batch file basically scans all files from 'Source' and encodes them in 'Target' and it skips files that already were encoded. It doesn't alter the files in 'Source' at all, just in case.

All that's left to do is copy all the videos to Source and run BatchConvert.bat !

Nimwegen answered 31/3, 2015 at 4:52 Comment(2)
Hmm, "latest" ffmpeg with avisynth 2.6 should work OK, could you try that?Tallage
AviSynth 2.6 RC1 or higher to be specific.Byington
P
6

Have you tried googling for the line that is in red in your screenshot?

From what I found here http://ffmpeg.zeranoe.com/forum/viewtopic.php?t=1084 and in other sources, unknown error might be due to difference in 32/64bit builds either in ffmpeg or avisynth. There might also be a problem if you're using Avisynth 2.5.8 instead of 2.6 (open an avisynth script containing "Version()" as the last command in it in any player to find which one you have). Finally you might want to try opening your script in x264.exe instead of ffmpeg and see if it works.

I would have posted this to comments intead of answer, but I'm not yet allowed to comment.

Pizzicato answered 30/3, 2015 at 12:4 Comment(2)
Thanks. I actually was successful using x264.exe before I saw your comment, but this isn't a viable solution as it can only create files with video streams (it loses all the audio tracks and they need to be muxed separately. I'm looking for a one-stop textual solution...). As to versions - my FFMPEG is 32-bit and so is Avisynth (I tried all combinations before posting the question). I'll keep trying and post my findings.Nimwegen
Thank you. I ran into this error and I indeed was using a 64-bit ffmpeg in my path with 32-bit AviSynth 2.6 installed. Switch to the latest 32-bit ffmpeg and it runs fine. But, out of curiosity, I tested the 32-bit ffmpeg N-71157-g7c6b043 version in the OP's screenshot and it doesn't work with AviSynth 2.5.8... but does work with AviSynth 2.6.0 (Mar 31 '15, note the date) and AviSynth 2.6 MT (20 Feb '15). The latest ffmpeg works with all of those. I didn't check AS (14 Jan '15) a likely version here. Thus, the error doesn't really indicate where the fault may be. It could be any of the above.Kevon
N
1

Well... it seems it was a matter of versions after all.

rogerdpack's remark is what made me systematically try old versions of ffmpeg etc. I gave his answer +1 but I think an answer should be such that it is a full solution for the question, so I'm writing my own answer. Hope you understand rogerdpack :-)

Anyway, here's the combination that worked for me (I hope posting URLs is OK):

FFMPEG 32-bit version 2.5.2 (downloaded from http://ffmpeg.zeranoe.com/)

Avisynth 2.5.8 (downloaded from official build)

MSharpen plugin for avisynth (downloaded from MSharpen official link).

Make sure you copied MSharpen.dll to the avisynth plugin folder beforehand and restarted your computer. In my case the plugin folder is C:\Program Files (x86)\AviSynth 2.5\plugins.

BTW I'm running Windows 7 Ultimate with SP1 (64 bit) with an Intel i5-3570K, 16GB ram etc. Maybe I should have stated that in the OP.

For what it's worth, here's my solution.

The folder and file layout is as following:

I have a main folder; the name does not matter - let's call it 'MAIN'. Within 'MAIN' I have 2 files and 2 folders.

The 2 files are:

  1. ffmpeg.exe (version 2.5.2, 32-bit)
  2. BatchConvert.bat

The 2 folders are:

  1. Source (contains all the video files)
  2. Target (will contain the encoded output video files)

The file BatchConvert.bat has the following text:

for %%a in ("Source*.*") do @echo DirectShowSource("%%a") >> "batchScript.avs" && @echo MSharpen(10,120) >> "batchScript.avs" && ffmpeg -i "batchScript.avs" -n -c:v libx264 -crf 24 -c:a libmp3lame -b:a 192k "Target\%%~na.mp4" && del "batchScript.avs" pause

The batch file basically scans all files from 'Source' and encodes them in 'Target' and it skips files that already were encoded. It doesn't alter the files in 'Source' at all, just in case.

All that's left to do is copy all the videos to Source and run BatchConvert.bat !

Nimwegen answered 31/3, 2015 at 4:52 Comment(2)
Hmm, "latest" ffmpeg with avisynth 2.6 should work OK, could you try that?Tallage
AviSynth 2.6 RC1 or higher to be specific.Byington

© 2022 - 2024 — McMap. All rights reserved.