Saturday, October 26, 2013

ffmpeg transcode of h.264 and ac3 encoded files to play on more devices

many devices won't play ac3 coded media.  this a discussion of recoding

Its been done, and you don't even need to whitelist your chromecast, you just have to enable 'developer mode' in the Google Cast extension. The guy even made a VLC transcoding option, but I just quickly repackage my files with FFmpeg if needed before playback.

I would first use mediainfo to see what your file is already, and check against the list of supported codecs for the Chromecast.
Assuming that you do need to convert, you need to figure out what exactly. For example, a lot of scene(aka pirate) releases that are in MKV are H.264 video(which works just fine on the Chromecast) and AC3 audio(which does not work on the Chromecast). So in a lot of cases, you will just be repacking the audio.
Depending on your FFmpeg, you will have different encoding and decoding libraries. The most surefire way is to just build it yourself - but I think if you're on Ubunut you can install packages for encoders.
But generally, what I do is repack the video(no conversion), and convert the audio to either AAC(preferred), or MP3(a better fallback option if you're using Windows).
I do:

ffmpeg -i <input file> -c:v copy -c:a libfdk_aac <output file>
if converting to MP3 audio, you need to specify a specific bitrate:

ffmpeg -i <input file> -c:v copy -c:a libmp3lame -b:a 320k <output file>
And lastly, if you video didn't come in H.264 to begin with, go ahead and just re-encode like this:

ffmpeg -i <input file> -c:v libx264 -c:a libfdk_aac <output file>
Hope this helps!
Edit: If you convert from a non-H.264 file, the audio may already be in MP3, and then you would only need to convert the video, like so:

ffmpeg -i <input file> -c:v libx264 -c:a copy <output file>

No comments:

Post a Comment