Sign in to follow this  
Followers 0
Rhazz

How can I use FFmpeg in AutoIt?

12 posts in this topic

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.

Share this post


Link to post
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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

 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

Share this post


Link to post
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')

 

1 person likes this

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

if you want combine your script use (FileInstall)

something like

FileInstall("ffmpeg.exe" , @ScriptDir&"/ffmpeg.exe")

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

 

Edited by ahmeddzcom
1 person likes this

Share this post


Link to post
Share on other sites

I still don't know where I have to put the FFmpeg library files.

Share this post


Link to post
Share on other sites

I still don't know where I have to put the FFmpeg library files.

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.

 

Share this post


Link to post
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! :)

Share this post


Link to post
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.  :)

 

1 person likes this

Share this post


Link to post
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
Sign in to follow this  
Followers 0