简体   繁体   中英

Using batch process to encode multiple files one at a time with ffmpeg

Total beginner here, likely asking for help on something (hopefully) very easy to implement.

I have a drop folder set up to trigger a batch process that will encode any videos contained therein to 5 different formats using FFMPEG. It also creates a text file containing the files name which I then use in a separate php/api process to upload the videos to the internet.

The process works perfectly when just the one video is dropped into the drop folder. However, as soon as there are two or more then the process comes unstuck.

Here's an example of one of the ffmpeg scripts the batch file runs:

for %%a in ("C:\live\dropfolder\transcode\*.*") do ffmpeg\ffmpeg -i "%%a" (encoding settings) "C:\live\dropfolder\output\%%~na.mp4"
pause
for %%g in (C:\live\dropfolder\output\*.mp4) do echo %%~nxg > C:\live\dropfolder\filename\filename_format.txt

So when there are 2 or more files, the filename that gets generated by that echo might be for File A, while the transcoding session might have been for File B.

Ideally I'd like to have the whole process finish transcoding the first video - including generating the text files for each format - before returning to the beginning of the process for the next video in the drop folder.

How do I achieve this? Any suggestions would be greatly appreciated.

Thanks!

Tom

Try this instead, not sure if it's really what you're after...

if exist C:\live\dropfolder\filename\filename_format.txt del C:\live\dropfolder\filename\filename_format.txt
for %%a in ("C:\live\dropfolder\transcode\*.*") do (
    ffmpeg\ffmpeg -i "%%a" (encoding settings) "C:\live\dropfolder\output\%%~na.mp4"
    echo %%~na.mp4 >> C:\live\dropfolder\filename\filename_format.txt
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM