DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Podcast Conversion and dates  (Read 8,899 times)

oblivion

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 499
    • Participated in NANY Challenge Once
Podcast Conversion and dates
« on: March 21, 2011, 02:30 PM »
I am a bit of a podcast addict. Sadly, I get a bit behind and -- because I TRY to be organised -- I keep my podcasts in a single folder, so I can sort them in date order, and transfer the oldest first to my MP3 player.

Mostly, this works very well. But one of the podcasts I regularly get comes in M4A format. Although the software I use to transfer stuff to my player converts things on the fly, I prefer to do the conversion myself so I can control the output quality and filesize a bit better.

So far, I have found the easiest way to do this is to use fre:ac (the new version of BonkEnc, still free though) to do the conversion to MP3, output the files somewhere away from the originals, then use another little freebie (filedate) to re-datestamp the new files to match the originals, so they don't get sorted to the end of the list. Fiddly and time-consuming, especially if you've only just got round to it after a few weeks of letting M4As build up...

Two related requests, then. Either a program that can suck in an audio file (or a list of files) and squirt out an MP3 with the same time/datestamp as the original, optionally deleting the original... or if doing that is too complex for a "snack", a program that can display two lists of files, allow them to be lined up by hand in case filenames don't quite match, then apply the date/timestamps from the source list to the destination list.
-- bests, Tim

...this space unintentionally left blank.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: Podcast Conversion and dates
« Reply #1 on: March 21, 2011, 02:32 PM »
interesting...  in thinking about a general purpose solution, one question is, can you keep the base filenames the same?
if so then a good general purpose solution might be an app that scans a directory and sets the file date stamps for all sets of files with same basename (and different extensions) to the date of earliest datestamp in the set.

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: Podcast Conversion and dates
« Reply #2 on: March 21, 2011, 04:17 PM »
Either a program that can suck in an audio file (or a list of files) and squirt out an MP3 with the same time/datestamp as the original

fre:ac actually comes with a commandline version in its install so that, combined with a small bit of AHK script, would make this a piece of cake.  Heck, you could even use the lame.exe file directly.  Do you have AutoHotkey installed?

oblivion

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 499
    • Participated in NANY Challenge Once
Re: Podcast Conversion and dates
« Reply #3 on: March 21, 2011, 04:37 PM »
fre:ac actually comes with a commandline version in its install so that, combined with a small bit of AHK script, would make this a piece of cake.  Heck, you could even use the lame.exe file directly.  Do you have AutoHotkey installed?

