Page 1 sur 1

[R] Utilisation d'un shell

Posté : jeu. 21 mars 2013 10:15
par clark17
Bonjour à tous,

Pour un petit programme j'utilise la commande shell pour lancer ffmpeg avec des paramètres. Ca marche convenablement mais j'ai un petit souci. Tout d'abord voici le code:

Code : Tout sélectionner

#include <GDIPlus.au3>

;Variables
$repetition = 5
$attente = 1 * 1000 * 20
$nom_video = @HOUR & "h" & @MIN & "_" & @MDAY & "_" & @MON & "_" & @YEAR" & "mp4"

For $i = 001 To $repetition
    ;Télécharge en arrière plan
    Local $hDownload = InetGet("http://toto/map.jpg?0.314970187144354", "map-" & StringFormat("%03i", $i) & ".jpg", 1, 1)
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, 2)
    InetClose($hDownload)
    $img1 = "map-" & StringFormat("%03i", $i) & ".jpg"  ; départ
    $img2 = "cmap-" & StringFormat("%03i", $i) & ".jpg"  ; arrivée
    _RognerImage($img1, $img2, 5, 24, 992, 938)
    FileDelete($img1)
    Sleep($attente)
Next

;Création de la vidéo avec FFmpeg
ShellExecute("ffmpeg.exe", "-f image2 -r 1 -i cmap-%03d.jpg -c:v libx264 -r 30 " & $nom_video)
ShellExecuteWait("ffmpeg.exe")

MsgBox(0, "", "Fin du script")


Func _RognerImage($imga, $imgb, $X, $Y, $W, $H)
    Local $hImage, $hClone
    _GDIPlus_Startup ()
    $hImage = _GDIPlus_ImageLoadFromFile ($imga)
    $hClone = _GDIPlus_BitmapCloneArea ($hImage, $X, $Y, $W, $H, $GDIP_PXF32RGB)
    _GDIPlus_ImageSaveToFile($hClone, $imgb)
    _GDIPlus_ImageDispose($hClone)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_ShutDown()
EndFunc
 
Comment faire pour éviter que la fenêtre shell se ferme toute seul? Parce que pour débugger c'est un peu chiant je n'ai pas le résultat du terminal. Y a une option pour laisser le terminal ouvert ou alors je dois passer par un batch?

Re: [..] Utilisation d'un shell

Posté : jeu. 21 mars 2013 10:41
par jguinch
Salut
Plutôt que de lancer ffmpeg.exe directement, tu peux essayer de le lancer comme ça :

Code : Tout sélectionner

Run(@ComSpec & " /k ffmpeg.exe")

Re: [..] Utilisation d'un shell

Posté : jeu. 21 mars 2013 12:26
par clark17
Je comprend pas bien comment cela fonctionne, où dois-je mettre mes paramètres pour ffmpeg?

Re: [..] Utilisation d'un shell

Posté : jeu. 21 mars 2013 14:36
par Tlem
Dans ce genre la :

Code : Tout sélectionner

$Params = "/param1 /param2 /param3 /param4"
Run(@ComSpec & " /k ffmpeg.exe" & " " & $Params)
PS : Pour ceux qui ce demanderaient pourquoi je n'ai pas fusionné l'espace avec la commande ffmpeg.exe, c'est tout simplement pour pas qu'il passe inaperçu ! :mrgreen:

Re: [..] Utilisation d'un shell

Posté : jeu. 21 mars 2013 15:41
par clark17
Ah et ben oui tout simple quoi! Merci. pour infos voici le script que j'utilise désormais:

Code : Tout sélectionner

#include <GDIPlus.au3>

;Variables
$repetition = 120
$attente = 1 * 1000 * 20
$nom_video = @HOUR & "h" & @MIN & "_" & @MDAY & "_" & @MON & "_" & @YEAR & ".mp4"

MsgBox(0, "Lancement", "Lancement du script")

For $i = 001 To $repetition
    ;Télécharge en arrière plan
    Local $hDownload = InetGet("http://toto/map.jpg?0.314970187144354", "map-" & StringFormat("%03i", $i) & ".jpg", 1, 1)
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, 2)
    InetClose($hDownload)
    $img1 = "map-" & StringFormat("%03i", $i) & ".jpg"  ; départ
    $img2 = "cmap-" & StringFormat("%03i", $i) & ".jpg"  ; arrivée
    _RognerImage($img1, $img2, 5, 24, 992, 938)
    Sleep($attente)
Next

;Création de la vidéo avec FFmpeg
MsgBox(0, "Encodage", "Lancement de l'encodage en x264")
RunWait(@ComSpec & " /k ffmpeg.exe -f image2 -r 1 -i cmap-%03d.jpg -c:v libx264 -r 30 " & $nom_video)

;On éfface les *.jpg
FileDelete("*.jpg")

MsgBox(0, "Quitter", "Fin du script")


Func _RognerImage($imga, $imgb, $X, $Y, $W, $H)
    Local $hImage, $hClone
    _GDIPlus_Startup ()
    $hImage = _GDIPlus_ImageLoadFromFile ($imga)
    $hClone = _GDIPlus_BitmapCloneArea ($hImage, $X, $Y, $W, $H, $GDIP_PXF32RGB)
    _GDIPlus_ImageSaveToFile($hClone, $imgb)
    _GDIPlus_ImageDispose($hClone)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_ShutDown()
EndFunc