News:

--

Main Menu

Streamline audio encoding?

Started by stuffy1, February 17, 2020, 12:49:02 AM

Previous topic - Next topic

stuffy1

#15
Quote from: dosdan on February 23, 2020, 03:53:12 AM
BTW, I wouldn't be surprised if both Handbrake and VidCoder had a similar issue with this clip.  Have you tried either of them?

Dan.

I haven't tried those others because I assumed they were similar to Avidemux and I'm looking for a faster option.

I finally had a chance to mess with the channels. I got the sample file working properly using this mapping:

channelmap=0|1|2|3|4|5:5.1

Not sure if it's a coincidence that they're in numerical order. Hopefully this will work with my other videos as well. So far so good.

I also added a command to keep the subtitles in place, which is a big improvement over using Avidemux for conversions since Avidemux can't do that (AFAIK). My only issue now is that the FFMPEG method doesn't work with filenames with spaces, but that's pretty minor.

Thanks again for your help.

dosdan

#16
Quote from: stuffy1 on March 06, 2020, 10:45:17 AM
My only issue now is that the FFMPEG method doesn't work with filenames with spaces, but that's pretty minor.

I fixed that in a later version of the batchfile. In this 3rd version of the batchfile I successfully tested with directories with spaces, files with spaces and with apostrophes. The test set to be drag-and-dropped:


Directory of C:\test directory\Directory A

09/07/2017  08:43 PM        64,296,960 test 1.MTS
09/07/2017  08:43 PM        64,296,960 test2.MTS
01/04/2019  06:50 AM               325 test3.mts
09/07/2017  08:43 PM        64,296,960 test4.MTS
01/04/2019  06:50 AM               325 test5.mts
09/07/2017  08:43 PM        64,296,960 Wilber's clip.mts


The 325-byte files are renamed text files, to ensure that batch conversion would continue after they where found in the video file mix and that they would be included in conversion_error.txt

The reason that the location of the test for the existence of and the creation of, if necessary, the "converted" sub-directory, inside the Files Loop, rather than before it, as I'd normally do, was to look at handling the drag-and-dropping of multiple folders. In which case, I was wanting each converted sub-directory to be situated below its parent directory.



You should be able to work out the changes needed in your batchfile by looking at how I did the filename parsing here:

Convert_MTS_to_MP4_3.bat
@echo off
setlocal EnableDelayedExpansion
cls

if exist conversion_error.txt del /q conversion_error.txt

:FILES_LOOP
for %%F  in (%*) do (
    echo Converting    "%%~F"    to    "%%~dpFconverted\%%~nF.mp4"
if not exist "%%~dpFconverted\" md "%%~dpFconverted\"
ffmpeg.exe -i "%%~fF" -c:v copy -c:a aac -y -hide_banner -loglevel error -map_metadata 0 "%%~dpFconverted\%%~nF.mp4"
if errorlevel 1 echo error occurred: "%%~F"  >> conversion_error.txt

rem Next line sets the MP4's file date/time to the same as the original MP4 file.
if exist "%%~dpFconverted\%%~nF.mp4" touch -r "%%~fF" "%%~dpFconverted\%%~nF.mp4"

rem Next line shows the MP4 after it has been created, so with multiple MP4s it acts as a sort of progress indicator.
if exist "%%~dpFconverted\%%~nF.mp4" dir "%%~dpFconverted\%%~nF.mp4" | find "/"

rem Remove REM from the start of the next line if you wish to delete the original file if no error occurred in the conversion.
rem del "%%~fF"

echo.
shift
)
if not "%1"=="" goto FILES_LOOP
goto FINISHED

:FINISHED
@echo off
if exist conversion_error.txt start /i conversion_error.txt
echo.
echo.
pause

stuffy1

#17
Hmm the only difference this seemed to make was creating a text file telling me there was an error. I noticed you removed the two "set filename" lines but other than that I don't really see a difference in the file name handling. Of course, I have very little idea what I'm looking at. Here's my current code:

