Author Topic: [Python] Converting DTS audio to AC3 with avconv  (Read 867 times)

0 Members and 1 Guest are viewing this topic.

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
[Python] Converting DTS audio to AC3 with avconv
« on: November 30, 2015, 08:38:57 pm »
I wrote about what I use my raspberry for before, one of the usages is media streaming. MiniDLNA is fully capable of streaming out fullhd videos, but the problem arises with DTS audio.
I don't know if my TV (LG) can't play DTS audio or MiniDLNA doesn't support streaming it, so the videos are without sound. Either way I made the below script to convert DTS audio to AC3 which my TV can play using avconv (ffmpeg for oldfags).
I tested it with few fullhd movies, seemed to work ok. Best part is that my RPI doesn't produce smoke when converting, in fact it barely goes above 35C, but that's mostly because I have heatsinks and a fan on it.
If there is something to improve, please suggest!

Code: (python) [Select]
#!/usr/bin/env python
import sys
import os

if (len(sys.argv) > 1):
    try:
        dir, fname = sys.argv[1].rsplit("/", 1)
        outname = "%s/c_%s" % (dir, fname)
        os.system("avconv -i %s -vcodec copy -acodec ac3 -async 1000 -scodec copy -y %s" % (sys.argv[1], outname))
    except:
        print "Wrong args given"
else:
    print "No args given"

I tried to do it in bash to be all native and stuff, but it was such a headache, that I just did it in python :/