Newbie : How to Copy Video & Audio folder from MKV to MP4 Script

Started by jonwren, March 24, 2018, 02:09:01 PM

Previous topic - Next topic

dosdan

Perhaps your version of FFPROBE is returning a different string e.g. AC3 or AC-3 instead of ac3. To troubleshoot, try a simpler command on the cmd line, not a batchfile, with a media file that you already know contains an AC-3 audio stream  e.g. try just:

ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "d:\20161130 - OIC Christmas Carols\Video\00000.MTS"

I see:
codec_name=h264
codec_name=ac3
codec_name=hdmv_pgs_subtitle
codec_name=h264
codec_name=ac3
codec_name=hdmv_pgs_subtitle


Dan.

jonwren

I get this

C:\Users\jonwr>ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1"C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4"
[default @ 000002d4adc36f20]
Failed to parse option string 'noprint_wrappers=1C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4' provided to writer context

dosdan

Quote from: jonwren on March 27, 2018, 10:32:08 AM
I get this

C:\Users\jonwr>ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1"C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4"
[default @ 000002d4adc36f20]
Failed to parse option string 'noprint_wrappers=1C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4' provided to writer context

Add a space before the media filename i.e.
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4"


jonwren

I now get this  :)

C:\Users\jonwr>ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4"
codec_name=h264
codec_name=ac3

dosdan

Quote from: jonwren on March 27, 2018, 10:44:10 AM
I now get this  :)

C:\Users\jonwr>ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4"
codec_name=h264
codec_name=ac3

OK, now try this (command on one line):

ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4" | find "ac3"


If that works increase it to (command on one line):

ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4" | find "ac3"  >nul && echo  "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4" contains AC3

Dan.

jonwren

ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4" | find "ac3"

I get...codec_name=ac3

ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4" | find "ac3"  >nul && echo  "C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4" contains AC3

I get..."C:\Users\jonwr\Desktop\Dark Net - 2x01 - My Mind.mp4" contains AC3

dosdan

So the basic command is working fine. The problem must be in the FOR IN () DO loop.

Try this batch file:

Find_AC3.bat
@echo on
cls
for %%F in (%*) do (
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF"  | find "ac3">nul && echo "%%~dpnxF" contains AC3
shift
)
pause


use it from the cmd line with a file containing AC-3. Since ECHO is ON you will see the lines in the batch file, and then you will see them again, this time with the FOR IN () DO loop interpreted and "%%~dpnxF" expanded:

D:\>Find_AC3.bat "D:\MKV test\test 100.mkv"

I see:
D:\>for %F in ("D:\MKV test\test 100.mkv") do (
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%~dpnxF"    | find "ac3"  1>nul  && echo "%~dpnxF" contains AC3
shift
)

D:\>(
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "D:\MKV test\test 100.mkv"    | find "ac3"  1>nul  && echo "D:\MKV test\test 100.mkv" contains AC3
shift
)

D:\>pause
Press any key to continue . . .





jonwren

@echo on
cls
for %%F in (%*) do (
   ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF"  | find "ac3">nul && echo "%%~dpnxF" contains AC3
   shift
)
pause

I get....
C:\Users\jonwr>for %%F in (%*) do (
%%F was unexpected at this time.

C:\Users\jonwr>ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF"  | find "ac3">nul && echo "%%~dpnxF" contains AC3
%%~dpnxF: No such file or directory

C:\Users\jonwr>shift

dosdan

Quote from: jonwren on March 27, 2018, 11:18:53 AM
I get....
C:\Users\jonwr>for %%F in (%*) do (
%%F was unexpected at this time.

That's unusual. In a batch file, (but not at the cmd line), you need to use the double percentage symbols: %%F

But when the batchfile is run, the first percentage symbol is stripped off, leaving just %F

Notice how mine is doing this and yours is not.


jonwren


dosdan

The same applies to %*

Mine is immediately changed to the command line parameters following the batchfile name, here just a single media file. Again this behaviour is expected inside a batch file as compared to issuing the command at the cmd prompt.

Dan.

jonwren

This is what am getting in a Batch now...

C:\Users\jonwr\Desktop>for %F in ((null)) do (
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%~dpnxF"    | find "ac3"  1>nul  && echo "%~dpnxF" contains AC3
shift
)

C:\Users\jonwr\Desktop>pause
Press any key to continue . . .

dosdan

Try this. Create this batch file in a text editor:

Batch_Paramenter_Parsing.bat
@echo off
echo %%1 is %1
echo %%2 is %2
echo %%3 is %3
echo %%4 is %4
echo %%* is %*


Run it from the cmd prompt with some parameters:
D:\>batch_parameter_parsing.bat 10 20 30 40 50 60 70 80 90

I see:
%1 is 10
%2 is 20
%3 is 30
%4 is 40
%* is 10 20 30 40 50 60 70 80 90


Dan.

jonwren

C:\Users\jonwr>C:\>batch_parameter_parsing.bat 10 20 30 40 50 60 70 80 90
'C:\' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\jonwr>

dosdan

Quote from: jonwren on March 27, 2018, 11:49:18 AM
C:\Users\jonwr>C:\>batch_parameter_parsing.bat 10 20 30 40 50 60 70 80 90
'C:\' is not recognized as an internal or external command,
operable program or batch file.

No, use:
batch_parameter_parsing.bat 10 20 30 40 50 60 70 80 90