I've got a portable copy somewhere, but I've never tried to use it. You're a proper programmer, I just pretend to know what it's about sometimes.  :-[

(I can sometimes write very simple and mechanistic black boxes -- take some input textfile, chop it up, put it back together in a different order, exit. Anything requiring screen design or direct access to the Windows API, I'm running away so fast people are choking on the dust.)
-- bests, Tim

...this space unintentionally left blank.

oblivion

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 499
    • Participated in NANY Challenge Once
Re: Podcast Conversion and dates
« Reply #4 on: March 21, 2011, 04:56 PM »
Do you have AutoHotkey installed?

Okay, just had a bit of a look at the helpfile for it. It looks like a file loop could be used to retrieve the file list and operate on them one at a time, and if I can throw commands at fre:ac or Lame, I might even be able to puzzle something out.

What I'm less sure about is -- as I suggested previously -- putting a front end on it. To make it reliable, I'd want a front end on it that allowed the specification of the input and output sources and a path to LAME or fre:ac or whatever, and I suppose to make it bulletproof it'd probably have to be able to specify encoder options and suddenly it's looking like I really should be running away from all this ui stuff  :-[  :)
-- bests, Tim

...this space unintentionally left blank.

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: Podcast Conversion and dates
« Reply #5 on: March 21, 2011, 05:07 PM »
Here's a proof-of-concept script.  

  1. Save this to <whatever>.ahk and put it in your fre:ac folder.
  2. Edit the myOutputDir variable to an output folder of your choice.
  3. Run the script.  You should see a small square begging for you to drop some files on it.
  4. Drop some files on it!
  5. They will be converted to mp3 and placed in your chosen output directory with the original modification times.

Code: (autohotkey)
; Set up environment.
#NoEnv
#SingleInstance, Off
SetBatchLines, -1
SetControlDelay, -1
DetectHiddenWindows, On
SetTitleMatchMode, 2
SetWorkingDir, %A_ScriptDir%

; Variables.
AppName     := "Podblivion"
myOutputDir := "c:\tmp2"

; Build simple drop target.
Gui, Add, Text, xm ym w150 h150 Center 0x200 vtxtDisplay, Drop files here...
Gui, Show, , % AppName
Return ; End of auto-execute section.


GuiDropFiles:
{
    myFiles := A_GuiEvent
    Loop, Parse, myFiles, `n
    {
        If ( A_LoopField != "" )
        {
            myFilePath := A_LoopField
            
            ; Notify user that we're doing something.
            SetTimer, Progress, On
            
            ; Get modified time of dropped file.
            FileGetTime, modTime, % myFilePath, M
            
            ; Crack path and form up output filename with mp3 extension.
            SplitPath, myFilePath, , , , myFileNameNoExt
            myOutputFile := myOutputDir . "\" . myFileNameNoExt . ".mp3"
            
            ; Set parameters for the freaccmd.exe program.
            cmdParams := "-e LAME -m VBR -b -q 5 -d " . myOutputDir . " """ . myFilePath . """"
            
            ; Convert file.
            RunWait, % A_ScriptDir . "\freaccmd.exe " . cmdParams, , Hide
            
            ; Set output file's modified time to input file's value.
            FileSetTime, % modTime, % myOutputFile, M
        }
    }
    SetTimer, Progress, Off
    GuiControl, Text, txtDisplay, Drop files here...
}
Return


Progress:
{
    GuiControl, Text, txtDisplay, Converting |
    Sleep, 250
    GuiControl, Text, txtDisplay, Converting /
    Sleep, 250
    GuiControl, Text, txtDisplay, Converting -
    Sleep, 250
    GuiControl, Text, txtDisplay, Converting \
    Sleep, 250
}
Return


GuiClose:
GuiEscape:
{
    ExitApp
}
Return

oblivion

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 499
    • Participated in NANY Challenge Once
Re: Podcast Conversion and dates
« Reply #6 on: March 23, 2011, 10:17 AM »
interesting...  in thinking about a general purpose solution, one question is, can you keep the base filenames the same?
if so then a good general purpose solution might be an app that scans a directory and sets the file date stamps for all sets of files with same basename (and different extensions) to the date of earliest datestamp in the set.
Sorry, I didn't notice this response before. I don't see why you couldn't constrain most conversion apps to work in that way, and it occurs to me that a general purpose app that took that approach might be useful for all sorts of things where you might want the creation date to be retained in a different file format. Photos as well as audio -- maybe even MORE than audio, since I suspect my idiosyncratic approach to podcasts may not be "normal."  :)
-- bests, Tim

...this space unintentionally left blank.

oblivion

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 499
    • Participated in NANY Challenge Once
Re: Podcast Conversion and dates
« Reply #7 on: March 23, 2011, 10:58 AM »
Here's a proof-of-concept script. 

Thanks!

It doesn't seem to want to work, though. The script is in the freac app directory (\portableapps\freacportable\app\freac) and freaccmd.exe is present in the same place. I can drop an m4a onto it and it does the "converting" thing for a little while then stops, but I can't find any sign of the output file in the folder I specified (g:\temp) or, indeed, anywhere else.

Any idea what might be going wrong, or how I can watch what it's doing in more detail, perhaps?
-- bests, Tim

...this space unintentionally left blank.

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: Podcast Conversion and dates
« Reply #8 on: March 23, 2011, 05:16 PM »
Any idea what might be going wrong, or how I can watch what it's doing in more detail, perhaps?

On line 43, you can take off the "Hide" keyword.  This will allow you to see the freaccmd.exe window.

Original address: https://www.donationcoder.com/forum/index.php?topic=26133.0