I use wildcard.video. I use it with symlink
ln -s /usr/bin/ffprobe /usr/local/bin/avprobe
, because ubuntu has changed the package. If i upload a video or press the convert button in action menu then the convert process fails. I investigated the problem a little bit and i found the following situation.
# https://github.com/collective/wildcard.media/blob/master/wildcard/media/convert.py#L49
def _run_command(self, cmd, or_error=False):
if isinstance(cmd, six.string_types):
cmd = cmd.split()
cmdformatted = ' '.join(cmd)
logger.info("Running command %s" % cmdformatted)
process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=self.close_fds)
output, error = process.communicate()
print("###Output###")
print(output)
print("###ReturnCode###")
print(process.returncode)
print("###Command###")
print(cmd)
print("###Command Formatted###")
print(cmdformatted)
print("###Error###")
print(output)
process.stdout.close()
process.stderr.close()
if process.returncode != 0:
error = """Command
%s
finished with return code
%i
and output:
%s
%s""" % (cmdformatted, process.returncode, output, error)
logger.info(error)
raise Exception(error)
logger.info("Finished Running Command %s" % cmdformatted)
if not output:
if or_error:
return error
return output
Here is the output of print statements:
###Output###
b''
###ReturnCode###
0
###Command###
['/usr/bin/avprobe', '/tmp/tmp4p3bo3ph/testvideo.mp4']
###Command Formatted###
/usr/bin/avprobe /tmp/tmp4p3bo3ph/testvideo.mp4
###Error###
b"ffprobe version 4.2.4-1ubuntu0.1 Copyright (c) 2007-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/tmp4p3bo3ph/testvideo.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:01:55.03, start: 0.000000, bitrate: 1731 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1601 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : ?Mainconcept Video Media Handler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 123 kb/s (default)
Metadata:
handler_name : #Mainconcept MP4 Sound Media Handler"
From my point of view error and output are twisted. But the documentation of subprocess
says that the returned value is a tuple of output, error. I'm a little bit confused.
Update:
I found the issue. It's a missing string decode from bytes to str and the afterwards string operations in the _convertFormat method.
class AVProbeProcess(BaseSubProcess):
"""
"""
if os.name == 'nt':
bin_name = 'avprobe.exe'
else:
bin_name = 'avprobe'
def info(self, filepath):
cmd = [self.binary, filepath]
result = {}
for line in self._run_command(cmd, or_error=True).splitlines():
line = line.decode() # -> that was misssing
if ':' not in line:
continue
name, data = line.split(':', 1)
data = data.strip()
if not data:
continue
name = name.strip().lower()
if ' ' in name:
continue
result[name] = data
return result