Drag and Drop to Batch Convert Videos Using FFMPEG

I've created this simple Applescript that will run an FFMPEG command in the Terminal (which I want to show so that I can see the progress) on files dropped on the MTS to Cropped MPG.app icon:
on open filelist
          repeat with i in filelist
                    tell application "Terminal"
                              do script "/Users/Lapaki/Desktop/MTS\ to\ Cropped\ MPG.app/Contents/Resources/ffmpeg -i " & POSIX path of i & " -vf crop=iw-360:1080:180:0 -f dvd -vcodec mpeg2video -s 720x480 -r 29.97 -acodec ac3 -ar 48000 -ab 448000 -async 1 -aspect 4:3 -b 4500000 " & POSIX path of i & ".mpg"
                    end tell
          end repeat
end open
I'd like to make this app portable so that I can share it or move it around as needed, so I put FFMPEG inside the Contents/Resources folder inside the app. The obvious problem is that the script will break as soon as I move the app to a different location. Is there a way to write the dynamic path of the app itself, no matter where it is moved, so that the app won't break when shared or moved?
This script also only works on a single video file. What I'd really like to do is drop a folder (which will always be called "mts") onto the app, and have the script create a new folder called "mpg" in the same directory as "mts", then batch convert all the .mts files in the "mts" folder, placing each new .mpg file into the "mpg" folder.
I'd also like the .mpg files to retain the same name as the .mts files, but instead of just appending .mpg, I'd like the .mpg to replace the .mts extension. So 00001.mts would be 00001.mpg (not 00001.mts.mpg as the current script generates).
Any help here would be much appreciated.

Tony,
quoted form of worked perfectly!
Now to the batching...
In my case there will never be nested directories. There will simply a folder called "mts" with at least one, but perhaps many .mts files, all named sequentially (00000.MTS, 00001.MTS, and so on).
So I'm having trouble figuring out how to integrate this:
on process_files_(fs)
          repeat with f in fs
                    tell application "System Events" to set finfo to the properties of f
                    if kind of finfo is "Folder" then
                              tell application "Finder" to set dirList to (items in f) as alias list
  process_files_(dirList) -- recurse directories
                    else if tolower(«class extn» of finfo) is not equal to "flac" then
                              tell me to activate
                              tell me to display dialog (name of finfo & " is not a Flac file") with iconcaution giving up after 2
                    else
                              try
                                        with timeout of 30000 seconds -- plenty of time
                                                  my itunes_convert_(f)
                                        end timeout
                              end try
                    end if
          end repeat
end process_files_
With this:
on open filelist
          repeat with i in filelist
                    tell application "Terminal"
                              do script quoted form of (POSIX path of (path to me) & "Contents/Resources/ffmpeg" as string) & " -i " & POSIX path of i & " -vf crop=iw-360:1080:180:0 -f dvd -vcodec mpeg2video -s 720x480 -r 29.97 -acodec ac3 -ar 48000 -ab 448000 -async 1 -aspect 4:3 -b 4500000 " & POSIX path of i & ".mpg"
                    end tell
          end repeat
end open
Again, it would be great to just drop a folder called "mts" onto the application, and have it convert all the .mts files inside and put them in a new folder called "mpg", which would be in the same directory as the "mts" folder.
Any way to make this happen?

