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

jonwren

It has the same effect of error

TinyPy: Exception
Exception : (tp_load) cant get filesize
BackTrack: File:py2bc.py,line50

eumagga0x2a

Thanks, it doesn't suppress dialogs opened for errors then. Will try to find out what is going on later tonight.

jonwren

Once it has done a scan this pops up

TinyPy: Exception
Exception : (tp_load) cant get filesize
BackTrack: File:py2bc.py,line50

I have to select OK and then the file will continue fully and finish, with no other errors

jonwren

Quote from: eumagga0x2a on March 25, 2018, 04:44:03 PM
Thanks, it doesn't suppress dialogs opened for errors then. Will try to find out what is going on later tonight.

SOLVED

I messed around and done this, and it works great, NO errors and copies Video and Audio from Mkv to MP4

set avidemux="C:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
set videocodec=Copy set audiocodec=Copy
for %%f in (*.mkv) do %avidemux% --video-codec %videocodec% --audio-codec %audiocodec% --force-alt-h264 --load "%%f" --save "%%~nf.mp4" --quit


Once again Thanks for getting me advice Cheers

eumagga0x2a

Quote from: jonwren on March 25, 2018, 06:26:10 PM
I messed around and done this, and it works great, NO errors and copies Video and Audio from Mkv to MP4

set avidemux="C:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
set videocodec=Copy set audiocodec=Copy
for %%f in (*.mkv) do %avidemux% --video-codec %videocodec% --audio-codec %audiocodec% --force-alt-h264 --load "%%f" --save "%%~nf.mp4" --quit

Just a small nit: --load should always come first, because depending on Avidemux settings, this will reset video codec to a user defined default value. Additionally, the option --force-alt-h264 has been removed from Avidemux since ages.

The reason for the error was most likely missing full path to the .py file so that it was simply never loaded (it works with relative path on Linux, but maybe this doesn't apply either to Windows or to your setup, so that the .py file wasn't located in the folder where the command was run).

Finally, in your command line above you don't set output format, the resulting .mp4 should be really a MKV with .mp4 file name extension.

eumagga0x2a

Just for reference: A more or less correct batch would have been

set avidemux="C:\Program Files\Avidemux 2.7 - 64 bits\avidemux.exe"
set videocodec=Copy
set audiocodec=Copy
set outfmt=MP4
for %%f in (*.mkv) do %avidemux% --load "%%f" -video-codec %videocodec% --audio-codec %audiocodec% --output-format %outfmt% --save "%%~nf.mp4" --quit


I have added gatekeeper code to deal with situations when script file provided via command line can't be found at the given location. In the future, users won't face a tinyPy exception message if they pass a wrong path to the --run option.


jonwren

I was just wondering if there is a Batch to detect AC3 within Video, as I would like to convert AC3 over to HE-AAC.
I have MediaInfo, but having to manually check every video is a pain.
Also is it ok to change the container AVI to MP4

Thanks

dosdan

Quote from: jonwren on March 27, 2018, 06:50:36 AM
I was just wondering if there is a Batch to detect AC3 within Video, as I would like to convert AC3 over to HE-AAC.

ffprobe is part of the FFMPEG package.  The following batchfile should work from cmd line or drag-and-drop (not tested) for win7 or later.

Find_AC3.bat
@echo off
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


Result using a cmd line of:
Find_AC3.bat "D:\20161130 - OIC Christmas Carols\Video\00000.MTS" "D:\20161130 - OIC Christmas Carols\Video\00001.MTS" *.mp4


"D:\20161130 - OIC Christmas Carols\Video\00000.MTS" contains AC3

"D:\20161130 - OIC Christmas Carols\Video\00001.MTS" contains AC3

"D:\00000.mp4" contains AC3


















Press any key to continue . . .


The .MTS files are AVCHD media files from my camcorder. Most of the MP4s in D:\ do not contain AC-3 so they produce blank lines.

The portion after "&&" will only execute if the find was successful. With a little more mucking around it would be possible to only run FFMPEG to perform the HE-AAC audio stream conversion if the find was successful.

The ">nul" hides double FIND screen displays of "ac3" to reduce clutter.

"%%~dpnxF" is used instead of %%F as it is not affected by the presence or absence of "" around *.mp4

