Jump to content

How can I use FFmpeg in AutoIt?


Rhazz
 Share

Recommended Posts

Hello people.
First of all, my English may contain errors, because I'm not a English speaker. If someone wants to correct my writing, I will accept it with pleasure.

I'm learning AutoIt from scratch since two weeks ago. So I am still a newbie.

Sorry if my question is repeated or very basic, but I couldn't find the answer on Google or in this forum.

Yesterday, I've learned about FFmpeg and I developed a small code that is what I need.

The problem is that I don't know how I can use FFmpeg in AutoIt.

I already have the interface coded in AutoIt and, on the other hand, the code of the function what I need coded using FFmpeg. The two codes are separated and I want to join them.

Thanks, regards.

Link to comment
Share on other sites

  • Moderators

Hi, Rhazz, welcome to the AutoIt forum. Please post the two functions you have. We can then do our best to assist you in joining them into a single script.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

 Hi, Rhazz, welcome to the AutoIt forum. Please post the two functions you have. We can then do our best to assist you in joining them into a single script.

@JLogan3o13 first, thanks!

My code isn't finished, but here it is:

#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>



Local $nombreVideoSinExtension
$nombreVideoSinExtension = InputBox("Definir nombre","Elige un nombre para el archivo final SIN EXTENSION ya que será un mp4","video-final","",-1,-1)
Local $videoFinal
$videoFinal = $nombreVideoSinExtension & ".mp4"
Local $duracionVideoFinal
$duracionVideoFinal = InputBox("Definir duración","Define la duración del video expresada en segundos","10","",-1,-1)
Local $videoResolucion
$videoResolucion = InputBox("Definir resolución","Define la resolución del video","1280x720","",-1,-1)
Local $imagenes
$imagenes = InputBox("Escoger imagen","Escribe el nombre de la imagen CON SU EXTENSION que será el fondo del video","audio.mp3","",-1,-1)
Local $duracionCadaImagen
$duracionCadaImagen = 5
Local $relacionDeAspecto
$relacionDeAspecto = "4:3"
Local $audioVideo
$audioVideo = InputBox("Escoger audio","Escribe el nombre del audio CON SU EXTENSION","imagen.jpg","",-1,-1)
Local $velocidadAlCodificar
;$velocidadAlCodificar[] = [ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow]
Local $fpsVideoFinal
$fpsVideoFinal = 20


EstablecerVelocidadAlCodificar()

Func EstablecerVelocidadAlCodificar()
    ; Create a GUI with various controls.
    Local $InterfazEstablecerVelocidadAlCodificar = GUICreate("Elige la velocidad de codificación", 300, 200)

    ; Create a combobox control.
    Local $idComboBox = GUICtrlCreateCombo("", 10, 10, 185, 20)
    Local $idClose = GUICtrlCreateButton("Cerrar", 210, 170, 85, 25)

    ; Add additional items to the combobox.
    GUICtrlSetData($idComboBox, "ultrafast|superfast|veryfast|faster|fast|medium|slow|slower|veryslow", "fast")

    ; Display the GUI.
    GUISetState(@SW_SHOW, $InterfazEstablecerVelocidadAlCodificar)

    Local $sComboRead = ""

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

            Case $idComboBox
                $sComboRead = GUICtrlRead($idComboBox)
                MsgBox($MB_SYSTEMMODAL, "", "Elegiste " & $sComboRead & " como velocidad de codificación", 0, $InterfazEstablecerVelocidadAlCodificar)
                $velocidadAlCodificar = $sComboRead

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($InterfazEstablecerVelocidadAlCodificar)
EndFunc

And the FFmpeg code with AutoIt variables:

ffmpeg -loop 1 -framerate 1/$duracionCadaImagen -i $imagenes -i $audioVideo -c:v libx264 -s $videoResolucion -t $duracionVideoFinal -aspect $relacionDeAspecto -c:a libvo_aacenc -ac 2 -ab 128k -r $fpsVideoFinal -preset $velocidadAlCodificar $videoFinal

