Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Ad icon
Video Content Creator
pramukag
Updated:
Sunday at 6:10 AM
Ad icon
QA Engineer Intern
pramukag
Updated:
Sunday at 6:07 AM
Ad icon
Sell your Land, House on idamata.lk for FREE
sajith.xp.pk
Updated:
Thursday at 9:03 AM
Handmade Character Soft Toys
anil1961
Updated:
Jun 23, 2026
Bodim.lk out now !
Manoj Suranga Bandara
Updated:
Jun 21, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
Merge audio and video
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Honey Bunch" data-source="post: 30453628" data-attributes="member: 569484"><p>Here's how you can automate the process of extracting video and audio file names into text files and then merging them using a batch script in <strong>Windows</strong>:</p><p></p><hr /><h3><strong>Step 1: Script Overview</strong></h3><p>This script will:</p><p></p><ol> <li data-xf-list-type="ol">Generate a list of video file names (videos.txt).</li> <li data-xf-list-type="ol">Generate a list of audio file names (audios.txt).</li> <li data-xf-list-type="ol">Match video files with corresponding audio files by name.</li> <li data-xf-list-type="ol">Merge the audio and video files using FFmpeg.</li> </ol><hr /><h3><strong>Step 2: Create the Script</strong></h3> <ol> <li data-xf-list-type="ol">Open Notepad and paste the following script:<br /> <br /> <br /> [USER=98746]@echo[/USER] off<br /> REM Create lists of video and audio files<br /> dir /b *.mp4 > videos.txt<br /> dir /b *.mp3 > audios.txt<br /> <br /> REM Read video and audio file names from the lists and merge them<br /> for /f "tokens=*" %%V in (videos.txt) do (<br /> set "video=%%V"<br /> set "audio=%%~nV.mp3"<br /> if exist "%%~nV.mp3" (<br /> echo Merging %%V and %%~nV.mp3...<br /> ffmpeg -i "%%V" -i "%%~nV.mp3" -c:v copy -c:a aac "output_%%~nV.mp4"<br /> ) else (<br /> echo Audio file for %%V not found!<br /> )<br /> )<br /> <br /> REM Cleanup<br /> del videos.txt<br /> del audios.txt<br /> <br /> echo All done!<br /> pause</li> <li data-xf-list-type="ol">Save the file as merge.bat in the same folder as your video and audio files.</li> </ol><hr /><h3><strong>Step 3: Run the Script</strong></h3> <ol> <li data-xf-list-type="ol">Double-click the merge.bat file.</li> <li data-xf-list-type="ol">The script will:<ul> <li data-xf-list-type="ul">List all .mp4 files into videos.txt.</li> <li data-xf-list-type="ul">List all .mp3 files into audios.txt.</li> <li data-xf-list-type="ul">Match each video file with its corresponding audio file (based on the same name without extensions).</li> <li data-xf-list-type="ul">Merge them into new files named output_<video_name>.mp4.</li> </ul></li> </ol><hr /><h3><strong>How It Works</strong></h3> <ul> <li data-xf-list-type="ul">The dir /b command lists all .mp4 and .mp3 files in the directory.</li> <li data-xf-list-type="ul">The script matches video files with audio files using the same base name (%%~nV).</li> <li data-xf-list-type="ul">If a matching audio file exists, FFmpeg merges the video and audio.</li> <li data-xf-list-type="ul">If no matching audio file is found, the script logs an error message.</li> </ul><hr /><h3><strong>Example</strong></h3><h4>Folder Contents:</h4> <ul> <li data-xf-list-type="ul">video1.mp4</li> <li data-xf-list-type="ul">video2.mp4</li> <li data-xf-list-type="ul">video1.mp3</li> <li data-xf-list-type="ul">video3.mp3</li> </ul><h4>Output:</h4> <ul> <li data-xf-list-type="ul">output_video1.mp4 (merged successfully)</li> <li data-xf-list-type="ul">output_video2.mp4 (error: audio not found)</li> <li data-xf-list-type="ul">output_video3.mp4 (error: video not found)</li> </ul><p>another method</p><p></p><p>To merge audio and video files using FFmpeg in Windows, you can follow these steps:</p><p></p><hr /><h3><strong>1. Install FFmpeg</strong></h3> <ul> <li data-xf-list-type="ul">Download FFmpeg from the official website: <a href="https://ffmpeg.org/" target="_blank">https://ffmpeg.org/</a>.</li> <li data-xf-list-type="ul">Extract the downloaded files and add the bin folder to your system's <strong>PATH</strong> environment variable so you can use FFmpeg from the command line.</li> </ul><hr /><h3><strong>2. Prepare Your Files</strong></h3> <ul> <li data-xf-list-type="ul">Place your video file (e.g., video.mp4) and audio files (e.g., audio1.mp3, audio2.mp3, etc.) in the same folder for convenience.</li> </ul><hr /><h3><strong>3. Concatenate Audio Clips</strong></h3><p>If you have multiple audio files to combine, create a text file (audio_list.txt) with the following format:</p><p></p><p></p><p></p><p>file 'audio1.mp3'</p><p>file 'audio2.mp3'</p><p>file 'audio3.mp3'</p><p></p><ul> <li data-xf-list-type="ul">Open <strong>Notepad</strong>, write the list of audio files in the above format, and save it as audio_list.txt in the same folder as your files.</li> <li data-xf-list-type="ul">Run the following command in Command Prompt (cmd) to merge the audio clips:<br /> <br /> <br /> ffmpeg -f concat -safe 0 -i audio_list.txt -c copy merged_audio.mp3<br /> This will create a single audio file called merged_audio.mp3.</li> </ul><hr /><h3><strong>4. Merge Video and Audio</strong></h3><p>Now, merge the video file (video.mp4) with the combined audio file (merged_audio.mp3):</p><p></p><ul> <li data-xf-list-type="ul">Open Command Prompt and run:<br /> <br /> <br /> ffmpeg -i video.mp4 -i merged_audio.mp3 -c:v copy -c:a aac -strict experimental output.mp4<ul> <li data-xf-list-type="ul"><strong>video.mp4</strong>: Your video file.</li> <li data-xf-list-type="ul"><strong>merged_audio.mp3</strong>: The combined audio file.</li> <li data-xf-list-type="ul"><strong>output.mp4</strong>: The final output file with the merged audio and video.</li> </ul></li> </ul><hr /><h3><strong>5. Sync Audio and Video (Optional)</strong></h3> <ul> <li data-xf-list-type="ul">If the audio is shorter than the video and you need to loop it:<br /> <br /> <br /> ffmpeg -stream_loop -1 -i merged_audio.mp3 -i video.mp4 -shortest -c:v copy -c:a aac output.mp4</li> <li data-xf-list-type="ul">If the audio is longer than the video and you want to trim it:<br /> cmd<br /> Copy code<br /> ffmpeg -i merged_audio.mp3 -i video.mp4 -filter_complex "[0:a]apad" -shortest -c:v copy output.mp4</li> </ul><hr /><h3><strong>6. Automate for Multiple Files</strong></h3><p>If you have many video and audio files, use a batch script:</p><p></p><ol> <li data-xf-list-type="ol">Create a new text file in Notepad and paste the following:<br /> <br /> <br /> [USER=98746]@echo[/USER] off<br /> for %%v in (*.mp4) do (<br /> set "video=%%v"<br /> set "audio=%%~nv.mp3"<br /> ffmpeg -i "%%v" -i "%%~nv.mp3" -c:v copy -c:a aac "output_%%~nv.mp4"<br /> )<br /> pause</li> <li data-xf-list-type="ol">Save it as merge.bat in the folder with your video and audio files.</li> <li data-xf-list-type="ol">Double-click the batch file to run it. It will process all .mp4 videos with corresponding .mp3 audio files.</li> </ol></blockquote><p></p>
[QUOTE="Honey Bunch, post: 30453628, member: 569484"] Here's how you can automate the process of extracting video and audio file names into text files and then merging them using a batch script in [B]Windows[/B]: [HR][/HR] [HEADING=2][B]Step 1: Script Overview[/B][/HEADING] This script will: [LIST=1] [*]Generate a list of video file names (videos.txt). [*]Generate a list of audio file names (audios.txt). [*]Match video files with corresponding audio files by name. [*]Merge the audio and video files using FFmpeg. [/LIST] [HR][/HR] [HEADING=2][B]Step 2: Create the Script[/B][/HEADING] [LIST=1] [*]Open Notepad and paste the following script: [USER=98746]@echo[/USER] off REM Create lists of video and audio files dir /b *.mp4 > videos.txt dir /b *.mp3 > audios.txt REM Read video and audio file names from the lists and merge them for /f "tokens=*" %%V in (videos.txt) do ( set "video=%%V" set "audio=%%~nV.mp3" if exist "%%~nV.mp3" ( echo Merging %%V and %%~nV.mp3... ffmpeg -i "%%V" -i "%%~nV.mp3" -c:v copy -c:a aac "output_%%~nV.mp4" ) else ( echo Audio file for %%V not found! ) ) REM Cleanup del videos.txt del audios.txt echo All done! pause [*]Save the file as merge.bat in the same folder as your video and audio files. [/LIST] [HR][/HR] [HEADING=2][B]Step 3: Run the Script[/B][/HEADING] [LIST=1] [*]Double-click the merge.bat file. [*]The script will: [LIST] [*]List all .mp4 files into videos.txt. [*]List all .mp3 files into audios.txt. [*]Match each video file with its corresponding audio file (based on the same name without extensions). [*]Merge them into new files named output_<video_name>.mp4. [/LIST] [/LIST] [HR][/HR] [HEADING=2][B]How It Works[/B][/HEADING] [LIST] [*]The dir /b command lists all .mp4 and .mp3 files in the directory. [*]The script matches video files with audio files using the same base name (%%~nV). [*]If a matching audio file exists, FFmpeg merges the video and audio. [*]If no matching audio file is found, the script logs an error message. [/LIST] [HR][/HR] [HEADING=2][B]Example[/B][/HEADING] [HEADING=3]Folder Contents:[/HEADING] [LIST] [*]video1.mp4 [*]video2.mp4 [*]video1.mp3 [*]video3.mp3 [/LIST] [HEADING=3]Output:[/HEADING] [LIST] [*]output_video1.mp4 (merged successfully) [*]output_video2.mp4 (error: audio not found) [*]output_video3.mp4 (error: video not found) [/LIST] another method To merge audio and video files using FFmpeg in Windows, you can follow these steps: [HR][/HR] [HEADING=2][B]1. Install FFmpeg[/B][/HEADING] [LIST] [*]Download FFmpeg from the official website: [URL]https://ffmpeg.org/[/URL]. [*]Extract the downloaded files and add the bin folder to your system's [B]PATH[/B] environment variable so you can use FFmpeg from the command line. [/LIST] [HR][/HR] [HEADING=2][B]2. Prepare Your Files[/B][/HEADING] [LIST] [*]Place your video file (e.g., video.mp4) and audio files (e.g., audio1.mp3, audio2.mp3, etc.) in the same folder for convenience. [/LIST] [HR][/HR] [HEADING=2][B]3. Concatenate Audio Clips[/B][/HEADING] If you have multiple audio files to combine, create a text file (audio_list.txt) with the following format: file 'audio1.mp3' file 'audio2.mp3' file 'audio3.mp3' [LIST] [*]Open [B]Notepad[/B], write the list of audio files in the above format, and save it as audio_list.txt in the same folder as your files. [*]Run the following command in Command Prompt (cmd) to merge the audio clips: ffmpeg -f concat -safe 0 -i audio_list.txt -c copy merged_audio.mp3 This will create a single audio file called merged_audio.mp3. [/LIST] [HR][/HR] [HEADING=2][B]4. Merge Video and Audio[/B][/HEADING] Now, merge the video file (video.mp4) with the combined audio file (merged_audio.mp3): [LIST] [*]Open Command Prompt and run: ffmpeg -i video.mp4 -i merged_audio.mp3 -c:v copy -c:a aac -strict experimental output.mp4 [LIST] [*][B]video.mp4[/B]: Your video file. [*][B]merged_audio.mp3[/B]: The combined audio file. [*][B]output.mp4[/B]: The final output file with the merged audio and video. [/LIST] [/LIST] [HR][/HR] [HEADING=2][B]5. Sync Audio and Video (Optional)[/B][/HEADING] [LIST] [*]If the audio is shorter than the video and you need to loop it: ffmpeg -stream_loop -1 -i merged_audio.mp3 -i video.mp4 -shortest -c:v copy -c:a aac output.mp4 [*]If the audio is longer than the video and you want to trim it: cmd Copy code ffmpeg -i merged_audio.mp3 -i video.mp4 -filter_complex "[0:a]apad" -shortest -c:v copy output.mp4 [/LIST] [HR][/HR] [HEADING=2][B]6. Automate for Multiple Files[/B][/HEADING] If you have many video and audio files, use a batch script: [LIST=1] [*]Create a new text file in Notepad and paste the following: [USER=98746]@echo[/USER] off for %%v in (*.mp4) do ( set "video=%%v" set "audio=%%~nv.mp3" ffmpeg -i "%%v" -i "%%~nv.mp3" -c:v copy -c:a aac "output_%%~nv.mp4" ) pause [*]Save it as merge.bat in the folder with your video and audio files. [*]Double-click the batch file to run it. It will process all .mp4 videos with corresponding .mp3 audio files. [/LIST] [/QUOTE]
Insert quotes…
Verification
Hata thunen beduwama keeyada? (60 bedeema thuna)
Post reply
Top
Bottom