Let's make a FFMeg code snippet and extend Xojo's AV abilities!

Is there any way to get a ffmep value to tell you that a encoding (whether it be re-encoding files or trimming them) to let you know they are finished?
Then you could hold the user before they try to access a file that isn’t there yet.

you can use myshellClass Completed Event Handler.

Here’s a way to draw a waveform of an audio file

[code]Waveform(source as FolderItem, wavecanvas as canvas)

'ffmpeg -i input -filter_complex “showwavespic=split_channels=1” output.png
dim destination as FolderItem
destination=SpecialFolder.ApplicationData.child(“Guitar SightReader Toolbox”).child(“recording bin”).child(“transcribe”).child(“output.png”)
dim mshell as shell
dim x as string=str(wavecanvas.Width)
dim y as string=str(wavecanvas.Height)
dim ffmpegapp as FolderItem = specialfolder.applicationdata.child(“Guitar SightReader Toolbox”).child(“FFMeg”).child(“bin”).child(“ffmpeg.exe”)
if ffmpegapp <> nil and ffmpegapp.Exists then
ffmpegapp = specialfolder.applicationdata.child(“Guitar SightReader Toolbox”).child(“FFMeg”).child(“bin”)
dim ffmpegstring as String = chr(34) + ffmpegapp.NativePath + “ffmpeg”+chr(34)
mshell = new myshellClass
mshell.Mode = 1
dim cmd as String
cmd = ffmpegstring +" -i " +chr(34)+ source.NativePath+chr(34)+" -lavfi showwavespic=split_channels=0:s="+X+“x”+Y+" "+ chr(34)+ destination.NativePath+chr(34)
mshell.Execute cmd

do until destination.Exists
dim pic as Picture
pic = Picture.Open(destination)
return pic

end if[/code]

you can draw a wave into any canvas by

** you need to delete the destination file well ahead of firing this method otherwise it won’t change the image…
dim f as FolderItem
f=SpecialFolder.ApplicationData.child(“Guitar SightReader Toolbox”).child(“recording bin”).child(“transcribe”).child(“output.png”)
'if f.Exists then f.Delete

[quote=261849:@Tim Parnell]To be on the “safe side” legally you cannot bundle FFmpeg with your software. See here
Also, keep in mind a number of the filters (video editing functions) are licensed under GPL and cannot be used in proprietary software. See here

They used to have a “hall of shame,” please don’t give them reason to list “Everything from Xojo users.” See here
Tread lightly.[/quote]
I don’t know if this will work for ffmpeg, in the past we’ve shipped apps with OpenSource ‘executables’ within them. Our first attempt would inform the user that it needs to installed, then if they agreed to it, we would download a version from our site and install it.

Then in the document I read that you’re allowed to include the OpenSource executable in a “delivery assistant”, so we included it as a compressed file within the application, we would then install it on the users computer when it was required. We added a disclaimer indicating the nature of operation of our application. i.e. It utilizes the OpenSource software, but when the software is not installed, it acts as “delivery assistant” for said software. The disclaimer also indicated that our application could be used without OpenSource software, however certain features would be disabled.

This was before Sandboxing came in, so I don’t know if this process is allowed via Sandboxing (I can’t imagine why not, but I can imagine an overzealous reviewer rejecting you for it).

The thing is the ffmpeg group have done a terrific job of creating a tool that a lot of developers need, they then release it as ‘sorta’ open source (but not quite as it has restrictions on it) and up devoting time and resources to chasing down developers who need this tool, but can’t legally use it.

Which begs the question as to why is it ‘sorta’ open sourced with these licenses?

maybe you can add -y to overwrite the image

cmd = ffmpegstring +" -i " +chr(34)+ source.NativePath+chr(34)+" -lavfi showwavespic=split_channels=0:s="+X+“x”+Y+" -y "+ chr(34)+ destination.NativePath+chr(34)

You can also skip the creating of the file by reading it straight in.
Here’s a quicky: https://dl.dropboxusercontent.com/u/609785/Xojo/Forum/ffmpeg_png.xojo_binary_project

Thanks, I changed some things (to find ffmpeg automatically in Linux)


[code]Dim dlg As New OpenDialog
Dim f As FolderItem = dlg.ShowModal()

If f <> Nil and f.Exists then
// Get Helper
dim sh as new shell
dim result as String
sh.Execute ("/usr/bin/which ffmpeg")
result = sh.Result.Replace(EndOfLine, “”)
pWavPic = Mp3ToWavPic(result, f)
End If[/code]

Function Mp3ToWavPic(HelperApp As String, MP3File As FolderItem) As Picture
  If MP3File <> Nil And MP3File.Exists Then
    // Set Command Options
    Dim cmdOptions() As String
    cmdOptions = Array(HelperApp, "-i", MP3File.ShellPath, "-filter_complex", "showwavespic=split_channels=1", "-vcodec png", "-v 0", "-f image2", "-")
    // Start a Shell
    Dim shShell As Shell
    shShell = New Shell
    shShell.Execute(join(cmdOptions, " "))
    // Set result png
    If shShell.ErrorCode = 0 And shShell.Result.Len > 0 Then
      Return Picture.FromData(shShell.Result)
      MsgBox shShell.ReadAll
    End If
  End If
End Function

Aaron Ballman made a VBdeclare converter, maybe this helps to get those dll’s working in Xojo: