convertisseur FFmpeg

Programmation d'applications complexes
Avatar de l’utilisateur
Ar-S
Messages : 9539
Inscription : dim. 09/oct./2005 16:51
Contact :

Message par Ar-S »

3h25 après une journée de taf et une fin alcoolisé chez les copains, voilà mon petit code avant d'aller me pieuter.

Code : Tout sélectionner

;{- FFmpeg GUI by Ar-S / LDV MULTIMEDIA

Enumeration
  #WIN
  #P0
  #OP_Debit_Free
  #BT_ChoixSource
  #ChoixSource
  #ChoixDest
  #BT_ChoixDest
  #TXT_1
  #TXT_2
  #OP_FLV
  #OP_AVI
  #TXT_3
  #BT_GO
  #TXT_4
  #OP_inchange
  #OP_16_9
  #OP_4_3
  #TXT_5
  #OP_res1
  #OP_128x96
  #OP_160x120
  #OP_320x240
  #OP_640x480
  #OP_800x600
  #OP_1024x768
  #TXT_6
  #OP_Debit1
  #OP_Debit_50
  #OP_Debit_100
  #OP_Debit_500
  #SON
  #Font_BT_ChoixSource
  #Font_BT_ChoixDest
EndEnumeration
Global OP_Debit_Free_Tooltip
Global BT_ChoixSource_Tooltip
Global BT_ChoixDest_Tooltip
Global SON_Tooltip
Global esp$=" "
Global Path$=GetCurrentDirectory()
Global FFmpeg$=Chr(34)+Path$+"ffmpeg.exe"+Chr(34)
Global V$="0.2"

; Create tooltip
Procedure GadgetBalloonToolTip(WindowNumber.l, GadgetNumber.l, Text.s)
  Protected Tooltip.l, Balloon.TOOLINFO
  Tooltip = CreateWindowEx_(0, "ToolTips_Class32", "", #WS_POPUP | #TTS_NOPREFIX | #TTS_BALLOON, 0, 0, 0, 0, WindowID(WindowNumber), 0, GetModuleHandle_(0), 0)
  SendMessage_(Tooltip, #TTM_SETTIPTEXTCOLOR, GetSysColor_(#COLOR_INFOTEXT), 0)
  SendMessage_(Tooltip, #TTM_SETTIPBKCOLOR, GetSysColor_(#COLOR_INFOBK), 0)
  SendMessage_(Tooltip, #TTM_SETMAXTIPWIDTH, 0, 180)
  Balloon\cbSize = SizeOf(TOOLINFO)
  Balloon\uFlags = #TTF_IDISHWND | #TTF_SUBCLASS
  Balloon\hwnd = GadgetID(GadgetNumber)
  Balloon\uId = GadgetID(GadgetNumber)
  Balloon\lpszText = @Text
  SendMessage_(Tooltip, #TTM_ADDTOOL, 0, @Balloon)
  ProcedureReturn Tooltip
EndProcedure
; Change tooltip text
Procedure ChangeGadgetBalloonToolTip(Tooltip.l, GadgetNumber.l, Text.s)
  Protected Balloon.TOOLINFO
  Balloon\cbSize = SizeOf(TOOLINFO)
  Balloon\uFlags = #TTF_IDISHWND | #TTF_SUBCLASS
  Balloon\hwnd = GadgetID(GadgetNumber)
  Balloon\uId = GadgetID(GadgetNumber)
  Balloon\lpszText = @Text
  SendMessage_(Tooltip, #TTM_ADDTOOL, 0, @Balloon)
EndProcedure
; Free tooltip
Procedure FreeBalloonTooltip(Tooltip.l)
  DestroyWindow_(Tooltip.l)
EndProcedure 
;
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
;}
Procedure OpenWindow_WIN()
  If OpenWindow(#WIN, 456, 176, 450, 185, "FFmpeg GUI FLV - AVI converter "+V$, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
    If CreateGadgetList(WindowID(#WIN))
      PanelGadget(#P0, 0, 0, 450, 185) ;>
        ; Options Generales
        AddGadgetItem(#P0, -1, "Options Generales")
        ButtonGadget(#BT_ChoixSource, 390, 15, 50, 30, "...")
        BT_ChoixSource_Tooltip = GadgetBalloonToolTip(#WIN, #BT_ChoixSource, "Indiquez le chemin du fichier source")
        StringGadget(#ChoixSource, 5, 25, 380, 20, "", #PB_String_BorderLess|#ES_CENTER|#PB_String_ReadOnly)
        StringGadget(#ChoixDest, 5, 75, 380, 20, "", #PB_String_BorderLess|#ES_CENTER|#PB_String_ReadOnly)
        ButtonGadget(#BT_ChoixDest, 390, 65, 50, 30, "...")
        BT_ChoixDest_Tooltip = GadgetBalloonToolTip(#WIN, #BT_ChoixDest, "Indiquez le chemin du fichier source")
        TextGadget(#TXT_1, 5, 7, 180, 15, "Chemin du fichier source")
        TextGadget(#TXT_2, 5, 55, 180, 15, "Chemin du fichier de destination")
        OptionGadget(#OP_FLV, 5, 130, 40, 20, "FLV")
        OptionGadget(#OP_AVI, 50, 130, 40, 20, "AVI")
        SetGadgetState(#OP_AVI, 1)
        TextGadget(#TXT_3, 5, 110, 80, 20, "Format de sortie")
        ButtonGadget(#BT_GO, 105, 105, 335, 45, "Convertir la vidéo")
        ; Options avancées
        AddGadgetItem(#P0, -1, "Options avancées")
        StringGadget(#OP_Debit_Free, 295, 105, 50, 15, "", #PB_String_Numeric|#ES_RIGHT)
        OP_Debit_Free_Tooltip = GadgetBalloonToolTip(#WIN, #OP_Debit_Free, "Choississez vous-même un débit vidéos")
        TextGadget(#TXT_4, 10, 5, 60, 15, "Aspect")
        OptionGadget(#OP_inchange, 10, 25, 70, 15, "Inchangé")
        SetGadgetState(#OP_inchange, 1)
        OptionGadget(#OP_16_9, 10, 45, 50, 15, "16:9")
        OptionGadget(#OP_4_3, 10, 65, 50, 15, "4:3")
        TextGadget(#TXT_5, 125, 5, 60, 15, "Résolution")
        OptionGadget(#OP_res1, 125, 25, 145, 15, "Identique à la source")
        SetGadgetState(#OP_res1, 1)
        OptionGadget(#OP_128x96, 125, 45, 70, 15, "128x96")
        OptionGadget(#OP_160x120, 125, 65, 70, 15, "160x120")
        OptionGadget(#OP_320x240, 125, 85, 70, 15, "320x240")
        OptionGadget(#OP_640x480, 125, 105, 70, 15, "640x480")
        OptionGadget(#OP_800x600, 125, 125, 70, 15, "800x600")
        OptionGadget(#OP_1024x768, 125, 145, 70, 15, "1024x768")
        TextGadget(#TXT_6, 295, 5, 110, 15, "Débit vidéo (kbps/s)")
        OptionGadget(#OP_Debit1, 295, 25, 145, 15, "Defaut (200)")
        SetGadgetState(#OP_Debit1, 1)
        OptionGadget(#OP_Debit_50, 295, 45, 50, 15, "50")
        OptionGadget(#OP_Debit_100, 295, 65, 50, 15, "100")
        OptionGadget(#OP_Debit_500, 295, 85, 50, 15, "500")
        CheckBoxGadget(#SON, 295, 135, 140, 15, "Suppression du son ?")
        SON_Tooltip = GadgetBalloonToolTip(#WIN, #SON, "Cocher pour supprimer la bande son")
        ; A propos
        AddGadgetItem(#P0, -1, "A propos")
        ; Mise à jour ?
        AddGadgetItem(#P0, -1, "Mise à jour ?")
      CloseGadgetList() ;<
      ; Gadget Fonts
      SetGadgetFont(#BT_ChoixSource, LoadFont(#Font_BT_ChoixSource, "Century Schoolbook", 16, 272))
      SetGadgetFont(#BT_ChoixDest, LoadFont(#Font_BT_ChoixDest, "Century Schoolbook", 16, 272))
      PureCOLOR_SetGadgetColor(#OP_Debit_Free, $0, $67CFFC)
      PureCOLOR_SetButtonColor(#BT_ChoixSource, #PureCOLOR_SystemColor, $67CFFC)
      PureCOLOR_SetGadgetColor(#ChoixSource, $0, $67CFFC)
      PureCOLOR_SetGadgetColor(#ChoixDest, $0, $67CFFC)
      PureCOLOR_SetButtonColor(#BT_ChoixDest, #PureCOLOR_SystemColor, $67CFFC)
      
    EndIf
  EndIf
EndProcedure


OpenWindow_WIN()
Aspect$=""
Resolution$=""
Format$="avi"
Debit$=""
Son$=""

;{- Event loop
Repeat
  Event = WaitWindowEvent()
  Select Event
    ; ///////////////////
    Case #PB_Event_Gadget
      EventGadget = EventGadget()
      EventType = EventType()
      Select EventGadget
        Case #P0
        Case #BT_ChoixSource
          EtatFormat=GetGadgetState(#OP_AVI)
          If EtatFormat=1
            Format$="avi"
          Else
            Format$="flv"
          EndIf
          FichierParDefaut$ = Path$   
          Filtre$ = "Tous les fichiers (*.*)|*.*"
          Filtre  = 0   
          Fichier$ = OpenFileRequester("Choisissez le fichier video à convertir", FichierParDefaut$, Filtre$, Filtre)
          If Fichier$
            NomFichier$=GetFilePart(Fichier$)
            LongueurFichier=Len(Fichier$)
            fichierDest$=Chr(34)+Left(Fichier$,LongueurFichier-3)+Format$+Chr(34)
            Fichier$=Chr(34)+Fichier$+Chr(34)
            SetGadgetText(#ChoixSource,Fichier$)
            SetGadgetText(#ChoixDest,fichierDest$)
          Else
            MessageRequester("Information", "La sélection a été annulée.", 0)
          EndIf 
          
        Case #BT_ChoixDest
          FichierParDefaut$ = Path$
          Filtre$ = "Fichier "+Format$+ " (*."+Format$+")|*."+Format$
          fichierDest$ = SaveFileRequester("Choisissez le fichier à sauvegarder", FichierParDefaut$, Filtre$, Filtre)
          If fichierDest$
            If Right(fichierDest$,4)="."+Format$
              fichierDest$=fichierDest$
            Else
              fichierDest$=Chr(34)+fichierDest$+"."+Format$+Chr(34)
            EndIf
            SetGadgetText(#ChoixDest,fichierDest$)
          Else
            MessageRequester("Information", "La sélection a été annulée.", 0)  
          EndIf 
        Case #ChoixSource 
        Case #ChoixDest
          
        Case #TXT_1
        Case #TXT_2
        Case #OP_FLV
          Format$="flv"
          SetGadgetState(#OP_AVI, 0)
        Case #OP_AVI
          Format$="avi"
          SetGadgetState(#OP_FLV, 0)
        Case #TXT_3
          ;-GO       
        Case #BT_GO
          EtatFormat=GetGadgetState(#OP_AVI)
          If EtatFormat=1
            Format$="avi"
          Else
            Format$="flv"
          EndIf
          If Fichier$=""
            MessageRequester("information","Vous devez choisir un fichier à convertir",#MB_ICONEXCLAMATION)
          Else
            If fichierDest$=""
              MessageRequester("information","Vous devez choisir le chemin de sauvegarde",#MB_ICONEXCLAMATION)
            Else
              If Format$="flv"
                parametre$="-i "+Fichier$+esp$+"-f "+Format$+esp$+fichierDest$
                Else
                  parametre$="-i "+Fichier$+esp$+"-sameq -vcodec rawvideo -f "+Format$+esp$+fichierDest$  
                ;parametre$="-i "+Fichier$+esp$+"-f "+Format$+esp$+Aspect$+Son$+Debit$+Resolution$+fichierDest$
              EndIf
              ;  RunProgram (FFmpeg$,parametre$)
              MessageRequester ("test",FFmpeg$+esp$+parametre$) ;-test
              RunProgram(FFmpeg$,parametre$,"",1)
              SetClipboardText(FFmpeg$+esp$+parametre$)
              CloseFile(1)
            EndIf
          EndIf
          
        Case #TXT_4
        Case #OP_inchange
          Aspect$=""
          SetGadgetState(#OP_16_9, 0)
          SetGadgetState(#OP_4_3, 0)
        Case #OP_16_9
          Aspect$="-aspect 16:9 "
          SetGadgetState(#OP_4_3, 0)
          SetGadgetState(#OP_inchange, 0)
        Case #OP_4_3
          Aspect$="-aspect 4:3 "
          SetGadgetState(#OP_16_9, 0)
          SetGadgetState(#OP_inchange, 0)
        Case #TXT_5
        Case #OP_res1
          Resolution$=""
          SetGadgetState(#OP_128x96, 0)
          SetGadgetState(#OP_160x120, 0)
          SetGadgetState(#OP_320x240, 0)
          SetGadgetState(#OP_640x480, 0)
          SetGadgetState(#OP_800x600, 0)
          SetGadgetState(#OP_1024x768, 0)
        Case #OP_128x96
          Resolution$="-s sqcif "
          SetGadgetState(#OP_res1, 0)
          SetGadgetState(#OP_160x120, 0)
          SetGadgetState(#OP_320x240, 0)
          SetGadgetState(#OP_640x480, 0)
          SetGadgetState(#OP_800x600, 0)
          SetGadgetState(#OP_1024x768, 0)
          
        Case #OP_160x120
          Resolution$="-s qqvga "
          SetGadgetState(#OP_128x96, 0)
          SetGadgetState(#OP_res1, 0)
          SetGadgetState(#OP_320x240, 0)
          SetGadgetState(#OP_640x480, 0)
          SetGadgetState(#OP_800x600, 0)
          SetGadgetState(#OP_1024x768, 0)
        Case #OP_320x240
          Resolution$="-s qvga "
          SetGadgetState(#OP_128x96, 0)
          SetGadgetState(#OP_res1, 0)
          SetGadgetState(#OP_160x120, 0)
          SetGadgetState(#OP_640x480, 0)
          SetGadgetState(#OP_800x600, 0)
          SetGadgetState(#OP_1024x768, 0)
        Case #OP_640x480
          Resolution$="-s vga "
          SetGadgetState(#OP_128x96, 0)
          SetGadgetState(#OP_res1, 0)
          SetGadgetState(#OP_160x120, 0)
          SetGadgetState(#OP_320x240, 0)
          SetGadgetState(#OP_800x600, 0)
          SetGadgetState(#OP_1024x768, 0)
        Case #OP_800x600
          Resolution$="-s svga "
          SetGadgetState(#OP_128x96, 0)
          SetGadgetState(#OP_res1, 0)
          SetGadgetState(#OP_160x120, 0)
          SetGadgetState(#OP_320x240, 0)
          SetGadgetState(#OP_640x480, 0)
          SetGadgetState(#OP_1024x768, 0)
        Case #OP_1024x768
          Resolution$="-s qqvga "
          SetGadgetState(#OP_128x96, 0)
          SetGadgetState(#OP_res1, 0)
          SetGadgetState(#OP_160x120, 0)
          SetGadgetState(#OP_320x240, 0)
          SetGadgetState(#OP_640x480, 0)
          SetGadgetState(#OP_800x600, 0)
        Case #TXT_6
        Case #OP_Debit_Free
          debfree$=GetGadgetText(#OP_Debit_Free)
          Debit$="-b "+debfree$+esp$
        Case #OP_Debit1
          Debit$=""
          SetGadgetState(#OP_Debit_50, 0)
          SetGadgetState(#OP_Debit_100, 0)
          SetGadgetState(#OP_Debit_500, 0)
          SetGadgetText(#OP_Debit_Free,"")
        Case #OP_Debit_50
          Debit$="-b 50 "
          SetGadgetState(#OP_Debit1, 0)
          SetGadgetState(#OP_Debit_100, 0)
          SetGadgetState(#OP_Debit_500, 0)
          SetGadgetText(#OP_Debit_Free,"")
        Case #OP_Debit_100
          Debit$="-b 100 "
          SetGadgetState(#OP_Debit1, 0)
          SetGadgetState(#OP_Debit_50, 0)
          SetGadgetState(#OP_Debit_500, 0)
          SetGadgetText(#OP_Debit_Free,"")
        Case #OP_Debit_500
          Debit$="-b 500 "
          SetGadgetState(#OP_Debit1, 0)
          SetGadgetState(#OP_Debit_50, 0)
          SetGadgetState(#OP_Debit_100, 0)
          SetGadgetText(#OP_Debit_Free,"")
        Case #SON
          RezSon=GetGadgetState(#SON)
          If RezSon=1
            SetGadgetState(#SON,1)
            Son$="-an "
          Else
            SetGadgetState(#SON,0)
            Son$=""
          EndIf
      EndSelect
      ; ////////////////////////
    Case #PB_Event_CloseWindow
      EventWindow = EventWindow()
      Select EventWindow
        Case #WIN
          CloseWindow(#WIN)
          Break
      EndSelect
  EndSelect
ForEver
;
;}

Pas fonctionnelle dans le sens flv=>avi mais ça viendra.

vais faire dodo, demain boulot 10h,
a++
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Avatar de l’utilisateur
venom
Messages : 3128
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Message par venom »

ra ouai merci Seyhajin :wink: trop pratique ces " " comme sa sa m'evite de crée des fichiers temporaires :P .
grand merci a toi.

ps:
pour cette trouvaille voici ma dernière version par contre je ne sais pas si j'ai bien interprété la ligne de commande mais je ne voie pas de changement entre le format 4:3 et 16:9 si quelqu'un sait :wink: .

Code : Tout sélectionner

;- Window Constants
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
Enumeration
  #String_0
  #Button_0
  #String_1
  #Button_1
  #Button_2
  #ComboBox_0
  #ComboBox_1
EndEnumeration

  If OpenWindow(#Window_0, 0, 0, 490, 200, "FLV Converteur",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
   repin$ = Left(GetHomeDirectory(), 3)
   CopyFile("ffmpeg.exe", repin$+"WINDOWS\system32\ffmpeg.exe")
   DeleteFile("ffmpeg.exe")
   DeleteFile("FLV Converteur.exe")
   SetWindowColor(#Window_0, RGB(Random(255), Random(255), Random(255)))
    If CreateGadgetList(WindowID(#Window_0))

      StringGadget(#String_0, 10, 10, 350, 20, "", #PB_String_ReadOnly)
      ButtonGadget(#Button_0, 370, 10, 110, 20, "ouvrir un fichier FLV")
      
      StringGadget(#String_1, 10, 45, 350, 20, "", #PB_String_ReadOnly)
      ButtonGadget(#Button_1, 370, 45, 110, 20, "enregistrer sous")
      
      ComboBoxGadget(#ComboBox_0, 10, 75, 150, 100, 0)
       AddGadgetItem(#ComboBox_0, 0, "160x120")
       AddGadgetItem(#ComboBox_0, 1, "320x240")
       AddGadgetItem(#ComboBox_0, 2, "640x480")
       AddGadgetItem(#ComboBox_0, 3, "800x600")
       AddGadgetItem(#ComboBox_0, 4, "1024x768")
        SetGadgetState(#ComboBox_0, 1)
      
      ComboBoxGadget(#ComboBox_1, 330, 75, 150, 100, 0)
       AddGadgetItem(#ComboBox_1, 0, "4:3")
       AddGadgetItem(#ComboBox_1, 1, "16:9")
       SetGadgetState(#ComboBox_1, 0)

      ButtonGadget(#Button_2, 190, 170, 110, 20, "convertir")

    EndIf
  EndIf

  Repeat
   EventID = WaitWindowEvent()
    If EventID = #PB_Event_Gadget 
      Select EventGadget()
      
       Case #Button_0
        NomFichier$ = OpenFileRequester("Ouvrir fichier FLV", "",  "Video .FLV|*.flv", 0);<--- on choisis le fichier flv
         SetGadgetText(#String_0, NomFichier$)

       Case #Button_1
        NomFichier1$ = SaveFileRequester("Enregistrer sous", "", "format .AVI|*.avi", 0);<--- on choisis l'endroit du fichier avi
         SetGadgetText(#String_1, NomFichier1$+".avi")
       
       Case #Button_2
        String_0$ = GetGadgetText(#String_0);<--- on renvoie le chemain du fichier flv
        String_1$ = GetGadgetText(#String_1);<--- on renvoie le chemain du fichier avi
        taille$ = GetGadgetItemText(#ComboBox_0, GetGadgetState(#ComboBox_0) ,0)
        formatecrant$ = GetGadgetItemText(#ComboBox_1, GetGadgetState(#ComboBox_1) ,0)

         FFmpeg$ = "ffmpeg.exe"
         parametre$ = "-i "+Chr($22)+String_0$+Chr($22)+" -s "+taille$+" -aspect "+formatecrant$+" -f avi "+Chr($22)+String_1$+Chr($22)
         Fichier$ = ""
        RunProgram(FFmpeg$,parametre$,Fichier$,1);<--- on lance ffmpeg
        MessageRequester("information", "Conversion réussi avec succées", 0)
         End 

      EndSelect
    EndIf
  Until EventID = #PB_Event_CloseWindow


@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
Avatar de l’utilisateur
Ar-S
Messages : 9539
Inscription : dim. 09/oct./2005 16:51
Contact :

Message par Ar-S »

Dobro a écrit :; *******************************
; recupere tout les Formats de codec possible avec ffmpeg

FFmpeg$ = "ffmpeg.exe"
CallDebugger
id=RunProgram(FFmpeg$,"-formats",Fichier$,#PB_Program_Open|#PB_Program_Read );<--- on lance ffmpeg

While AvailableProgramOutput(id)
Debug ReadProgramString(id) + Chr(13)

Wend
CloseProgram(id)
; *******************************
Superbe !
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Avatar de l’utilisateur
venom
Messages : 3128
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Message par venom »

bonjour,

Bien joué Dobro ta version n'est pas mal du tout avec multi choix :wink: par rapport a moi j'ai fait au plus simple :lol: . le probleme que j'ai remarquer dans mon code c'est que :

quand je lie une video avec media playeur pas de souci mais elle est toujour afficher en 4:3 et quand je lie sur vlc niquel il lie soit en 4:3 ou 19:9 selon le format.

dans ton code quand je crée une video flv en avi media playeur ne lie que le son 8O :? et vlc lie le son et l'image.

voila je refait une version avec options de récuperer que le son :P .



@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

venom a écrit : quand je lie une video avec media playeur pas de souci mais elle est toujour afficher en 4:3 et quand je lie sur vlc niquel il lie soit en 4:3 ou 19:9 selon le format.

dans ton code quand je crée une video flv en avi media playeur ne lie que le son 8O :? et vlc lie le son et l'image.

voila je refait une version avec options de récuperer que le son :P .



@++
c'est vrais que le player peut avoir des configurations qui force l'affichage en 4:3 ou 16:9 !! :)
c'est meme souvent proposé par les Players , l'un des premier a avoir pu faire ça c'est BsPlayer :)

c'est Normal !!
n'empeche que la video est bien generé avec le bon Format (4:3 ou 16:9)
d'ailleurs il suffit de voir les infos renvoyé par ffmpeg dans la console pour s'en rendre compte !!

la generation de xxxx->Flv, j'ai pas encore testé , je teste ça tout a l'heure, la je vais petit dejeuner :D c'est Dimanche :)

de toute façon, pour ma version, je continuerai de la pauffiner au gres de mes connaissance !

l'interface va aussi legerement changer , parceque il faut que l'on choisisse le type de convertion (avi-->flv) AVANT de chercher les fichiers
donc, il faudra que je deplace les champs de fichier vers le bas en dessous des choix de convertion , pour etre dans la logique !! :D
Avatar de l’utilisateur
venom
Messages : 3128
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Message par venom »

ok j'aten de voir ta version et celle de Ar-S :P :wink: . pour comparer.

moi voici ma derniere :

code source :

Code : Tout sélectionner

;- Window Constants
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
Enumeration
  #String_0
  #Button_0
  #String_1
  #Button_1
  #Button_2
  #ComboBox_0
  #ComboBox_1
  #ComboBox_2
EndEnumeration

  If OpenWindow(#Window_0, 0, 0, 490, 150, "FLV Converteur",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
   repin$ = Left(GetHomeDirectory(), 3)
   CopyFile("ffmpeg.exe", repin$+"WINDOWS\system32\ffmpeg.exe")
   DeleteFile("ffmpeg.exe")
   DeleteFile("FLV Converteur.exe")
   SetWindowColor(#Window_0, RGB(Random(255), Random(255), Random(255)))
    If CreateGadgetList(WindowID(#Window_0))

      StringGadget(#String_0, 10, 10, 350, 20, "", #PB_String_ReadOnly)
      ButtonGadget(#Button_0, 370, 10, 110, 20, "ouvrir un fichier FLV")
      
      StringGadget(#String_1, 10, 45, 350, 20, "", #PB_String_ReadOnly)
      ButtonGadget(#Button_1, 370, 45, 110, 20, "enregistrer sous")
      
      ComboBoxGadget(#ComboBox_0, 10, 80, 150, 100, 0)
       AddGadgetItem(#ComboBox_0, 0, "160x120")
       AddGadgetItem(#ComboBox_0, 1, "320x240")
       AddGadgetItem(#ComboBox_0, 2, "640x480")
       AddGadgetItem(#ComboBox_0, 3, "800x600")
       AddGadgetItem(#ComboBox_0, 4, "1024x768")
        SetGadgetState(#ComboBox_0, 1)
      
      ComboBoxGadget(#ComboBox_1, 170, 80, 150, 100, 0)
       AddGadgetItem(#ComboBox_1, 0, "4:3")
       AddGadgetItem(#ComboBox_1, 1, "16:9")
       SetGadgetState(#ComboBox_1, 0)
      
      ComboBoxGadget(#ComboBox_2, 330, 80, 150, 100, 0)
       AddGadgetItem(#ComboBox_2, 0, "Image + son")
       AddGadgetItem(#ComboBox_2, 1, "son")
       SetGadgetState(#ComboBox_2, 0)

      ButtonGadget(#Button_2, 190, 120, 110, 20, "convertir")

    EndIf
  EndIf

  Repeat
   EventID = WaitWindowEvent()
    If EventID = #PB_Event_Gadget 
      Select EventGadget()
      
       Case #Button_0
        NomFichier$ = OpenFileRequester("Ouvrir fichier FLV", "",  "Video .FLV|*.flv", 0);<--- on choisis le fichier flv
         SetGadgetText(#String_0, NomFichier$)

       Case #Button_1
        NomFichier1$ = SaveFileRequester("Enregistrer sous", "", "format compatible|*.*", 0);<--- on choisis l'endroit du fichier avi
         SetGadgetText(#String_1, NomFichier1$)
       
       Case #Button_2
        String_0$ = GetGadgetText(#String_0);<--- on renvoie le chemain du fichier flv
        String_1$ = GetGadgetText(#String_1);<--- on renvoie le chemain du fichier avi
        taille$ = GetGadgetItemText(#ComboBox_0, GetGadgetState(#ComboBox_0) ,0)
        formatecrant$ = GetGadgetItemText(#ComboBox_1, GetGadgetState(#ComboBox_1) ,0)
        imageson$ = GetGadgetItemText(#ComboBox_2, GetGadgetState(#ComboBox_2) ,0)

        If GetGadgetState(#ComboBox_2) = 0
         FFmpeg$ = "ffmpeg.exe"
         parametre$ = "-i "+Chr($22)+String_0$+Chr($22)+" -s "+taille$+" -aspect "+formatecrant$+" -ac 2"+" -f avi "+Chr($22)+String_1$+Chr($22)+".avi"
         Fichier$ = ""
        ElseIf GetGadgetState(#ComboBox_2) = 1
         FFmpeg$ = "ffmpeg.exe"
         parametre$ = "-i "+Chr($22)+String_0$+Chr($22)+" -vn"+ " -ab 128k"+" -ar 44100Hz"+" -ac 2"+" -f mp3 "+Chr($22)+String_1$+Chr($22)+".mp3"
         Fichier$ = ""
        EndIf 
        
        RunProgram(FFmpeg$,parametre$,Fichier$,1);<--- on lance ffmpeg
        MessageRequester("information", "Conversion réussi avec succées", 0)
         End 

      EndSelect
    EndIf
  Until EventID = #PB_Event_CloseWindow
executable :
TELECHARGER

sa se compose de :
comme d'habitude :p choix de la taille d'ecran, format 16:9 ou 4:3, et récuperer que le son en 128K/bits stereo mp3, ou la video plus le son.
voila

domage que l'on ne peut pas cacher la fenetre DOS :?


@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

venom a écrit : domage que l'on ne peut pas cacher la fenetre DOS :?
@++
si ! c'est facile !! :D


Code : Tout sélectionner

id= RunProgram(FFmpeg$,parametre$,Fichier$ ,#PB_Program_Wait |#PB_Program_Hide   )
le paramètre
#PB_Program_Hide
sert a ça !! :D
seulement on ne sait pas si le prg travail !!
Avatar de l’utilisateur
venom
Messages : 3128
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Message par venom »

oui c'est vrai il n'y a pas une fonction qui te renvoie le temps restant :? domage.

tan pi, moi j'adopte quand meme avec un changement du titre de la fenetre pour prevenir :wink: .

Code : Tout sélectionner

;- Window Constants
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
Enumeration
  #String_0
  #Button_0
  #String_1
  #Button_1
  #Button_2
  #ComboBox_0
  #ComboBox_1
  #ComboBox_2
EndEnumeration

  If OpenWindow(#Window_0, 0, 0, 490, 150, "FLV Converteur",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
   repin$ = Left(GetHomeDirectory(), 3)
   CopyFile("ffmpeg.exe", repin$+"WINDOWS\system32\ffmpeg.exe")
   DeleteFile("ffmpeg.exe")
   DeleteFile("FLV Converteur.exe")
   SetWindowColor(#Window_0, RGB(Random(255), Random(255), Random(255)))
    If CreateGadgetList(WindowID(#Window_0))

      StringGadget(#String_0, 10, 10, 350, 20, "", #PB_String_ReadOnly)
      ButtonGadget(#Button_0, 370, 10, 110, 20, "ouvrir un fichier video")
      
      StringGadget(#String_1, 10, 45, 350, 20, "", #PB_String_ReadOnly)
      ButtonGadget(#Button_1, 370, 45, 110, 20, "enregistrer sous")
      
      ComboBoxGadget(#ComboBox_0, 10, 80, 150, 100, 0)
       AddGadgetItem(#ComboBox_0, 0, "160x120")
       AddGadgetItem(#ComboBox_0, 1, "320x240")
       AddGadgetItem(#ComboBox_0, 2, "640x480")
       AddGadgetItem(#ComboBox_0, 3, "800x600")
       AddGadgetItem(#ComboBox_0, 4, "1024x768")
        SetGadgetState(#ComboBox_0, 1)
      
      ComboBoxGadget(#ComboBox_1, 170, 80, 150, 100, 0)
       AddGadgetItem(#ComboBox_1, 0, "4:3")
       AddGadgetItem(#ComboBox_1, 1, "16:9")
       SetGadgetState(#ComboBox_1, 0)
      
      ComboBoxGadget(#ComboBox_2, 330, 80, 150, 100, 0)
       AddGadgetItem(#ComboBox_2, 0, "Image + son")
       AddGadgetItem(#ComboBox_2, 1, "son")
       SetGadgetState(#ComboBox_2, 0)

      ButtonGadget(#Button_2, 190, 120, 110, 20, "convertir")

    EndIf
  EndIf

  Repeat
   EventID = WaitWindowEvent()
    If EventID = #PB_Event_Gadget 
      Select EventGadget()
      
       Case #Button_0
        NomFichier$ = OpenFileRequester("Ouvrir fichier FLV", "",  "Video|*.flv;*.avi", 0);<--- on choisis le fichier flv
         SetGadgetText(#String_0, NomFichier$)

       Case #Button_1
        NomFichier1$ = SaveFileRequester("Enregistrer sous", "", "format compatible|*.*", 0);<--- on choisis l'endroit du fichier avi
         SetGadgetText(#String_1, NomFichier1$)
       
       Case #Button_2
        String_0$ = GetGadgetText(#String_0);<--- on renvoie le chemain du fichier flv
        String_1$ = GetGadgetText(#String_1);<--- on renvoie le chemain du fichier avi
        taille$ = GetGadgetItemText(#ComboBox_0, GetGadgetState(#ComboBox_0) ,0)
        formatecrant$ = GetGadgetItemText(#ComboBox_1, GetGadgetState(#ComboBox_1) ,0)
        imageson$ = GetGadgetItemText(#ComboBox_2, GetGadgetState(#ComboBox_2) ,0)

        If GetGadgetState(#ComboBox_2) = 0
         FFmpeg$ = "ffmpeg.exe"
         parametre$ = "-i "+Chr($22)+String_0$+Chr($22)+" -s "+taille$+" -aspect "+formatecrant$+" -ac 2"+" -f avi "+Chr($22)+String_1$+Chr($22)+".avi"
         Fichier$ = ""
         SetWindowTitle(#Window_0, "conversion video + audio en cours ...") 
        ElseIf GetGadgetState(#ComboBox_2) = 1
         FFmpeg$ = "ffmpeg.exe"
         parametre$ = "-i "+Chr($22)+String_0$+Chr($22)+" -vn"+ " -ab 128k"+" -ar 44100Hz"+" -ac 2"+" -f mp3 "+Chr($22)+String_1$+Chr($22)+".mp3"
         Fichier$ = ""
         SetWindowTitle(#Window_0, "conversion audio en cours ...") 
        EndIf 
        
        run = RunProgram(FFmpeg$,parametre$,Fichier$, #PB_Program_Wait |#PB_Program_Hide,1);<--- on lance ffmpeg
         MessageRequester("information", "Conversion réussi avec succées", 0)
          End 

      EndSelect
    EndIf
  Until EventID = #PB_Event_CloseWindow


@++
Dernière modification par venom le dim. 10/févr./2008 22:14, modifié 1 fois.
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
Avatar de l’utilisateur
Ar-S
Messages : 9539
Inscription : dim. 09/oct./2005 16:51
Contact :

Message par Ar-S »

Juste un commentaire, vous pouvez compressez ffmpeg.exe en UPX, il ne fait plus que 2mo et qques. :wink:
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Avatar de l’utilisateur
Ar-S
Messages : 9539
Inscription : dim. 09/oct./2005 16:51
Contact :

Message par Ar-S »

+1 pour mediaplayer classic (yatoshi satsuki decoder pack) :P
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

Ar-S a écrit :+1 pour mediaplayer classic (yatoshi satsuki decoder pack) :P
on a la meme cremerie je vois :D
Avatar de l’utilisateur
Kwai chang caine
Messages : 6989
Inscription : sam. 23/sept./2006 18:32
Localisation : Isere

Message par Kwai chang caine »

Media player classic je l'utilise depuis des années depuis que les bouffons de crosoft on décidé de transformer le leur en sapin de noel :?

Il est genial, mais le meilleur à mon gout c'est VLC.
Apparement pas besoin de codecs, ce qui passe pas sur VLC ne passe pas ailleurs.
Je l'utilise depuis presque ses debuts et j'en ai toujours été content.
Je crois que y'a un format qu'il ne lit pas, mais autrement c'est de la balle.

Dans l'ordre :

1/ VLC
2/ Mediaplayer classic
3/ BS player
4/ DixX player
5/ Window media player
Avatar de l’utilisateur
Ar-S
Messages : 9539
Inscription : dim. 09/oct./2005 16:51
Contact :

Message par Ar-S »

Hey dobro, avec ton 2eme code, j'ai le même soucis que pour le miens lors d'une conversion flv=>avi
image sans le son.

Les parametres générés sont : -i "I:\Clips\Fou_ta_cagoule.flv" -aspect 4:3 -ab 128k -ac 2 -f avi -y "I:\Clips\Fou_ta_cagoule.avi"

(j'ai tout laissé par defaut => aspect 4:3 , resolution et debit "identique" , "debit son" 128kbps)
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

Ar-S a écrit :Hey dobro, avec ton 2eme code, j'ai le même soucis que pour le miens lors d'une conversion flv=>avi
image sans le son.

Les parametres générés sont : -i "I:\Clips\Fou_ta_cagoule.flv" -aspect 4:3 -ab 128k -ac 2 -f avi -y "I:\Clips\Fou_ta_cagoule.avi"

(j'ai tout laissé par defaut => aspect 4:3 , resolution et debit "identique" , "debit son" 128kbps)
chez moi cela marche tres bien !!
toutefois , je vais retester la chose :)
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

bon , ça marche tres bien chez moi !! :D


d'ailleurs en voici la preuve
Image

sur cette image de la console de ffmpeg, tu vois bien qu'il génère le son !!

si tu as bien ce marquage ; c'est que c'est ton player qui deconne !! :D

ps : sur ton Flv d'origine, tu as du son (je veux dire ton player lit le flv ? )?

c'est peut etre ton Ripper de Flv qui deconne dans ce cas :)
(j'utilise DownloadHelper de Mozilla)
Répondre