I want to create a program to generate a video from a combination of images+audio+text (code for insert text isn't written yet).

Remember, I didn't finished the code, it have some errors or missing elements.

Edited by Rhazz
cite
Link to comment
Share on other sites

something like?

run ('cmd /k ffmpeg -loop 1 -framerate ' & 1 /$duracionCadaImagen & ' -i ' & $imagenes & ' -i ' & $audioVideo & ' -c:v libx264 -s ' & $videoResolucion & ' -t ' & $duracionVideoFinal & ' -aspect ' & $relacionDeAspecto & ' -c:a libvo_aacenc -ac 2 -ab 128k -r ' & $fpsVideoFinal & ' -preset ' & $velocidadAlCodificar & $videoFinal')

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

something like?

run ('cmd /k ffmpeg -loop 1 -framerate ' & 1 /$duracionCadaImagen & ' -i ' & $imagenes & ' -i ' & $audioVideo & ' -c:v libx264 -s ' & $videoResolucion & ' -t ' & $duracionVideoFinal & ' -aspect ' & $relacionDeAspecto & ' -c:a libvo_aacenc -ac 2 -ab 128k -r ' & $fpsVideoFinal & ' -preset ' & $velocidadAlCodificar & $videoFinal')

 

I will try your code but how can I integrate FFmpeg to AutoIt and then compile in a .exe only file.

I want a final .exe without other files, and I want that the users could execute the program without installing anything.

I don't know how to integrate FFmpeg (I'm very newbie, sorry) and then compile all together in a .exe file.

Thanks a lot.

Link to comment
Share on other sites

This thread may be helpful getting an FFMPeg that is all one exe file rather than libraries:

http://www.portablefreeware.com/forums/viewtopic.php?f=6&t=16912

Then you could bundle it into your script's compiled exe using FileInstall()

See FileInstall in the help.

Thanks! But also I have a doubt about using FFmpeg in AutoIt. Where I have to put the FFmpeg files? In the same folder as my AutoIt script?

Edited by Rhazz
Texto correction
Link to comment
Share on other sites

something like?

run ('cmd /k ffmpeg -loop 1 -framerate ' & 1 /$duracionCadaImagen & ' -i ' & $imagenes & ' -i ' & $audioVideo & ' -c:v libx264 -s ' & $videoResolucion & ' -t ' & $duracionVideoFinal & ' -aspect ' & $relacionDeAspecto & ' -c:a libvo_aacenc -ac 2 -ab 128k -r ' & $fpsVideoFinal & ' -preset ' & $velocidadAlCodificar & $videoFinal')

 

if you want combine your script use (FileInstall)

something like

DirCreate(@DesktopDir&"/MyConvert")

FileInstall("ffmpeg.exe" , @DesktopDir&"/MyConvert/ffmpeg.exe")

$CMD = "ffmpeg -i xxxx.MP4 -codec copy yyyy.avi"
RunWait(@ComSpec & " /c " & $CMD)

xxxx.mp4 & yyyy.avi = path your file

 

Thanks, Both codes worked fine!

That is why I posted the link where you can find statically compiled FFMPeg.  No DLLs to worry about.

See the bottom post in the link.

 

Oh, sorry! I looked very quickly the link and I thought that there was not what I was looking for.

I could make it work! Now I will continue with the rest of the functions that I want to introduce in the program :P

Thank you so much guys! :)

Link to comment
Share on other sites

Thanks, Both codes worked fine!

Oh, sorry! I looked very quickly the link and I thought that there was not what I was looking for.

I could make it work! Now I will continue with the rest of the functions that I want to introduce in the program :P

Thank you so much guys! :)

You are welcome.  I am glad you are making progress.  :)

 

Link to comment
Share on other sites

  • 6 years later...

Hi Team, 

I need to compile all jpg images with naming convention like prt1.jpg, prt2.jpg etc. present in a folder to a video file. While running through cmd, the -i argument for the same would be -i "C:\myfolder\prt%01d.jpg". How can I pass the same argument when using ffmpeg through autoit.

Link to comment
Share on other sites

  • Developers

@varsha123,

Welcome,  

I assume you post in a 6 years old thread because you tried what is shown here and not working for you?
So, show the script you have that isn't working for starters so we can see what you have tried.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...