@ProWo
sample code in VB to add an audio slider control to FFplay preview form.
Creating a Visual Basic application to add an audio slider to an `ffplay` preview form involves several steps. Since `ffplay` is a command-line tool and doesn't have a built-in GUI, you'll need to create a custom form in Visual Basic that can control `ffplay` via command-line arguments and update the audio volume in real-time.
Below is an example of how you might achieve this using Visual Basic .NET (VB.NET) with Windows Forms. This example assumes you have a basic understanding of VB.NET and Windows Forms.
### Step-by-Step Guide
1. **Create a new Windows Forms Application project in Visual Studio.**
2. **Add a TrackBar control to the form for the audio slider.**
3. **Add a PictureBox control to display the video preview.**
4. **Add a Button control to start the video playback.**
5. **Write the code to handle the audio volume adjustment.**
### Code Example
```Code:```vb Imports System.Diagnostics Imports System.Threading Public Class Form1 Private ffplayProcess As Process Private videoFilePath As String = "path\to\your\video.mp4" ' Replace with your video file path Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ' Initialize the TrackBar for audio volume control TrackBar1.Minimum = 0 TrackBar1.Maximum = 100 TrackBar1.Value = 50 ' Default volume level TrackBar1.TickFrequency = 10 End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ' Start the ffplay process StartFFplay() End Sub Private Sub TrackBar1_Scroll(sender As Object, e As EventArgs) Handles TrackBar1.Scroll ' Adjust the audio volume AdjustAudioVolume(TrackBar1.Value) End Sub Private Sub StartFFplay() ' Create a new process to run ffplay ffplayProcess = New Process() ffplayProcess.StartInfo.FileName = "ffplay.exe" ffplayProcess.StartInfo.Arguments = $"-i ""{videoFilePath}""" ffplayProcess.StartInfo.UseShellExecute = False ffplayProcess.StartInfo.RedirectStandardInput = True ffplayProcess.StartInfo.RedirectStandardOutput = True ffplayProcess.StartInfo.RedirectStandardError = True ffplayProcess.StartInfo.CreateNoWindow = True ' Start the process ffplayProcess.Start() ' Read the output to capture the process ID Dim output As String = ffplayProcess.StandardOutput.ReadToEnd() Dim error As String = ffplayProcess.StandardError.ReadToEnd() ' Close the standard output and error streams ffplayProcess.StandardOutput.Close() ffplayProcess.StandardError.Close() ' Adjust the initial audio volume AdjustAudioVolume(TrackBar1.Value) End Sub Private Sub AdjustAudioVolume(volume As Integer) ' Convert the volume to a factor between 0 and 1 Dim volumeFactor As Double = volume / 100.0 ' Send the volume adjustment command to ffplay If ffplayProcess IsNot Nothing AndAlso ffplayProcess.HasExited = False Then ffplayProcess.StandardInput.WriteLine($"volume {volumeFactor}") ffplayProcess.StandardInput.Flush() End If End Sub Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing ' Kill the ffplay process when the form is closing If ffplayProcess IsNot Nothing AndAlso Not ffplayProcess.HasExited Then ffplayProcess.Kill() ffplayProcess.WaitForExit() End If End Sub End Class
### Explanation
1. **Form1_Load**: Initializes the `TrackBar` control for audio volume control. The minimum value is 0, the maximum value is 100, and the default value is 50.
2. **Button1_Click**: Starts the `ffplay` process to play the video. The `StartFFplay` method is called to handle the process creation and initialization.
3. **TrackBar1_Scroll**: Adjusts the audio volume based on the `TrackBar` value. The `AdjustAudioVolume` method is called to send the volume adjustment command to `ffplay`.
4. **StartFFplay**: Creates a new process to run `ffplay` with the specified video file. It redirects the standard input, output, and error streams to capture the process ID and send commands to `ffplay`.
5. **AdjustAudioVolume**: Converts the `TrackBar` value to a volume factor between 0 and 1 and sends the volume
+ Reply to Thread
Results 2,101 to 2,130 of 2158
-
As always .. there is nothing wrong with my environment
-
@VideoAI
sample code in VB to add an audio slider control to FFplay preview form.
my app is not a media player, the preview is just for control.
Since Clever already supports 'scan for errors' and batch processing; is it not possible to
combine both to scan many files? or to scan a folder [of files]?
A feature like that would be a big time saver. -
As always .. there is nothing wrong with my environment
-
@ ProWo
3.4.3 Feedback
- Input limitations for idx field in mux/batch grid.
A maximum of three digits are allowed. Good.
EDIT: I forgot that this also makes sense in the Join grid.
- Check for cd_rom drive (to avoid wrong destination selection).
My drive get recognized.
- Input limitation for start time textbox in video crop (now numbers only).
Is working.
- Bug in raw video extraction with mpeg2video codec.
No problem found. Fixed.
- Bug with preview length with frame accurate cutting.
No problem found. Fixed.
- Bug with missing aborted reset and closing to batch action in audio encoding.
No problem found. Fixed.
- Cut help (added frame accurate cut info).
Thanks!
- Bug with new encode length with frame accurate cutting.
No length problem found. Fixed.
---
Problems:
- Audio encoding, Channels, Remap button disappear when you use Stay open plus Encode or To batch.
- "Frame accurate cut" has no "To batch" button.Last edited by Findu; 30th Jun 2025 at 09:00.
-
-
I love that Clever now remembers that last format/container used and the last output folder used.
How about memorizing the last "stay open/not open" state of the mux page too?
Also, How about memorizing the default for a chosen language for the streams? My default language is English (en, eng). It would be great if Clever automatically checks "default" if the language is English, or the last language checked.
Thank you.Last edited by davidt1; 30th Jun 2025 at 13:40.
-
@ProWo
--- Feature Request ----
Would it be possible to add the following 6 parameters to the Join screen?
--------------------------
To successfully join files in ffmpeg, several parameters should match.
1. Codecs, video & audio codecs should match, ex: AVC/AAC
2. Video Resolution, ex: 1280x720 (width x height). Although, slight differences might still work.
3. Frame Rate [FPS], ex: 30.
4. Audio Sample Rate [ASR], ex: 48 khz.
5. Audio Channels, The number of audio channels (mono, stereo, 5.1 surround, etc.) should match.
6. Pixel Format, of the video streams should match. ex: files should use yuv420p or yuv422p.
Container Format: While not strictly necessary for the video and audio streams themselves,
it's often easier to work with files that have the same container format (e.g., MP4, MKV).As always .. there is nothing wrong with my environment -
Codecs and streams indexes check is already implemented.
2. Video Resolution, ex: 1280x720 (width x height). Although, slight differences might still work.
3. Frame Rate [FPS], ex: 30.
4. Audio Sample Rate [ASR], ex: 48 khz.
5. Audio Channels, The number of audio channels (mono, stereo, 5.1 surround, etc.) should match.
6. Pixel Format, of the video streams should match. ex: files should use yuv420p or yuv422p.
Container Format: While not strictly necessary for the video and audio streams themselves,
it's often easier to work with files that have the same container format (e.g., MP4, MKV)
BTW:
Have you tested the new batch scan for errors in the last nightly? -
@ProWo
I am in the process of testing the new batch scan. Thanks for adding it in.
I ran the batch scan twice, each time scanning ~ 20 files. I minimized clever and let it run in the background.
The new batch scan identified one issue with one of the files and created a text file indicating the error found.
[this file may have an issue that needs further investigation, will discuss in a separate post later.]
depending on the number of files and their size, it may take some time to scan all 1200 files.
will report back on that when finished. Fingers crossed.
Last edited by videoAI; 1st Jul 2025 at 05:57.
As always .. there is nothing wrong with my environment -
Although the join may be successful, the resulting file may not play proper.
Also having the parameters shown, as columns, in the grid saves time and
tells the user, at a glance, which files can be joined and which ones can't, and should be removed.
The alternative is to use media info, which a casual user, may not be aware of.
Would you at least consider adding #2,3,4 ..
BTW, I actually use Losslesscut to merge my videos.
It auto detects mismatches across all 6 parameters, but allows you to proceed with a warning.
The warning says the output may not be playable, which is true in most cases.
Ex; joining mismatched FPS yields jerky motion or freezes.
joining mismatched Audio ASR yields mute or noisy output audio.
Last edited by videoAI; 1st Jul 2025 at 06:11.
As always .. there is nothing wrong with my environment -
@ ProWo
3.4.3.02 Feedback
- Audio encoding, Channels, Remap button disappear when you use Stay open plus Encode or To batch.
Bug has been fixed.
- Input limitations for idx field in mux/batch grid.
This also makes sense in the Join grid.
- Would it be possible to retain embedded chapters upon joining?
The timing would have to be adjusted, of course, similar to the subtitles. Or as with cutting for subtitles and chapters. Since embedded chapters are saved when an audio stream is encoded into a m4a/mka container, this would be nice here as well. However, embedded chapters could also be replaced by the actual feature "Insert chapters". -
Just dragged 1344 files to test .. it took few minutes with an hour glass before the grid loaded.
Started the process @ 9 AM. will see how long it takes to process all of them and how many
bad files it finds.
[Attachment 87685 - Click to enlarge]
Last edited by videoAI; 1st Jul 2025 at 08:22.
As always .. there is nothing wrong with my environment -
-
Will be added, for audio encoding/video encoding section too.
Also, How about memorizing the default for a chosen language for the streams? My default language is English (en, eng). It would be great if Clever automatically checks "default" if the language is English, or the last language checked.
Not useful. -
As always .. there is nothing wrong with my environment
-
As always .. there is nothing wrong with my environment
-
Retest this with the last version (or nightly). Should not happen anymore.
First rename portable.config to _portable.config (as backup), then start clever FFmpeg-GUI.
Follow the instructions.
If all went fine, close the app, delete the new created portable.config file and rename the backup from _portable.config to portable.config.
All done, the app starts as before the test. -
@ProWo
1st error found by the new batch scan [20 files] said:
Code:[h264 @ 0000014abd919500] Error splitting the input into NAL units
The mp4 file that was flagged, played fine in my mpc-be player !!
Asking my AI agent, yielded this response:
The error message [h264 @ 0000014abd919500] Error splitting the input into NAL units typically
indicates that there is an issue with the H.264 video stream being processed. This error can occur
for several reasons, including corrupted video files, incorrect codec settings, or issues with the input stream.
so, I did some research and came up with a plan to diagnose and hopefully fix the file.
1. I needed to find out when the error was occurring, so I wrote an ffmpeg command to pipe the file via ffplay.
Code:ffmpeg -hide_banner -i %%f -map 0 -c copy -f matroska - | ffplay -hide_banner -vf "scale=320:240" -af "volume=0.1" -window_title %%f -autoexit -
Code:[h264 @ 0000012ae7c295c0] Invalid NAL unit size (1363 > 149).bitrate= 866.2kbits/s speed=0.995x [h264 @ 0000012ae7c295c0] missing picture in access unit with size 153 [out#0/matroska @ 0000012ae7486940] video:14403KiB audio:1163KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.520971% frame= 3693 fps= 25 q=-1.0 Lsize= 15646KiB time=00:02:27.75 bitrate= 867.5kbits/s speed=0.995x [h264 @ 0000014abdae3d40] Invalid NAL unit size (1363 > 149). [h264 @ 0000014abdae3d40] missing picture in access unit with size 153 [h264 @ 0000014abd919500] Invalid NAL unit size (1363 > 149). [h264 @ 0000014abd919500] Error splitting the input into NAL units. 147.72 A-V: -0.012 fd= 638 aq= 0KB vq= 0KB sq= 0B Press any key to continue . . .
ffplay never stopped playing the file and exited at the pause command.
3. then I tried fixing the file with running many ffmpeg commands. none worked. till I tried this:
Code:ffmpeg -hide_banner -i %%f -c:v copy -bsf:v h264_mp4toannexb "%%~nf.ts"
4. Finally, I converted it back to mp4 and it ran through ffplay without any errors or issues.
so, the output file is fixed for good.
it seems that a Bitstream filter can help in handling problematic streams.
Any thoughts why this error occurred in the first place?
As always .. there is nothing wrong with my environment -
As always .. there is nothing wrong with my environment
-
As always .. there is nothing wrong with my environment
-
@ ProWo
3.4.3.02 Feedback 2
>> Input limitations for idx field in Join grid.
> Already fixed in 3.4.3.02
Your right. You can't enter numbers larger than 999 but you can add more files then 999. Same for streams in Multiplex and Batch tasks.
They will all reload if you close the app for any reason.
Good that identical idx numbers are processed in the order as they appear in the grid. Therefore, no check for identical idx numbers is necessary.
---
>> Would it be possible to retain embedded chapters upon joining?
> Not possible.
Too bad! As embedded chapters are retained when cutting, one might assume they'd be retained when joining. -
As always .. there is nothing wrong with my environment
-
15.5 hrs later, clever is at task 526, and found 7 corrupted files.
@ ProWo
I started prepping a detailed testing report consisting of Pros, Cons, Recommendations, and Potential Enhancements.
but first I have few questions:
1. During batch scan, do you currently employ;
- Multi threading?
- Handling tasks in parallel?
2. What is the Maximum limit for the number of tasks in a single batch scan? is there any?
3. What happens, currently, after the batch scan to the:
- Processed files? Do you attempt to move all of them to Mux/Join grid?
- Damaged files? Do you attempt to move all of them to Mux/Join grid?
Please let us know ..
As always .. there is nothing wrong with my environment -
The FFmpeg defaults are used.
2. What is the Maximum limit for the number of tasks in a single batch scan? is there any?
3. What happens, currently, after the batch scan to the:
- Processed files? Do you attempt to move all of them to Mux/Join grid?
- Damaged files? Do you attempt to move all of them to Mux/Join grid?
I'll add a hardware acceleration option to relieve the cpu on suitable systems and transfer the decoding to the gpu.
BTW:
Please don't add the full quotes to your replys. Thanks. -
@ ProWo
3.4.3.02 Feedback 3
The normal "Scan for errors" for proper files always ends in an error:
The same scan as a Batch has no problem!
System.IO.FileNotFoundException: Die Datei "C:\Users\Findu\Downloads\input4_errors.txt" konnte nicht gefunden werden.
Dateiname: "C:\Users\Findu\Downloads\input4_errors.txt"
bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
bei System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
bei System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
bei System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
bei System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost)
bei clever_FFmpeg_GUI.Form1.P_closed()
bei clever_FFmpeg_GUI.Form1.VB$StateMachine_512_Button 9_ClickAsync.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.ExceptionServices.ExceptionDispatch Info.Throw()
[Attachment 87695 - Click to enlarge] -
As always .. there is nothing wrong with my environment
Similar Threads
-
GUI for ffmpeg x265 encoder
By david55 in forum Video ConversionReplies: 15Last Post: 11th May 2025, 09:15 -
New small GUI for FFmpeg
By ProWo in forum Video ConversionReplies: 29Last Post: 24th Feb 2024, 02:06 -
Best GUI for ffmpeg encoding
By usta in forum Video ConversionReplies: 25Last Post: 17th Jan 2019, 11:23 -
GUI for FFMpeg amf?
By Micky in forum Video ConversionReplies: 0Last Post: 14th Jan 2018, 07:45 -
dmMediaEncoder v1.8.0 - crossplatform FFMPEG GUI
By mdalacu in forum Video ConversionReplies: 38Last Post: 29th Sep 2015, 00:19