VLC command line converting is not always working - batch-file

I scheduled a .cmd file that would convert a network stream into a .mp4 file, using:
vlc -vvv "http://86.127.212.113/control/faststream.jpg?stream=mxpeg" --sout=#transcode{vcodec=h264,scale=Automat,scodec=none}:file{dst=C:\\Users\\ACV\\Videos\\rec3.mp4,no-overwrite} :no-sout-all :sout-keep
It often works, but sometimes it just creates big files that I am not able to play.
Even VLC itself cannot play these files, outputting just this

I would suggest that you use the following syntax:
Replace the = after --sout with a space character
Doublequote the --sout chain
Replace the prefix : characters for the global options for no-sout-all and sout-keep with --
#"%ProgramFiles%\VideoLAN\VLC\vlc.exe" -vvv "http://86.127.212.113/control/faststream.jpg?stream=mxpeg" --sout "#transcode{vcodec=h264,scale=Automat,scodec=none}:file{dst=C:\\Users\\ACV\\Videos\\rec3.mp4,no-overwrite}" --no-sout-all --sout-keep
I have included the full path to vlc.exe for safety, please adjust it as you need.

Related

Using ghostscript in a Windows .bat file to convert multiple pdf files to png

I have many many pdf files in a directory that I need to convert from pdf to png. Currently, I am using the ImageMagick command:
magick mogrify -format png *.pdf
Because, there are so many files, I would like to use ghostscript directly because there are several sources that suggest that I could achieve a 75% reduction in processing time by doing this.
However, I am having trouble finding a clean dos command example to accomplish the same thing as the ImageMagick command above. I believe I need to execute the gswin64c.exe module but I am unsure how to do this to accomplish what I need to get done. Can someone provide me with a clean example of the ghostscript that accomplishes what I'm doing in ImageMagick?
After much digging, what I discovered was that ghostscript does not really have a wildcard that would allow reference to all files of a certain pattern (like ImageMagick does). To convert all files in a directory that are pdf's to png's, a dos script like the following could be used:
for %%x in (*) do gswin64c.exe -sDEVICE=png16m -dBATCH -dNOPAUSE -dQUIET -
SOutputFile="%%~nx.png" %%~nx.pdf
This can also be run from the command line by simply using single percentage signs (%) instead of the double percentage signs in the script above.
The terms are as follows:
gswin64c.exe: This is the dos command version of GhostScript. It should be used as opposed to gswin64.exe which will open a GhostScript window.
-sDEVICE=png16m This indicates the form of the output file. Is this case png.
-dBATCH -dNOPAUSE. These are GhostScript options and when employed will allow for continuous operation of the script (without them, the program will pause after each file converted).
-dQUIET - This suppresses notifications that display on stdout after each processed file.
SOutputFile="%%~nx.png" %%~nx.pdf This indicates the pattern for the input files and the output files. x is the loop variable. The % sign is used as a wild card. ~nx is a Dos convention which truncates the extension of an echoed file name.

FOR /f in DOS alternative

