Batch script equivalent for conversion on Mac for VLC

macOS specific usage questions
aitte
Cone that earned his stripes
Cone that earned his stripes
Posts: 310
Joined: 28 Feb 2012 00:26

Batch script equivalent for conversion on Mac for VLC

Postby aitte » 29 Feb 2012 00:40

Hey, I was hoping someone could help me on this issue. I currently use windows for a batch script conversion where I can just drag and drop a video file onto my batch file and it will run the conversion and output the file with the same name. Is it possible to do something similar to this on osx lion? I would like to be able to drag and drop the video file onto the script and allow it to run and output the newly converted video file with the same name. I currently use the latest vlc 2.0 on both systems.

My script is "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" %1 --sout=#transcode{vcodec=h264,vb=800,acodec=mp4a,ab=192,channels=2}:standard{access=file,mux=mp4,dst=%1.mp4}

I understand that the location for vlc will to /Applications/VLC.app/Contents/MacOS/VLC but how can I make the script executable by dragging and dropping the video file.

Im not as proficient on OSX as I am on windows so any help would be much appreciated.

Thank you.

nkoriyama
Cone that earned his stripes
Cone that earned his stripes
Posts: 338
Joined: 01 Sep 2011 20:50
VLC version: git
Operating System: Windows / Mac OS X
Location: Japan

Re: Batch script equivalent for conversion on Mac for VLC

Postby nkoriyama » 01 Mar 2012 01:41

AppleScript, droplet
How To Ask Questions The Smart Way http://www.catb.org/~esr/faqs/smart-questions.html
My hack for ISDB-T http://sdrv.ms/126weue

kemuel
New Cone
New Cone
Posts: 3
Joined: 01 Mar 2012 00:58

Re: Batch script equivalent for conversion on Mac for VLC

Postby kemuel » 01 Mar 2012 02:05

This AppleScript should do the trick:

Code: Select all

on open these_items try process_item(these_items) end try end open -- this sub-routine processes files on process_item(this_item) set full_path to the POSIX path of this_item do shell script "/Applications/VLC.app/Contents/MacOS/VLC" & " '" & full_path & "' --sout=#transcode{vcodec=h264,vb=800,acodec=mp4a,ab=192,channels=2}:standard{access=file,mux=mp4,dst='" & full_path & ".mp4'}" end process_item
Open the AppleScript editor in the Utilities folder. Write the script above. Click the Compile button to check the script. Then save the script as an application. Now you can drop videofiles onto the App and it should open VLC and transcode. At least it should. I haven't tried it since I'm not at home on my own computer.

aitte
Cone that earned his stripes
Cone that earned his stripes
Posts: 310
Joined: 28 Feb 2012 00:26

Re: Batch script equivalent for conversion on Mac for VLC

Postby aitte » 01 Mar 2012 03:48

Thank you for taking the time to answer kemual, I tried your script and it does open vlc and add the file but it does not commence the encoding process. Ill try looking into it some more and see why it doesnt begin the process. Any more help would be greatly appreciated however.

kemuel
New Cone
New Cone
Posts: 3
Joined: 01 Mar 2012 00:58

Re: Batch script equivalent for conversion on Mac for VLC

Postby kemuel » 01 Mar 2012 12:44

I tried it at home and found an error in my code..
So here comes something that works:

Code: Select all

on open these_items try process_item(these_items) end try end open -- this sub-routine processes files on process_item(this_item) set full_path to the POSIX path of this_item do shell script "/Applications/VLC.app/Contents/MacOS/VLC" & " '" & full_path & "' --sout='#transcode{vcodec=h264,vb=800,acodec=mp4a,ab=192}:standard{access=file,mux=mp4,dst=" & full_path & ".mp4}'" end process_item
The change is very subtle so you may not be able to tell the difference between this and the first one.
Actually I just moved the single quotation-marks. I tested this and it works perfectly :)

aitte
Cone that earned his stripes
Cone that earned his stripes
Posts: 310
Joined: 28 Feb 2012 00:26

Re: Batch script equivalent for conversion on Mac for VLC

Postby aitte » 01 Mar 2012 22:23

Thank you so so much. It worked perfectly, I cant thank you enough.

sigbhu
New Cone
New Cone
Posts: 3
Joined: 02 Oct 2013 16:31

Re: Batch script equivalent for conversion on Mac for VLC

Postby sigbhu » 02 Oct 2013 19:56

this doesn't work for me. there are to problems:

1) with one file, it runs, and converts it, but then refuses to quit. it just stays there. if I keep VLC open and play the converted file, it is fine, but if i quit VLC, it adds something to the converted file and corrupts it. ( I know because after conversion, if i copy the file, only the original is corrupted and the copy of the converted is fine)

2) if i drag more than one file onto it, it fails. crashes instantly.

jacky97531
New Cone
New Cone
Posts: 1
Joined: 09 Jan 2014 19:23

Re: Batch script equivalent for conversion on Mac for VLC

Postby jacky97531 » 09 Jan 2014 20:47

Hi, I have the same problem, when I drag the files onto it, it crashes instantly. Could someone help me with this problem, please?

Thanks!

Raptor25
New Cone
New Cone
Posts: 1
Joined: 21 Jan 2014 00:58

Re: Batch script equivalent for conversion on Mac for VLC

Postby Raptor25 » 21 Jan 2014 01:52

The script [/b]WORKS[/b] but only with a single file.

Is there some simple way of allowing it to accept multiple files dropped on it?

Please make any solution easy to understand. I am not a programmer. I did complete a Diploma of IT in 2001 but I learnt only a little programming, and learnt to hate it. Java programming caused me to quit uni a few weeks after starting. Just some background info to let you know I do know computers, but not in the realm of programming.

thank you in advance

Luiz Siqueira Neto
New Cone
New Cone
Posts: 1
Joined: 25 Apr 2021 01:24

Re: Batch script equivalent for conversion on Mac for VLC

Postby Luiz Siqueira Neto » 25 Apr 2021 01:29

This code does what you ask, processes more than one file dropped on it. Important: it also moves the original file to the trash, you can recover it if you want.

Code: Select all

on open theDroppedItems repeat with a from 1 to length of theDroppedItems set theCurrentDroppedItem to item a of theDroppedItems try process_item(theCurrentDroppedItem) end try delete_file(theCurrentDroppedItem) end repeat end open -- this sub-routine processes files on process_item(this_item) set full_path to the POSIX path of this_item do shell script "/Applications/VLC.app/Contents/MacOS/VLC" & " '" & full_path & "' --sout='#transcode{vcodec=h264,vb=800,acodec=mp4a,ab=192}:standard{access=file,mux=mp4,dst=" & remove_file_suffix(full_path) & ".mp4}' vlc://quit" end process_item on remove_file_suffix(theText) if length of theText = 0 then error "Can't trim empty text." number -1728 else if length of theText = 1 then return "" else return text 1 thru -5 of theText end if end remove_file_suffix on delete_file(file_to_delete) tell application "Finder" move file_to_delete to trash end tell end delete_file


Return to “VLC media player for macOS Troubleshooting”

Who is online

Users browsing this forum: Google [Bot] and 20 guests