Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error using avisynth script as input to ffmpeg

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).

like image 263
CV_User Avatar asked Mar 30 '15 08:03

CV_User


2 Answers

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.

like image 107
Seedmanc Avatar answered Nov 20 '22 14:11

Seedmanc


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 !

like image 1
CV_User Avatar answered Nov 20 '22 15:11

CV_User