-2

I'm trying to run a list of cmd like this:

ffmpeg -i "E:\Download\Video\Test\1.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\01.png"
ffmpeg -i "E:\Download\Video\Test\2.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\02.png"
ffmpeg -i "E:\Download\Video\Test\3.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\03.png"
ffmpeg -i "E:\Download\Video\Test\4.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\04.png"
ffmpeg -i "E:\Download\Video\Test\5.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\05.png"
ffmpeg -i "E:\Download\Video\Test\6.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\06.png"
ffmpeg -i "E:\Download\Video\Test\7.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\07.png"
ffmpeg -i "E:\Download\Video\Test\8.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\08.png"
ffmpeg -i "E:\Download\Video\Test\9.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\09.png"
ffmpeg -i "E:\Download\Video\Test\10.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\10.png"
ffmpeg -i "E:\Download\Video\Test\11.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\11.png"
ffmpeg -i "E:\Download\Video\Test\12.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\12.png"
ffmpeg -i "E:\Download\Video\Test\13.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\13.png"
ffmpeg -i "E:\Download\Video\Test\14.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\14.png"
ffmpeg -i "E:\Download\Video\Test\15.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\15.png"
ffmpeg -i "E:\Download\Video\Test\16.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\16.png"
ffmpeg -i "E:\Download\Video\Test\17.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\17.png"
ffmpeg -i "E:\Download\Video\Test\18.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\18.png"
ffmpeg -i "E:\Download\Video\Test\19.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\19.png"
ffmpeg -i "E:\Download\Video\Test\20.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\20.png"
ffmpeg -i "E:\Download\Video\Test\21.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\21.png"
ffmpeg -i "E:\Download\Video\Test\22.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\22.png"
ffmpeg -i "E:\Download\Video\Test\23.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\23.png"
ffmpeg -i "E:\Download\Video\Test\24.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\24.png"
ffmpeg -i "E:\Download\Video\Test\25.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\25.png"
ffmpeg -i "E:\Download\Video\Test\26.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\26.png"
ffmpeg -i "E:\Download\Video\Test\27.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\27.png"
ffmpeg -i "E:\Download\Video\Test\28.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\28.png"
ffmpeg -i "E:\Download\Video\Test\29.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\29.png"
ffmpeg -i "E:\Download\Video\Test\30.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\30.png"
ffmpeg -i "E:\Download\Video\Test\31.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\31.png"
ffmpeg -i "E:\Download\Video\Test\32.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\32.png"
ffmpeg -i "E:\Download\Video\Test\33.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\33.png"
ffmpeg -i "E:\Download\Video\Test\34.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\34.png"
ffmpeg -i "E:\Download\Video\Test\35.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\35.png"
ffmpeg -i "E:\Download\Video\Test\36.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\36.png"
ffmpeg -i "E:\Download\Video\Test\37.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\37.png"
ffmpeg -i "E:\Download\Video\Test\38.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\38.png"
ffmpeg -i "E:\Download\Video\Test\39.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\39.png"
ffmpeg -i "E:\Download\Video\Test\40.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\40.png"
ffmpeg -i "E:\Download\Video\Test\41.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\41.png"
ffmpeg -i "E:\Download\Video\Test\42.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\42.png"
ffmpeg -i "E:\Download\Video\Test\43.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\43.png"
ffmpeg -i "E:\Download\Video\Test\44.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\44.png"
ffmpeg -i "E:\Download\Video\Test\45.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\45.png"
ffmpeg -i "E:\Download\Video\Test\46.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\46.png"
ffmpeg -i "E:\Download\Video\Test\47.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\47.png"
ffmpeg -i "E:\Download\Video\Test\48.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\48.png"
ffmpeg -i "E:\Download\Video\Test\49.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\49.png"
ffmpeg -i "E:\Download\Video\Test\50.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\50.png"

When I copy & paste in one go, it doesn't work because it takes time to finish each command, ffmpeg.exe can't receive next cmd from cmd.exe when it's still executing current cmd, Is there anyway I can tell the cmd.exe to wait for current cmd to finish, then execute next cmd?

Edit:

