Accueil > > > STREAMING AUDIO ET VIDEO
STREAMING AUDIO ET VIDEO
Information sur la source
Description
Voici une petite source geniale extra lissime !
Je l'ai recupérée sur The Code Project et l'ai modifié de maniere a la rendre plus accessible et a ce kelle accepte le son dans le .avi
Cette source utilise DirextX et DirectShow.
ATTENTION: fonctionne avec DX9 et DX8.1.
Les 2 DLL fournit possedent leur source en C# si besoin IM moi.
Source
- Imports DirectX.Capture
-
- Public Class Form1
- Inherits System.Windows.Forms.Form
-
- #Region " Code généré par le Concepteur Windows Form "
-
- Public Sub New()
- MyBase.New()
-
- 'Cet appel est requis par le Concepteur Windows Form.
- InitializeComponent()
-
- 'Ajoutez une initialisation quelconque après l'appel InitializeComponent()
-
- End Sub
-
- 'La méthode substituée Dispose du formulaire pour nettoyer la liste des composants.
- Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
- If disposing Then
- If Not (components Is Nothing) Then
- components.Dispose()
- End If
- End If
- MyBase.Dispose(disposing)
- End Sub
-
- 'Requis par le Concepteur Windows Form
- Private components As System.ComponentModel.IContainer
-
- 'REMARQUE : la procédure suivante est requise par le Concepteur Windows Form
- 'Elle peut être modifiée en utilisant le Concepteur Windows Form.
- 'Ne la modifiez pas en utilisant l'éditeur de code.
- Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
- Friend WithEvents Button1 As System.Windows.Forms.Button
- Friend WithEvents ComboBox2 As System.Windows.Forms.ComboBox
- Friend WithEvents Panel1 As System.Windows.Forms.Panel
- Friend WithEvents Button2 As System.Windows.Forms.Button
- Friend WithEvents Button3 As System.Windows.Forms.Button
- Friend WithEvents Label1 As System.Windows.Forms.Label
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
- Me.ComboBox1 = New System.Windows.Forms.ComboBox()
- Me.Button1 = New System.Windows.Forms.Button()
- Me.ComboBox2 = New System.Windows.Forms.ComboBox()
- Me.Panel1 = New System.Windows.Forms.Panel()
- Me.Button2 = New System.Windows.Forms.Button()
- Me.Button3 = New System.Windows.Forms.Button()
- Me.Label1 = New System.Windows.Forms.Label()
- Me.SuspendLayout()
- '
- 'ComboBox1
- '
- Me.ComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
- Me.ComboBox1.Location = New System.Drawing.Point(60, 16)
- Me.ComboBox1.Name = "ComboBox1"
- Me.ComboBox1.Size = New System.Drawing.Size(368, 21)
- Me.ComboBox1.TabIndex = 0
- '
- 'Button1
- '
- Me.Button1.Location = New System.Drawing.Point(60, 60)
- Me.Button1.Name = "Button1"
- Me.Button1.Size = New System.Drawing.Size(368, 23)
- Me.Button1.TabIndex = 1
- Me.Button1.Text = "Valider la configuration"
- '
- 'ComboBox2
- '
- Me.ComboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
- Me.ComboBox2.Location = New System.Drawing.Point(60, 36)
- Me.ComboBox2.Name = "ComboBox2"
- Me.ComboBox2.Size = New System.Drawing.Size(368, 21)
- Me.ComboBox2.TabIndex = 2
- '
- 'Panel1
- '
- Me.Panel1.BackColor = System.Drawing.Color.Black
- Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
- Me.Panel1.Location = New System.Drawing.Point(84, 128)
- Me.Panel1.Name = "Panel1"
- Me.Panel1.Size = New System.Drawing.Size(320, 240)
- Me.Panel1.TabIndex = 3
- Me.Panel1.Visible = False
- '
- 'Button2
- '
- Me.Button2.Location = New System.Drawing.Point(84, 376)
- Me.Button2.Name = "Button2"
- Me.Button2.TabIndex = 4
- Me.Button2.Text = "Start"
- '
- 'Button3
- '
- Me.Button3.Enabled = False
- Me.Button3.Location = New System.Drawing.Point(328, 376)
- Me.Button3.Name = "Button3"
- Me.Button3.TabIndex = 5
- Me.Button3.Text = "Stop"
- '
- 'Label1
- '
- Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
- Me.Label1.ForeColor = System.Drawing.Color.Red
- Me.Label1.Location = New System.Drawing.Point(80, 224)
- Me.Label1.Name = "Label1"
- Me.Label1.Size = New System.Drawing.Size(328, 23)
- Me.Label1.TabIndex = 6
- Me.Label1.Text = "Enregistrement en cours ..."
- Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
- Me.Label1.Visible = False
- '
- 'Form1
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
- Me.ClientSize = New System.Drawing.Size(492, 429)
- Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label1, Me.Button3, Me.Button2, Me.Panel1, Me.ComboBox2, Me.Button1, Me.ComboBox1})
- Me.Name = "Form1"
- Me.Text = "Choisir la caméra"
- Me.ResumeLayout(False)
-
- End Sub
-
- #End Region
-
- Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
- Dim j As Short
- Dim f As Filter
-
- 'listage des peripheriques video installés sur la machine
- ComboBox1.Items.Clear()
- For j = 0 To Dispositivos.VideoInputDevices.Count - 1
- f = Dispositivos.VideoInputDevices(j)
- ComboBox1.Items.Add(f.Name)
- Next
- If j > 0 Then ComboBox1.SelectedIndex = 0
-
- 'listage des peripheriques audio installés sur la machine
- ComboBox2.Items.Clear()
- For j = 0 To Dispositivos.AudioInputDevices.Count - 1
- f = Dispositivos.AudioInputDevices(j)
- ComboBox2.Items.Add(f.Name)
- Next
- If j > 0 Then ComboBox2.SelectedIndex = 0
-
- End Sub
-
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
- 'pre configuration du capturing
- 'definission de la camera
- CaptureInformation.Camera = Dispositivos.VideoInputDevices(ComboBox1.SelectedIndex)
- 'mise en place du stream video et audio
- CaptureInformation.CaptureInfo = New Capture(CaptureInformation.Camera, Dispositivos.AudioInputDevices(ComboBox2.SelectedIndex))
- 'renseignement du panneau d'affichage de la video
- CaptureInformation.CaptureInfo.PreviewWindow = Panel1
- 'compteur pour les capture d'image (frame video)
- CaptureInformation.Counter = 1
- CaptureInformation.CounterFrames = 1
- 'configurations avancées
- Configurer()
- 'pour faire plus joli
- Button1.Enabled = False
- Panel1.Visible = True
-
- End Sub
-
- Private Sub Configurer()
-
- 'configurations avancées
- 'configuration du systeme de compression video et audio
- CaptureInformation.CaptureInfo.VideoCompressor = Dispositivos.VideoCompressors(0) 'compression video
- 'taille de la video
- CaptureInformation.CaptureInfo.FrameSize = New Size(320, 240) 'taille de la video
- 'FPS de la video
- CaptureInformation.CaptureInfo.FrameRate = 15 'FPS
- 'fichier .avi
- CaptureInformation.CaptureInfo.Filename = Application.StartupPath + "\\essai.avi"
- 'lancement du streaming d'affichage
- CaptureInformation.CaptureInfo.RenderPreview()
-
- End Sub
-
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
-
- 'demarage du streaming avec enregistrement dans le .avi
- CaptureInformation.CaptureInfo.Start()
- 'pour faire plus joli
- Button2.Enabled = False
- Button3.Enabled = True
- Panel1.Visible = False
- Label1.Visible = True
-
- End Sub
-
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
-
- 'arret du streaming
- CaptureInformation.CaptureInfo.Stop()
- 'relancement de la configuration et de laffichage video
- Configurer()
- 'encore pour faire plus jolie
- Panel1.Visible = True
- Button2.Enabled = True
- Button3.Enabled = False
- Panel1.Visible = True
- Label1.Visible = False
-
- End Sub
- End Class
Imports DirectX.Capture
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Code généré par le Concepteur Windows Form "
Public Sub New()
MyBase.New()
'Cet appel est requis par le Concepteur Windows Form.
InitializeComponent()
'Ajoutez une initialisation quelconque après l'appel InitializeComponent()
End Sub
'La méthode substituée Dispose du formulaire pour nettoyer la liste des composants.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Requis par le Concepteur Windows Form
Private components As System.ComponentModel.IContainer
'REMARQUE : la procédure suivante est requise par le Concepteur Windows Form
'Elle peut être modifiée en utilisant le Concepteur Windows Form.
'Ne la modifiez pas en utilisant l'éditeur de code.
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents ComboBox2 As System.Windows.Forms.ComboBox
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.ComboBox1 = New System.Windows.Forms.ComboBox()
Me.Button1 = New System.Windows.Forms.Button()
Me.ComboBox2 = New System.Windows.Forms.ComboBox()
Me.Panel1 = New System.Windows.Forms.Panel()
Me.Button2 = New System.Windows.Forms.Button()
Me.Button3 = New System.Windows.Forms.Button()
Me.Label1 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'ComboBox1
'
Me.ComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ComboBox1.Location = New System.Drawing.Point(60, 16)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(368, 21)
Me.ComboBox1.TabIndex = 0
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(60, 60)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(368, 23)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Valider la configuration"
'
'ComboBox2
'
Me.ComboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ComboBox2.Location = New System.Drawing.Point(60, 36)
Me.ComboBox2.Name = "ComboBox2"
Me.ComboBox2.Size = New System.Drawing.Size(368, 21)
Me.ComboBox2.TabIndex = 2
'
'Panel1
'
Me.Panel1.BackColor = System.Drawing.Color.Black
Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Panel1.Location = New System.Drawing.Point(84, 128)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(320, 240)
Me.Panel1.TabIndex = 3
Me.Panel1.Visible = False
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(84, 376)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 4
Me.Button2.Text = "Start"
'
'Button3
'
Me.Button3.Enabled = False
Me.Button3.Location = New System.Drawing.Point(328, 376)
Me.Button3.Name = "Button3"
Me.Button3.TabIndex = 5
Me.Button3.Text = "Stop"
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.ForeColor = System.Drawing.Color.Red
Me.Label1.Location = New System.Drawing.Point(80, 224)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(328, 23)
Me.Label1.TabIndex = 6
Me.Label1.Text = "Enregistrement en cours ..."
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.Label1.Visible = False
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(492, 429)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label1, Me.Button3, Me.Button2, Me.Panel1, Me.ComboBox2, Me.Button1, Me.ComboBox1})
Me.Name = "Form1"
Me.Text = "Choisir la caméra"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim j As Short
Dim f As Filter
'listage des peripheriques video installés sur la machine
ComboBox1.Items.Clear()
For j = 0 To Dispositivos.VideoInputDevices.Count - 1
f = Dispositivos.VideoInputDevices(j)
ComboBox1.Items.Add(f.Name)
Next
If j > 0 Then ComboBox1.SelectedIndex = 0
'listage des peripheriques audio installés sur la machine
ComboBox2.Items.Clear()
For j = 0 To Dispositivos.AudioInputDevices.Count - 1
f = Dispositivos.AudioInputDevices(j)
ComboBox2.Items.Add(f.Name)
Next
If j > 0 Then ComboBox2.SelectedIndex = 0
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'pre configuration du capturing
'definission de la camera
CaptureInformation.Camera = Dispositivos.VideoInputDevices(ComboBox1.SelectedIndex)
'mise en place du stream video et audio
CaptureInformation.CaptureInfo = New Capture(CaptureInformation.Camera, Dispositivos.AudioInputDevices(ComboBox2.SelectedIndex))
'renseignement du panneau d'affichage de la video
CaptureInformation.CaptureInfo.PreviewWindow = Panel1
'compteur pour les capture d'image (frame video)
CaptureInformation.Counter = 1
CaptureInformation.CounterFrames = 1
'configurations avancées
Configurer()
'pour faire plus joli
Button1.Enabled = False
Panel1.Visible = True
End Sub
Private Sub Configurer()
'configurations avancées
'configuration du systeme de compression video et audio
CaptureInformation.CaptureInfo.VideoCompressor = Dispositivos.VideoCompressors(0) 'compression video
'taille de la video
CaptureInformation.CaptureInfo.FrameSize = New Size(320, 240) 'taille de la video
'FPS de la video
CaptureInformation.CaptureInfo.FrameRate = 15 'FPS
'fichier .avi
CaptureInformation.CaptureInfo.Filename = Application.StartupPath + "\\essai.avi"
'lancement du streaming d'affichage
CaptureInformation.CaptureInfo.RenderPreview()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'demarage du streaming avec enregistrement dans le .avi
CaptureInformation.CaptureInfo.Start()
'pour faire plus joli
Button2.Enabled = False
Button3.Enabled = True
Panel1.Visible = False
Label1.Visible = True
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'arret du streaming
CaptureInformation.CaptureInfo.Stop()
'relancement de la configuration et de laffichage video
Configurer()
'encore pour faire plus jolie
Panel1.Visible = True
Button2.Enabled = True
Button3.Enabled = False
Panel1.Visible = True
Label1.Visible = False
End Sub
End Class
Conclusion
Zip In The Mix
PS: pour plus de detail sur le fonctionnement, ou pour voir comment lancer la configuration de la camera allez voir sur The Code Project
PS2: EDITEZ LA SOURCE AVANT DE LA LANCER POUR LA CONFIGURER
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
GESTION D'EXCEPTION AVEC LES TASKSGESTION D'EXCEPTION AVEC LES TASKS par richardc
Nous avons vu dans un précédent article comment utiliser Task pour effectuer des opérations dans un autre thread.
Malheureusement, comme tout le monde n'est pas parfait, il se peut que cette exécution se passe mal et qu'une exception se produise.
La...
Cliquez pour lire la suite de l'article par richardc DéMARRONS AVEC LES TASKSDéMARRONS AVEC LES TASKS par richardc
Que vous le vouliez ou non, le développement multi-tâche est maintenant une obligation pour toute nouvelle application. Il est donc vital d'en comprendre les mécanismes et de s'y mettre le plus tôt possible.
En attendant le .NET Framework 4.5 avec le...
Cliquez pour lire la suite de l'article par richardc SLIDE & DéMO TECHDAYS 2012 - FAST & FURIOUS XAML APPSSLIDE & DéMO TECHDAYS 2012 - FAST & FURIOUS XAML APPS par Vko
Retrouvez les slides et les démo de ma session Fast & Furious XAML Apps. A ceux qui se posent la question : "est-ce que le code de la DataGrid est disponible?", je vous répondrais "pas encore". Je vais mettre en place un projet codeplex pour part...
Cliquez pour lire la suite de l'article par Vko XNA IS DEAD!XNA IS DEAD! par richardc
Depuis la semaine dernière (et grâce aux TechDays 2012), je me penche activement sur la nouvelle version de Windows, aka Windows 8. Vous me direz, il était temps puisque la première preview date de Septembre dernier.
OK. Remarquez, on n'en est qu'aux...
Cliquez pour lire la suite de l'article par richardc TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 !TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 ! par ROMELARD Fabrice
Speakers: Fabrice Meillon et Stanislas Quastana Cette session est basée entièrement sur celle donnée lors de la BUILD cet hiver. Il n'y a pas d'ajout d'information en rapport avec cet évènement passé. Windows 8 Server sera intégralem...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DocTranslate (V3.1.0.0)DOCTRANSLATE (V3.1.0.0)DocTranslate est un traducteur de document Microsoft Word, PowerPoint et Excel. Il permet d'autom... Cliquez pour télécharger DocTranslate Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System
|