gPodder Bug Tracker – Bug 585
Convert m4a files to mp3 when transfering to device
Last modified: 2012-10-13 15:56:32 CST
Some podcasts deliver their audios as m4a or ogg vorbis, which isn't supported by all devices.
So, there could be an option to convert these *.m4a or *.ogg into *.mp3 (or something different).
Converting .ogg is already supported if you install all the dependencies (see the
"Additional components" menu item for a list of things you are missing for the iPod "OGG" feature).
Converting m4a isn't possible - you would need to write a patch (have a look at libconverter.py in the source) and submit it.
I believe the following addition to libconverter.py should enable conversion. But I haven't thoroughly tested it due to lack of m4a feeds that interest me (I started this because I thought I came across one, but it turned out to be defunct). Also, the config and sync.py appear to use logic of "convert all formats or none" (presented in the UI as ogg conversion since that's the only format it's currently capable of converting), so some modification there would be necessary for a proper patch.
Oh, and there would probably need to be a new "Additional Component" dependency on MPlayer with regard to m4a conversion support.
Anyhow, the code:
converters.add_converter( 'm4a', 'mplayer', '-really-quiet -nolirc -ao pcm:file=/dev/stdout "%s"')
Wow, I didn't know this would be THAT easy. Great thanks! It works like a charm.
> converters.add_converter( 'm4a', 'mplayer', '-really-quiet -nolirc -ao
> pcm:file=/dev/stdout "%s"')
Are you sure?
I took a look to the code some weeks ago and if I remember correctly, the conversions opnly take place if you have configured that your device doesn't support OGG. My device supports it, so conversion will not be triggered.
Also, the conversion is only to mp3 and tags are lost in the process.
By the way, I think that the proper application to convert would be using faad (maybe mplayer as a fallback)
I haven't tested it but you can try...
converters.add_converter( 'm4a', 'faad', '-q -o /dev/stdout "%s"')
I only have taken a look to the code, I haven't make any test, so I may be wrong.
By the way, since the configuration dialog is being rewritten, is there a posibility to have a more configurable dialog with what formats do the player support (maybe even video formats) and the preferable format to do conversions? I would prefer to transcode to ogg instead mp3.
I forgot, since mplayer supports many formats, it can be used to try to handle unknown formats. And also ffmpeg if video conversions are added.
As my device also supports ogg vorbis, i just deleted the ogg-converter and told gpodder that my device does not support it.
It's hacky, but working. Of course, some nice gui would be cool ;)
Created attachment 461 [details]
I have been hacking libconvert.py
This version should support comversions from to several formats
The calls in sync.py will need to ve changed:
if libconverter.converters.has_converter(extension): -> if libconverter.converter.can_convert(extension):
local_filename = libconverter.converters.convert(filename, callback=callback_status) -> local_filename = libconverter.converter.convert(filename, callback=callback_status)
Also there need to be done the proper changes to allow the selection fo the output format (by default mp3) and to not convert if the player supports the format. But this will need changes in the device configuation dialog.
I have tested the module a bit and seems to work (but I haven't tested it inside gpodder)
For tag support and that maybe you can take some code or ideas from dir2ogg
I was unaware of faad (and hadn't noticed that tags were lost in conversion), but otherwise agree with your commentary. I did say, "the config and sync.py appear to use logic of 'convert all formats or none', so some modification there would be necessary for a proper patch." I was only offering a quick hack since there had been no activity on this ticket.
Again, there probably also need to be new "Additional Component" dependencies. Near the top of sync.py shows how existing per-feature oggdec/lame/mplayer dependencies are handled in that regard. I suppose it gets a little complicated with the fallback decoder... it doesn't look like the dependency manager (in services.py) is setup to handle the concept of a fallback dependency. Seems like you would wind up adding an "Additional Component" entry for each individual encoder/decoder, including the fallback(s). That may work against the user-friendliness of the dialog.
I like the ideas of flexible conversion and a fallback decoder. I would have preferred to see the Converters class enhanced, but I'll leave such stylistic concerns to more experienced python/gpodder developers. However, dependencies should probably be dynamically-checked (so installing oggdec/lame/etc doesn't require restarting gpodder...), especially since the "Additional Components" display *is* dynamically-checked.
Ideally, it seems like things would be setup such that a single line adds full knowledge of a particular encoder/decoder, which is then automatically added to the dependency manager (in some magically-intuitive way), which is later the entity queried each time a conversion is attempted (rather than directly using find_command from the FileConverter class). But that's probably crazy-talk.
Cool things happening here :)
* We should support video in addition to audio
* Video conversion might require a "user-definable" encoder line
(I think people have "known-good" command lines for their devices
with MPlayer of ffmpeg - or at least they can Google such lines)
* The user should be allowed to choose which formats are supported
through the UI (by simply entering a comma-separated extension list?)
* The user should be allowed to choose into which format unsupported
audio files get converted (based on which encoders we have
* We should give the user the option to not sync unsupported files and
videos (not every player supports video) or to try to convert the files
(In reply to comment #9)
> Cool things happening here :)
> Some thoughts:
> * We should support video in addition to audio
> * Video conversion might require a "user-definable" encoder line
> (I think people have "known-good" command lines for their devices
> with MPlayer of ffmpeg - or at least they can Google such lines)
Maybe also in audio, or at least a way to configure the encoding quality.
By default lame encodes to 128kbps CBR and oggenc to ~112kbps.
That could be low for music podcasts and, if you have few free space in your device, too high for voice podcasts.
Anyway, if this won't be configurable I suggest to use VBR instead CBR in lame. Maybe -V5 or -V6.
> * The user should be allowed to choose which formats are supported
> through the UI (by simply entering a comma-separated extension list?)
> * The user should be allowed to choose into which format unsupported
> audio files get converted (based on which encoders we have
Here is an screenshot of the dialog on Amarok1.4
> * We should give the user the option to not sync unsupported files and
> videos (not every player supports video) or to try to convert the files
To extract the audio can be a good idea in some cases. In fact, I'm subscribed to several feeds with the audio of documentals.
BTW, about the m4a files, apart of faad and faac, there is also neroaacdec, neroaacenc and neroaactag which are gratis but not libre.
Does anybody want to create a proper patch against the current Git head from attachment 461 [details]?
(In reply to comment #4)
> By the way, since the configuration dialog is being rewritten, is there a
> posibility to have a more configurable dialog with what formats do the player
> support (maybe even video formats) and the preferable format to do conversions?
> I would prefer to transcode to ogg instead mp3.
I second that.
Actually, knowing the original format, it would be nice to have a per-feed option (or a default one) to convert to **any** of the supported formats.
For example: I subscribed to a radio feed which is... a video, in mp4, but my device supports only mp3. The video does not bring me anything, I just see the radio guy speaking, to converting these videos to mp3 would be fine, I just need the sound.
There's now a hook script "m4a_converter" available in gPodder 3. Also, libconverter isn't available anymore, so I consider this fixed in gPodder 3.