Dan.

eumagga0x2a

Just a few words to conversion AVI --> MP4: If the video is H.264 or HEVC and contains B-frames, direct conversion will result in a file not smoothly playable in some players like VLC. The reason for that is AVI not storing presentation timestamps while the presence of B-frames means that frames are stored not in the order they are displayed. Avidemux offers a feature to reconstruct missing information by decoding the entire video, but I am not sure it is scriptable.


jonwren

Quote from: dosdan on March 27, 2018, 08:18:33 AM
Quote from: jonwren on March 27, 2018, 06:50:36 AM
I was just wondering if there is a Batch to detect AC3 within Video, as I would like to convert AC3 over to HE-AAC.

ffprobe is part of the FFMPEG package.  The following batchfile should work from cmd line or drag-and-drop (not tested) for win7 or later.

Find_AC3.bat
@echo off

Great cheers Dan

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


Result using a cmd line of:
Find_AC3.bat "D:\20161130 - OIC Christmas Carols\Video\00000.MTS" "D:\20161130 - OIC Christmas Carols\Video\00001.MTS" *.mp4


"D:\20161130 - OIC Christmas Carols\Video\00000.MTS" contains AC3

"D:\20161130 - OIC Christmas Carols\Video\00001.MTS" contains AC3

"D:\00000.mp4" contains AC3


















Press any key to continue . . .


The .MTS files are AVCHD media files from my camcorder. Most of the MP4s in D:\ do not contain AC-3 so they produce blank lines.

The part after "&&" will only execute if the find was successful. With a little more mucking around it would be possible to only run FFMPEG to perform the HE-AAC conversion if the find was successful.

The ">nul" hides FIND screen displays of "ac3" to reduce clutter.

"%%~dpnxF" is used instead of %%F as it is not affected by the presence or absence of "" around *.mp4

Dan.

jonwren

Hi Dan
I've just tried it and all I get is...
Press any key to continue

I copied and pasted
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

and made a bat file and placed it inside a folder with AC3 video files, I have double clicked on the bat and have also drag the files into the bat and I still get Press any key to continue

cheers

dosdan

Quote from: jonwren on March 27, 2018, 09:09:55 AM
Hi Dan
I've just tried it and all I get is...
Press any key to continue

Is the directory FFPROBE.EXE is situated in included in your path list? You can test by going to the cmd prompt and just typing FFPROBE. I see:

C:\Windows\System32>ffprobe
ffprobe version N-90419-g3e3d567761 Copyright (c) 2007-2018 the FFmpeg developers
  built with gcc 7.3.0 (Rev1, Built by MSYS2 project)
  configuration:  --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-fontconfig --enable-libass --enable-libbluray --enable-libfreetype --enable-libmfx --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libwavpack --enable-libwebp --enable-libxml2 --enable-libzimg --enable-libshine --enable-gpl --enable-openssl --enable-avisynth --extra-cflags=-DLIBTWOLAME_STATIC --enable-libfdk-aac --extra-libs=-lstdc++ --extra-cflags=-DLIBXML_STATIC --enable-version3 --enable-nonfree --disable-debug
  libavutil      56. 11.100 / 56. 11.100
  libavcodec     58. 15.100 / 58. 15.100
  libavformat    58. 10.100 / 58. 10.100
  libavdevice    58.  2.100 / 58.  2.100
  libavfilter     7. 13.100 /  7. 13.100
  libswscale      5.  0.102 /  5.  0.102
  libswresample   3.  0.101 /  3.  0.101
  libpostproc    55.  0.100 / 55.  0.100
Simple multimedia streams analyzer
usage: ffprobe [OPTIONS] [INPUT_FILE]

You have to specify one input file.
Use -h to get full help or, even better, run 'man ffprobe'.


Dan.

jonwren

This is what I get

Microsoft Windows [Version 10.0.17120.1]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\jonwr>FFPROBE
ffprobe version 3.4.2 Copyright (c) 2007-2018 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libmfx --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Simple multimedia streams analyzer
usage: ffprobe [OPTIONS] [INPUT_FILE]

You have to specify one input file.
Use -h to get full help or, even better, run 'man ffprobe'.