Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

python 3 using ffmpeg in a subprocess getting stderr decoding error

$
0
0

I am running ffmpeg as a subprocess and using the stderr to get various bits of data like the subtitles stream Id's. It works fine for most videos, but one with japanese subtitles results in an error:

'charmap' codec can't decode byte in position xxx : character maps to

Much googling suggests the problem is that the japanese requires unicode, whereas English does not. Solutions offered refer to problems with files, and I cannot find a way of doing the same with the stderr. Relevent Code is below:

command = [ffmpeg,"-y","-i",fileSelected,"-acodec","pcm_s16le","-vn","-t","3", "-f",            "null","-"]print(command)   proc = subprocess.Popen(command,stderr=PIPE,Jstdin=subprocess.PIPE,                            universal_newlines=True,startupinfo=startupinfo)stream = ""    for line in proc.stderr:    try:        print("line",line)    except exception as error:        print("print",error)        line = line[:-1]        if "Stream #" in line:            estream = line.split("#",1)[1]            estream =estream.split(" (",1)[0]            print("estream",estream)            stream = stream + estream +"\n"  #.split("(",1)[0]             stream = stream + estream +"\n"

Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>