@echo off
setlocal EnableDelayedExpansion
cls

if exist conversion_error.txt del /q conversion_error.txt

:FILES_LOOP
for %%F in (%*) do (
echo Converting    "%%F"    to    "%%~dpF!videos\%%~nF.mkv"
if not exist "%%~dpF!videos\" md "%%~dpF!videos\"
ffmpeg.exe -i "%%F" -c:v copy -c:a aac -b:a 384k -af "channelmap=0|1|2|3|4|5:5.1" -map 0:v -map 0:a -map 0:s -y -hide_banner -loglevel error -map_metadata 0 "%%~dpF!videos\%%~nF.mkv"
if errorlevel 1 echo error occurred: "%%~F"  >> conversion_error.txt

        rem Next line sets the MP4's file date/time to the same as the original MP4 file.
rem touch -r "%%~fF" "%%~dpF!videos\%%~nF.mp4"

        rem Next line shows the MP4 after it has been created, so with multiple MP4s it acts as a sort of progress indicator.
rem dir "%%~dpF!videos\%%~nF.mp4" | find "/"

rem Remove REM from the start of the next line if you wish to delete the original file if no error occurred in the conversion.
rem del "%%F"

        echo.
shift
)
if not "%1"=="" goto FILES_LOOP
goto FINISHED

:FINISHED
@echo off
if exist conversion_error.txt start /i conversion_error.txt
echo.
echo.
exit /b


Changing the directory output to just "ideos" instead of "!videos" made no difference.

BTW the only way for me to post things like this on this forum without being marked as spam is to make a simple post and then edit it.

dosdan

#18
Quote from: stuffy1 on March 07, 2020, 02:37:34 AM
I don't really see a difference in the file name handling.

In your FFMPEG  line, after -i, use "%%-fF", instead of "%%F".  To test this, duplicate the FFMPEG line in the batchfile, but using the two different parameters, and add an ECHO and a space before each FFMPEG.EXE so the command line will be displayed rather than executed. And add a ECHO. between these two FFMPEG lines to leave a empty line:

echo fmpeg.exe -i "%%F" -c:v copy -c:a aac -b:a 384k -af "channelmap=0|1|2|3|4|5:5.1" -map 0:v -map 0:a -map 0:s -y -hide_banner -loglevel error -map_metadata 0 "%%~dpF!videos\%%~nF.mkv"
echo.
echo fmpeg.exe -i "%%~fF" -c:v copy -c:a aac -b:a 384k -af "channelmap=0|1|2|3|4|5:5.1" -map 0:v -map 0:a -map 0:s -y -hide_banner -loglevel error -map_metadata 0 "%%~dpF!videos\%%~nF.mkv"


Now I drag a file with spaces in its filename onto the batchfile icon. (I also temporarily changed the final EXIT /B to PAUSE so the window would remain open so you can see the result.)

fmpeg.exe -i ""C:\test directory\Directory A\Wilber's clip.mts"" -c:v copy -c:a aac -b:a 384k -af "channelmap=0|1|2|3|4|5:5.1" -map 0:v -map 0:a -map 0:s -y -hide_banner -loglevel error -map_metadata 0 "C:\test directory\Directory A\videos\Wilber's clip.mkv"

fmpeg.exe -i "C:\test directory\Directory A\Wilber's clip.mts" -c:v copy -c:a aac -b:a 384k -af "channelmap=0|1|2|3|4|5:5.1" -map 0:v -map 0:a -map 0:s -y -hide_banner -loglevel error -map_metadata 0 "C:\test directory\Directory A\videos\Wilber's clip.mkv"


Notice the doubling of inverted commas in the first version ("%%F"), but not in the second version ("%%-fF")

Dan.

stuffy1

Ah yeah I see it now. It works! Thanks again for all your help.