Similar Messages

  • HT1473 Is drag to drop songs or videos still present in itunes. When i updated itunes i couldn't drag and drop any song or videos pls help.

    Is drag to drop songs or videos still present in itunes. When i updated itunes i couldn't drag and drop any song or videos pls help.

    It could be an indication or a damaged or dying hard drive.  I would recommend doing a disk diagnostic on the iPod's HD using the instructions given by turingtest2 in this older thread.  He also covers what the resulting numbers indicate.
    https://discussions.apple.com/thread/3784647?start=0&tstart=0
    If necessary, post the resultings numbers and we can verify what the next steps to take.
    B-rock

  • How do I drag and drop files between computers when using Home Sharing in ITunes?

    How can I drag music files between computers while using Home Sharing? An older version of ITunes had a Home Sharing icon in the column browser near the playlist so it was easy to drag and drop.

    Hello cacalenni,
    Thanks for using the Apple Support Communities. I understand that you wish to learn how to import songs using Home Sharing in the new iTunes. The following resource should assist you in doing so:
    iTunes 12 for Mac: Use Home Sharing to import items from another iTunes library
    http://support.apple.com/kb/PH19614
    Cheers,
    Matt M.

  • Can't Drag and Drop with a Double Tap using Single Finger in Lion?

    I installed the Mac OS X Lion two days. But I can't drag and drop with a Double tap using Single Finger, which I used to do in Snow Leopard.
    If I choose Three Finger Move, then Swap Between Pages goes back to "Scroll left or right with Two Fingers" that only works with Safari, but doesn't work with Chrome or Firefox.
    I tried literally every setting in Trackpad and also checked if there was a override settings and there is no overrride setting.
    Would be thankful, if you guys could suggest me what to do?
    ======================================
    My Machine Configuration:
    Macbook Pro 13" (mid 2010)
    Intel Core 2 Duo 2.4GHz
    4GB Ram
    Nvidia Geforce 320m
    Mac OS X Lion (Installe on a updated Snow Leopard 10.6.8)

    Hey Serge many thanks for telling me how to do. now its working like previously
    I just cheked the Dragging under Trackpad option and unchecked Three Finger Moves. now I can drag and drop with a double tap using single finger.
    Thank you guys. You are the best

  • How to I drag and drop from Customize Add On using a Wireless Mouse on a Laptop?

    I have been assisting a friend in installing Firefox. I have added Add On, but I cannot drag and drop them into the toolbars on the top. The tiny weenie add on tool bar stinks for those of us who are older and have weakened eyesight. How Can I Drap and Drop into the Toolbars on the Top using a laptop without a mouse?

    PS. I also tried drag-and-dropping to Photoshop, and it doesn't work either.
    I did more research online, and the more I research this, the more it seems that the LIGHTROOM DRAG AND DROP functionality works on MAC but not on PC...
    If it is the case, this would be a major annoyance.
    Some people said this feature worked on PC in Windows Vista.
    I tried running LR in compatibility more (Vista SP2), but this did not fix the issue.
    I am starting to wonder if this is a problem with LR running on WINDOWS x64 systems... (I am running WIN7 x64)

  • I can't seem to drag and drop more than one video on my timeline ? Only the audio will appear ?

    Hello, I've been working on Premiere for a year now
    I installed 2014 a week ago, and until today I haven't had any problems.
    When I drag and drop the first video, everything works fine, until I try to drop another video.
    The second video won't appear on the timeline, except for it's audio
    Which is weird to me because everything worked well on the CS6
    My sequence settings are
    Custom
    30 frames/second
    16/9
    sample rate : 44100Hz
    quickTime
    +H.264
    The first video's properties:
    Type: MPEG Movie
    File Size: 576,0 MB
    Image Size: 1920 x 1080
    Frame Rate: 30,00
    Source Audio Format: 44100 Hz - compressed - Mono
    Project Audio Format: 44100 Hz - 32 bit floating point - Mono
    Total Duration: 00:04:41:28
    Pixel Aspect Ratio: 1,0
    The second video's properties:
    Type: MPEG Movie
    File Size: 583,1 MB
    Image Size: 1920 x 1080
    Frame Rate: 29,97
    Source Audio Format: 48000 Hz - compressed - Stereo
    Project Audio Format: 48000 Hz - 32 bit floating point - Stereo
    Total Duration: 00:04:45:15
    Pixel Aspect Ratio: 1,0
    (it's a .MTS)
    What is weird, too, is that when I added the first video, I couldn't add it "Again", the same thing happened
    Any help? I need to finish the project by tonight :/

    My QuickTime version is the 10.4 (no idea if it's the latest one)
    What do you mean by my system properties ? My mac ? If so then its a 16Gb 1600MHz DDR3 + Nvidia Geforce GT 750M 1024MB, an OS X Yosemite version 10.10
    "What happens when you import the files onto a non-quicktime sequence?", well I don't know how to create a sequence before dragging a file on the timeline on this premiere, so I dragged the "Second video" first and it created a sequence with AVC Intra 100 1080i
    29,97 frames/second
    preview file format AVC-intra class100 1080i
    what's weird is that I could add the second video once, but not twice, and I can add the "first" video several times (it's weird because the sequence was created from the second video's properties)
    To answer your last question, the same thing happens too. I can create another sequence with the "Second video", add the "First video" 10 times but I won't be able to add the second video a second time.
    On the other hand, when i created another sequence with the "first video", I will be able to add the first video as much as I want, but I won't even be able to add the "second" video once.

  • Drag and drop interaction for a different use

    Hi,
    Can anyone please help me get the a solution to the below:  For the drag and drop interaction my user should be able to drop the answer (irrespective of that being a wrong answer) to any of the options, but as they click Submit, the actual answers should show up.
    I am using Captivate 7.
    Thanks,
    Roja

    Thanks so much Sreekanth!
    One thing that I am still struggling with is, the source (the questions) do not sit on the wrong destinations (non-answers), the moment it dragged to the wrong answer, the source goes back to its original place .
    Thanks,
    Roja

  • Unable to Drag and Drop Yahoo emails to folders (Used to work. Still works fine on IE)

    Unable to Drag and Drop Yahoo emails to Yahoo Email folders using Firefox. I am sure this worked until recently.
    I am still able to Drag and Drop in the same yahoo sign on using Internet Explorer.

    I've found it works for some. I think it will only work if it can figure out which one to put it in. If it ins't capable or figuring that out, it won't work. I imagine if you drag several, and if even one can't be sorted, it will reject them all.

  • Drag and Drop for Externally Loaded Videos

    Good day to all. Thanks for viewing. My problem is that im trying to click and drag videos externally loaded onto the flash stage. Apparently normal drag-drop methods won't make it work Anyway to work around this error? Thanks! Here's what i've came up with so far.
    var videoConnection:NetConnection = new NetConnection();
    videoConnection.connect(null);
    var videoStream:NetStream = new NetStream(videoConnection);
    videoStream.play("video.flv");
    var video:Video = new Video();
    video.attachNetStream(videoStream);
    addChild(video);
    video.addEventListener(MouseEvent.MOUSE_DOWN, dragMovie);
    video.addEventListener(MouseEvent.MOUSE_UP, dropMovie);
    function dragMovie(event:MouseEvent):void
      video.startDrag();
    function dropMovie(event:MouseEvent):void
      video.stopDrag();

    var mySprite:Sprite = new Sprite();
    mySprite.addChild(video);
    addChild(mySprite);
    Then add listeners that you added to video -  to mySprite.

  • Can't drag and drop images onto PS icon using Snow Leopard

    In general this is minor but frustrating.  You can't drag an image from a document onto the PS 11.0.1 icon anymore to open the image in Photoshop.

    I just read another from another website - http://www.bulletsandbones.com/GB/FAQPages/OddBallProbs.html
    that if you choose delete the prefernce files .plist/.cs and use "SAVE AS" vs "SAVE" the files I referred to above get saved when attempting to open th project again. I tried it and it seems to work for me now. I hope this helps others with the GB *"File Not Found"* dilemma in Leopard and Garageband V5.1
    Message was edited by: Mikeatcaz

  • Moving answers in a quiz once they have been matched to a target in using drag and drop

    Hi,
    I am having a problem with some of my drag and drop quizzes that I'm wondering if anyone you might be able to help me with?
    In some drag and drop quizzes I have created, using the Infosemantics drag and drop light widget in Captivate 5.5, I can move the answer after having matched it to a target but before submittting.  Whereas in some quizzes I have created, the answers get stuck and do not let me move the answers after I have matched them to a target, even though I haven't submitted.  This leaves me no choice but to clear all my answers and start again if I have made a mistake. 
    Please can you tell me how to enable the answers to move even after they have been placed on a target? 

    Emma,
    Take a look at the troubleshooting tips on this page from the Infosemantics website:
    http://www.infosemantics.com.au/adobe-captivate-widgets/drag-and-drop/troubleshooting-widg et-issues
    Pay particular attention to the section entitled: "My drag and drop question works correctly sometimes, but not other times. "
    From the appearance of your slide, it looks like you may have removed some of the components from the quiz slide that are necessary for it to function correctly.  Try the test that this section of the troubleshooting suggests so that you can see if this is the case.  If it turns out that you have deleted some items, you'll need to recreate your quiz slide to get them back again.
    Hope this helps.

  • Cant drag and drop from file-roller to nautilus when using List View

    Hi, im using file-roller and i can only use drag and drop feature from file-roller when i use Icon View. If i select List View i cant drag and drop.
    Is that an expected behavior or its a bug? Is there a patch or work around? (File Roller 2.20.1 and Gnome 2.20.2)
    I think its a problem with file-roller cause in my other box, running ubuntu 7.10 i have the same problem, but i can drag and drop from ark even when using List View.
    Thx!

    Well, sorry for the double post, but after a little research i found this is a bug, actually a not yet implemented feature. There is a patch and probably its going to be merged in next version.
    Ill try to apply the patch myself, if it works could the maintainer Jan de Groot put it on the repository?
    Here is the bug: http://bugzilla.gnome.org/show_bug.cgi?id=171655
    Here is the patch: http://bugzilla.gnome.org/attachment.cg … ction=view
    Cya

  • Flash drag and drop not working on Firefox for android browser

    Drag and drop functionality is not working using Firefox Browser for Android on tablet. We tested with flash action script 2.0 & 3.0 content, both have same issue. Specs of the tab and OS are as follows.
    Android - Kitkat 4.4.2
    Tab models - Lenovo A7600H and Samsung Tab4 T531
    Please refer to a previous case raised on the same issue here at this link (Case 1029615) - https://support.mozilla.org/en-US/questions/1029615
    Additionally, we observed that the object on which Drag and Drop event was triggered, is moving little bit when we double tap.
    Does Firefox provide any libraries to support Drag and Drop functionality on Flash? We are using Geekoview api to execute flash content in our app. Will the same support be provided in Geekoview as well?
    Are there other folks facing the same issue? Is there a solution or workaround to get this feature running?

    Flash on Android is no longer supported by Adobe. While Firefox does support basic functionality we mainly focus on legacy video applications. You may run into issues with Flash and Geckoview. I doubt we have any resources to support that configuration.

  • Problem with Drag and drop manager

    I am noticing that the sample provided at
    http://livedocs.adobe.com/flex/3/html/help.html?content=dragdrop_7.html is not working when tried on any version of FireFox browser on a Mac OS version 10.6.3.
    So my understanding is that there seems to be some problem with the drag and drop manager in Flex when used on Firefox on a Mac OS version 10.6.3.
    It will be very helpful if you can provide any work around for this issue. We want to implement the drag and drop feature in a website that we are building for one of our clients.

    You must be an Oracle employee as you're referring to a component in the upcoming JDeveloper version which has yet been released to the general public. Oracle employee's are, I believe, directed to post on internal Oracle forums.
    CM.

  • Drag and drop file to desktop bug

    I have a new fusion drive 27" iMac with Thunderbolt Cinema Display.
    When I drag a file, like an attachment from mail, onto the desktop it does not drop the file where the cursor indicates it will.
    The same thing when dragging from the download folder or a finder window.
    The file is randomly paced on the main iMac desktop in no particluar order, and you can't precisely drop a file where you want.
    File can be dropped behind open windows, making them hard to find.
    If the Thunderbolt display is unplugged, the issue goes away and drag and drop is precise.
    This used to happen on my old iMac aswell, but i put it down to a bug with my system, however, it also happened out-of-the-box on the new fusion iMac before I installed any software or files, as I was specifically testing this - it's very annoying and disruptive to workflow.
    Something with OSX doesn't like the external monitor when it comes to drag and drop to desktop.

    The card reader is apparently stuck in write-locked mode. I don't generally advise do-it-yourself hardware repair, but one ASC poster managed to fix this problem. I haven't tried the fix myself and I can't offer any guidance beyond what's in that discussion. If you cause damage, don't expect your warranty to cover it. I suggest you instead make a "Genius" appointment at an Apple Store.

Maybe you are looking for

  • [AWESOME WM] How to define the size of textbox widget

    Hi, I have problem with network widget. When some transfer has place widget change it's value and move all widgets that are place before it. Is there any why to set it's width to some fix value so it have some margin for changes? To create widget I u

  • Duplicate rows displayed in list

    I am using ADF, Struts and JSP. On occasion, some of the pages that simply display a list of attibutes in a VO display duplicate rows - these views reference just one EO and in the majority of cases all of the default settings are used. There seems t

  • Call ManagedBean method on TabSwitch in UI Shell

    Hello, We have our own version of Oracle UI Shell with a different look and feel. Inside the tabs, we have regions containing jsff that get rendered on tab switch. The jsff itself has 3 regions inside of it, lets say r1, r2, r3 Once we switch tab, we

  • ORACLE TEXT INDEX ON VARCHAR2 COLUMN

    Hello All, I find a search in our application very slow so i thought of using ORACLE TEXT CTXCAT index based search but i find certain inconsistencies . How can this be avoided....The following query should not return result if i can replace with ora

  • How to use/build stack layout with features like bring to top?

    I need a layout where i can move my views to any position i want to without destroying them and at the same time can use functionalities like pop and push with the same effect as stacknavigator.