I'll try to describe my problem with step by step:

  1. I copy the list of commands above (multiple lines)

  2. I open cmd.exe, navigate to ffmpeg.exe location.

  3. I paste the data I copied into cmd.exe

Expected: After finish, I should have 50 png files inside my Thumbs folder.

Reality: I have less than 50 png files (could be 1 or 2 or 3, but less than 50) in my Thumbs folder.

Conclusion: Some commands miss out by ffmpeg, cmd.exe doesn't care if the current cmd has finished before executing the next one.

If I just copy one by one and paste each command into cmd.exe separately, it works, but that is too slow cause I have a lot of cmds.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
123iamking
  • 2,387
  • 4
  • 36
  • 56
  • 4
    Your question is unclear. If *ffmpeg.exe can't receive next cmd when it's executing current cmd*, then cmd.exe is already waiting for the current one to finish before it executes the next cal to ffmpeg.exe. It appears that what's happening is just what you want. If it's not, can you [edit] to be more clear about what the problem is? – Ken White Sep 08 '19 at 05:01
  • Are you running these commands from a [tag:batch-file]? Or are you copying and pasting them directly into the [tag:cmd] window? – Compo Sep 08 '19 at 07:39
  • @Compo: I copy and paste them directly into the cmd window. – 123iamking Sep 08 '19 at 07:47
  • @KenWhite: the cmd.exe isn't waiting for the current one to finish, thus only the first cmd can complete, the cmd after that miss out by ffmpeg. – 123iamking Sep 08 '19 at 07:53

1 Answers1

0

If your files are really named sequentially from 1 in increments of 1 up to 50, then what you should do is to run a looping command with For /L

From the window:

For /L %A In (1,1,50) Do @ffmpeg -i "E:\Download\Video\Test\%A.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\%A.png"

From a :

@For /L %%A In (1,1,50) Do @ffmpeg -i "E:\Download\Video\Test\%%A.mp4" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\%%A.png"


If your question deceives us and your files are not named sequentially as shown, but have more random names, then what you should do is to run a looping command with For and use a wildcard:

From the window:

For %A In ("E:\Download\Video\Test\*.mp4") Do @ffmpeg -i "%A" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\%~nA.png"

From a :

@For %%A In ("E:\Download\Video\Test\*.mp4") Do @ffmpeg -i "%%A" -ss 00:01:14 -vframes 1 "E:\Download\Video\Thumbs\%%~nA.png"


If you wanted to explicitly tell ffmpeg to wait for each to finish before moving onto the next, despite the fact that it does that already, you can change @ffmpeg in the above examples to @Start /Wait ffmpeg.

If you wanted to try and run all of the ffmpeg commands at the same time, without waiting for each to finish, unlikely to work with many files, due to program or memory limitations, you can change @ffmpeg in the above examples to @Start ffmpeg.


If your commands are already in a list inside a plain text file, you can change that list to a by changing its file extension to .bat or .cmd then just double-click it to run it. For this to work, ffmpeg would probably need to be in the same directory as the batch file, (list of commands), or be located somewhere within %PATH%. In this case you'd see each command echoed to the screen as it's run, if you'd rather not see that, add a new first line to the top containing @Echo Off.
Compo
  • 36,585
  • 5
  • 27
  • 39
  • but there is a case where wildcard won't help, for example, I want to add download file to idm.exe with cmd line: `IDMan.exe /d "https://i.stack.imgur.com/FYDxX.jpg?s=32&g=1" /f "avarta1.jpg" /a` - there is hundred of cmds like this and there is no way I can wildcard the url. – 123iamking Sep 08 '19 at 08:48
  • PS: I got it, paste all the cmds into the `.bat` file solved my problem. – 123iamking Sep 08 '19 at 08:55
  • 1
    As for your first comment, please don't expect me to have guessed, that what you're trying to do has no relevance to the actual question you posted. For your second comment, I would advise that you use the `.cmd` extension instead of `.bat`, _although it's unlikely to make any noticeable difference_. To find out more about the differences, read [this](https://stackoverflow.com/q/148968). – Compo Sep 08 '19 at 09:27
  • Thanks for your help, I appreciate it. – 123iamking Sep 08 '19 at 09:29