Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
junorich
- Posts: 10
- Joined: 31 Oct 2017 09:53
#1
Post
by junorich » 31 Oct 2017 09:56
Hello everyone, I am new here so forgive me if this is in the wrong place. I am new to shell script and am trying to write a script to use with a program called ffmpeg. Would this be something I could get help with here?
Code: Select all
set /p VIDEO=Enter full name of video file on desktop:
md "%userprofile%\desktop\frames"
ffmpeg.exe -y -i "%userprofile%\desktop\%VIDEO%.mp4" -an -r 10 "%userprofile%\desktop\frames\img%%3d.jpg"
This allows you to paste the name of an mp4 file in the window and it will automatically make a folder and print out a frame by frame of the video in it. This was given to me and I added the little mp4 extension to it but that is as far as I can go. Would anyone here be able or willing to show me how to edit this further to do a few other things?
Thank you all for your time and help.
Last edited by
Squashman on 31 Oct 2017 12:36, edited 1 time in total.
Reason: MOD EDIT: Please use code tags.
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#2
Post
by aGerman » 31 Oct 2017 12:15
If you're looking for the ffmpeg command line reference - it's there:
http://ffmpeg.org/ffmpeg.html
I'm afraid nobody knows all that by heart and if you want to know how to use ffmpeg you should rather look it up on the manpage. Not sure what your actual question is though.
Steffen
-
junorich
- Posts: 10
- Joined: 31 Oct 2017 09:53
#3
Post
by junorich » 31 Oct 2017 12:27
I guess I was looking to see if someone knew enough about this to help me or guide me on changing this script around to do a few different things. But I didn't want to go off writing it all out and clutter this up unless someone knew about this kind of thing.
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#4
Post
by Squashman » 31 Oct 2017 12:34
junorich wrote:I guess I was looking to see if someone knew enough about this to help me or guide me on changing this script around to do a few different things. But I didn't want to go off writing it all out and clutter this up unless someone knew about this kind of thing.
We can help you with the batch code but as far as help with ffmpeg we can't guarantee anyone is a subject matter expert on that application.
-
junorich
- Posts: 10
- Joined: 31 Oct 2017 09:53
#5
Post
by junorich » 31 Oct 2017 12:49
Awesome. you guys are much nicer than the last group I dealt with (Different Forum).
Anyways, I am new to batch files and ffmpeg in general. I had this Batch file given to me and it allows you to paste a video name into it and it will create a folder that frames the video out of you. I looked at the code and made it to where you don't have to add the .mp4 to it, but that's as far as I can go with my limited knowledge.
1. id like to make it to where I can have a designated folder on the desktop that I can drag a video into and have it automatically run the ffmpeg to frame the video out and to extract the audio for it. Is this something that sounds remotely possible?
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#6
Post
by aGerman » 31 Oct 2017 13:02
Drag a file on it
Code: Select all
@echo off
if "%~1"=="" exit /b
ffmpeg.exe -y -i "%~1" -an -r 10 "%~dp1frames\img%%3d.jpg"
As long as ffmpeg.exe was not placed in the PATH environment you'd still need it in the same folder along with your batch script.
I don't know how to extract the audio.
Steffen
-
junorich
- Posts: 10
- Joined: 31 Oct 2017 09:53
#7
Post
by junorich » 31 Oct 2017 13:11
set /p VIDEO=Video file name (with extension) on Desktop:
ffmpeg.exe -i "%userprofile%\desktop\%VIDEO%.mp4" -vn -ac 2 -ar 44100 -ab 320k -f mp3 "%userprofile%\desktop\%VIDEO%.mp3"
this is the code to run to extraxt the audio. I was unsure how to combine the two.
Ok, I made a test folder with the exe for ffmpeg and the batch file that you showed me. I drug an mp4 onto the batch file, it open and shut a window prompt but didn't do anything.
im sure I just did something wrong.
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#8
Post
by aGerman » 31 Oct 2017 13:54
Code: Select all
@echo off
if "%~1"=="" exit /b
if not exist "%~dp1frames\" md "%~dp1frames"
ffmpeg.exe -y -i "%~f1" -an -r 10 "%~dp1frames\img%%3d.jpg"
ffmpeg.exe -i "%~f1" -vn -ac 2 -ar 44100 -ab 320k -f mp3 "%~dpn1.mp3"
PAUSE
The PAUSE at the end is to see possible error messages that you should quote if it still doesn't work.
Steffen
-
junorich
- Posts: 10
- Joined: 31 Oct 2017 09:53
#9
Post
by junorich » 01 Nov 2017 07:14
: Directory not found.
It will still run the frames and produce them but that error comes with the audio portion.
-
junorich
- Posts: 10
- Joined: 31 Oct 2017 09:53
#10
Post
by junorich » 01 Nov 2017 07:38
Code: Select all
set /p VIDEO=Enter full name of video file on desktop:
md "%userprofile%\desktop\frames"
ffmpeg.exe -y -i "%userprofile%\desktop\%VIDEO%.mp4" -an -r 10 "%userprofile%\desktop\frames\img%%3d.bmp"
ffmpeg.exe -i "%userprofile%\desktop\%VIDEO%" -vn -ac 2 -ar 44100 -ab 320k -f mp3 "%userprofile%\desktop\%VIDEO%.mp3"
pause
I tried it this way too and get the error of
C:\Users\Admin\desktop\set /p VIDEO=Enter full name of video file on desktop:: I
nvalid argument
But it still makes the frames file dump, just not the audio.
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#11
Post
by aGerman » 01 Nov 2017 08:03
junorich wrote:: Directory not found.
Worked for me.
Where did you download ffmpeg? Do you use a static build of ffmpeg.exe?
junorich wrote:But it still makes the frames file dump, just not the audio.
Because you missed the extension .mp4 in this command line.
-
junorich
- Posts: 10
- Joined: 31 Oct 2017 09:53
#12
Post
by junorich » 01 Nov 2017 08:49
Hello, I am sorry to be Ignorant. I do not see what you mean.
Code: Select all
set /p VIDEO=Enter full name of video file on desktop:
md "%userprofile%\desktop\frames"
ffmpeg.exe -y -i "%userprofile%\desktop\%VIDEO%.mp4" -an -r 10 "%userprofile%\desktop\frames\img%%3d.bmp"
ffmpeg.exe -i "%userprofile%\desktop\%VIDEO%" -vn -ac 2 -ar 44100 -ab 320k -f mp3 "%userprofile%\desktop\%VIDEO%.mp3"
pause
C:\Users\Admin\desktop\12337395_1050143501672989_1180547475_n: No such file or d
irectory
I still get this error and I do not quite see where to fix it, Im sure its something small. Thank you again for helping me out like this.
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#13
Post
by aGerman » 01 Nov 2017 09:12
ffmpeg.exe -i "%userprofile%\desktop\%VIDEO%.mp4" -vn -ac 2 -ar 44100 -ab 320k -f mp3 "%userprofile%\desktop\%VIDEO%.mp3"
-
junorich
- Posts: 10
- Joined: 31 Oct 2017 09:53
#14
Post
by junorich » 01 Nov 2017 12:17
Your awesome! Thank you.
Heres the code in the off chance that someone else needs it.
Code: Select all
set /p VIDEO=Enter full name of video file on desktop:
md "%userprofile%\desktop\frames"
ffmpeg.exe -y -i "%userprofile%\desktop\%VIDEO%.mp4" -an -r 10 "%userprofile%\desktop\frames\img%%3d.bmp"
ffmpeg.exe -i "%userprofile%\desktop\%VIDEO%.mp4" -vn -ac 2 -ar 44100 -ab 320k -f mp3 "%userprofile%\desktop\%VIDEO%.mp3"
pause
Just as a perk but not important. Do any of you know a way to auto paste when the batch file starts up? Just like to make this as automated as possible, but only if its not outrageous to do.
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#15
Post
by aGerman » 01 Nov 2017 12:31
Auto paste? Sorry but I'm afraid I don't get you.