As it appears there is no version of DOS (6.22 to WinME "DOS") or FreeDOS that allows you to take part of a text file and make it a variable, I'm going to just keep collecting the data I get in DOS mode into one very large file but I can't think of a way to get each asset and UUID and add them together in a third file... Here is what I get at the moment:
SMBIOS.TXT
~~~~~~~(usually 27 lines of stuff I don't need)~~~~~~~
Asset Number: ABC12345
~~~~~~~(usually 37 lines of stuff I don't need)~~~~~~~
UUID: ABCDEF12345678901234567890
~~~~~~~(usually 4 lines of stuff I don't need, complicated by a # symbol in there too)~~~~~~~
^Repeated many times
I need to add both the Asset Number and the UUID together in a CSV format so I was previously hoping (before I exhausted all attempts at doing for /F in DOS) just echoing the two variables I was creating as follows:
ECHO !Asset!,!UUID!>>Results.CSV
Which again works in Windows command prompt just not DOS, the script I'm using however only gets the first variable of each so I need to do them in order and keep repeating through the file in the manner?
Alternatively is there any other way I could use DOS to get the info I need out of the two text files on the fly? It's all running from a USB stick so I don't have any size constraints at least.
Aaron
You may be able to get it done with the DOS command line text stream editor EDLIN.
I am assuming this has to be done in DOS and Windows is not an option.
PDGREPPE is an MS DOS command line GREP search and replace utility.
Maybe you can find a DOS Text Editor with Macros
Lotus 123?
DBase?
Write an app in DOS BASIC.

How to remove specific characters from a file name?

I have bunch of files that need to have a (.) dot removed from the file-name. Eg. "Mr.-John-Smith.jpg" to "Mr-John-Smith.jpg". I don't have real experience with programming and know only html/css and a little javascript. I found another identical question here on stackoverflow, but what I gathered it was fixed on linux system and BASH was used.
Anyways, if anyone could provide me a tutorial on which program to use for this and what code to execute in that program to make it happen I'd be grateful.
if you are using a windows environment (which i guess you do)
you can download this free utility to mass change file names !
main page :
http://www.bulkrenameutility.co.uk/Main_Intro.php
download page :
http://www.bulkrenameutility.co.uk/Download.php
its easy to use
enjoy
If your file names in a file...
1- Open Microsoft Word or any text editor. Press ctrl+h and then search "." without quotes then replace it with blank character.
2- It will remove all dots, again bring "." to your file extention such as .jpg , .png searh your file extention for example "jpg" and replace it with ".jpg"
It will works %100, i am using this method everytime.
if they are not in a file and if you want do somethings in your operation systems' file system
Try this program. It is very useful for this operation;
Download
To remove all except the extension dot from all files in a directory, you can use PowerShell that comes with newer versions of Windows, and can be downloaded for older versions;
Line breaks inserted for readability, this should go on one line;
PS> dir | rename-item -newname {
[System.IO.Path]::GetFileNameWithoutExtension($_.name).Replace(".","") +
[System.IO.Path]::GetExtension($_.name); }
What it does is to take the file name without an extension and remove all dots in it, and then add back the extension. It then renames the file to the resulting name.
This will change for example do.it.now to doit.now, or in your case, Mr.-John-Smith.jpg to Mr-John-Smith.jpg.

File encoding format through command prompt : Windows

I have a file which may be in ASCII or UTF-8 format. I can know which format it is through Notepad++. But can some one tel me a tool that could show me in which format the file is through command prompt.
Example:
Open Command Prompt,
C:><Some Command> FileName
which should give me the file format like ASCII or UTF-8.
Install Python 3.x
Run command in cmd.exe (Administrator): pip install chardet
Write a small python script that read a file, detect the encoding, and print the encoding using the newly installed module chardet. See here for help.
Put the script somewhere under PATH
Suppose you create ec.py doing the job. Then you can invoke ec FileName on command line to get the encoding. If you do a good job writing the python script, you can invoke something like ec *.txt to get the encodings of multiple files.
This is a duplicate of this question here which has a great answer (not by me I might add)
EDIT
I am pretty sure there is not way that is reliable to do this, usually you are told the encoding of a file, sure you can look for a Byte Order Mark (BOM) at the start of the file but its not mandatory and so is not a true indicator unless you know for SURE its supposed to be there.
Unless someone knows differently I don't think its possible to work out from scratch you have to have some clue about the encoding used.

Adding subtitle from command line MP4Box

I am adding a subtitle file to a video using MP4Box. The following command works perfectly from the command line:
c:/GPAC/MP4Box -add c:/test.m4v#audio -add c:/test.m4v#video -add c:/test_en.srt:hdlr=sbtl:lang=en:group=2:layer=-1 -new c:/test2.m4v
However, what I really want to do is to put the command into a .bat file. The following is my command in the batch file:
%1/GPAC/MP4Box -add %2/%3#audio -add %2/%3#video %4 -new %2/%3
As you can see I am trying to pass in "-add c:/test.m4v#video -add c:/test_en.srt:hdlr=sbtl:lang=en:group=2:layer=-1" as the fourth parameter. The reason I want to do this is there may be many subtitles files being added:
"-add c:/test.m4v#video -add c:/test_en.srt:hdlr=sbtl:lang=en:group=2:layer=-1 -add c:/test.m4v#video -add c:/test_ja.srt:hdlr=sbtl:lang=ja:group=2:layer=-1:disabled"
so I don't know ahead of time how many -add commands there need to be so I want to just pass them all in as one parameter. But, mp4box doesn't like this.
I'm not sure if this is a limitation with mp4box or with batch file parameters in general.
I know this is an old thread, but for anyone searching in future.
I used the following approach in a batch file, combined with filemenu tools to allow for a simple right-click menu function to initiate the batch process:
for %%a in (*.m4v) do mp4box -add "%%~Na.eng.srt":lang=eng:layout=0x60x0x-1:group=2:hdlr="sbtl:tx3g" "%%a"
I ended up solving this by writing/rewriting the batch file from code every time I needed to run it. So I would create the batch file with all my arguments. Run it. Then delete the file. This worked great.
Batch files on Windows are quirky and have limited functionality. What you could do is use Cygwin, which allows you to use a real shell (like Bash for example) on Windows.
A note regarding MP4Box syntax,since both the question and the answers here have it... "suboptimally", let's just say.
If you want MP4Box to rewrite an input file — which is its default mode, unless told otherwise — while adding subtitles (or any other tracks/metadata), you should specify the file to be modified first on the command line, and without using -add. So, to rewrite a video file my_video.mp4 with subtitled added from my_video_English.srt and my_video_German.srt, you'd use:
MP4Box my_video.mp4 \
-add my_video_English.srt \
-add my_video_German.srt
No need to specify tracks, since you want to use all available tracks from all input files. (Here also, that's the default disposition for track data.)
MP4Box will create a new temporary output file, copy the contents of my_video.mp4 into it, remuxing the original tracks with new tracks created for each subtitle file, and then rename the temporary file back to my_video.mp4, overwriting the original. (If you don't want to overwrite, add -out newname.mp4 to the end of the command line.)
The program help (specifically, MP4Box -h import) especially warns against adding subtitle tracks to the output stream before any video tracks are created, so -add foo.srt should never be before the a/v input file on the command line:
$ MP4Box -h import
[...]
Note: When importing SRT or SUB files, MP4Box will choose
default layout options to make the subtitle appear at the
bottom of the video. You SHOULD NOT import such files before
any video track is added to the destination file, otherwise
the results will likely not be useful (default SRT/SUB
importing uses default serif font, fontSize 18 and display
size 400x60). For more details, check TTXT doc.
It's possible this wouldn't affect file rewriting (because, the video track is already in the output stream before it even begins), but it definirely would affect use of -out. In general, placing the input a/v content first in the arguments is just a good habit to get into when using MP4Box.

Resources