vidgear: CalledProcessError at /teaches/api/v1/admin/video-upload

Description

django project after upload video and use streamgear occer this erorr CalledProcessError at /teaches/api/v1/admin/video-upload Command '['ffmpeg', '-y', '-hide_banner', '-i', '/usr/src/app/media/upload/2021/01/1609541608-vide-finnanc.mp4', '-vcodec', 'libx264', '-vf', 'format=yuv420p', '-aspect', '0', '-crf', '18', '-tune', 'zerolatency', '-preset', 'ultrafast', '-acodec', 'aac', '-movflags', '+faststart', '-map', '0', '-s:v:0', '0x5581', '-b:v:0', '0k', '-b:a:0', '96k', '-map', '0', '-s:v:1', '320x240', '-b:v:1', '500k', '-b:a:1', '96k', '-bf', '1', '-sc_threshold', '0', '-keyint_min', '50', '-g', '50', '-use_timeline', '1', '-use_template', '1', '-window_size', '5', '-adaptation_sets', 'id=0,streams=v id=1,streams=a', '-f', 'dash', '/usr/src/app/media/upload/1609541608-vide-finnanc.mpd']' returned non-zero exit status 1.

code

file = request.FILES.get('file')
    fs = FileSystemStorage()
    category = ''
    if 'category' in request.data.keys():
        category = request.data['category'] + '/'

    path = f"{settings.UPLOAD_URL}{category}{datetime.datetime.now().strftime('%Y/%m/%s')}"
    name, extension = os.path.splitext(file.name)
    if extension not in ['.mp4']:
        return Response({
            "detail": "invalid video file format"
        }, status=status.HTTP_422_UNPROCESSABLE_ENTITY)

    filename = fs.save(f"{path}-{slugify(name)}{extension}", file)
    uploaded_file_url = fs.url(filename)

    ''' 
        Encode Video
        encode upload video file
    '''
    # activate Single-Source Mode with valid video input
    stream_params = {
        "-video_source": f"{settings.MEDIA_ROOT}/{filename}",
        "-streams": [
            {"-resolution": "320x240", "-video_bitrate": "500k"},  # Stream3: 320x240 at 500kbs bitrate
        ],
    }
    # describe a suitable manifest-file location/name and assign params
    encodeUrl = f"media/upload/{filename.split('/')[-1].replace('.mp4', '')}.mpd"
    streamer = StreamGear(output=encodeUrl,format="dash", **stream_params)
    # trancode source
    streamer.transcode_source()
    # terminate
     streamer.terminate()` 

stream gear log

StreamGear :: CRITICAL :: StreamGear has been successfully configured for Single-Source Mode.

StreamGear :: INFO :: Source Audio will be used for streams.

 

StreamGear :: CRITICAL :: Transcoding streaming chunks. Please wait...

Processing Frames: 0% 0/27 [00:00<?, ?frame/s]

StreamGear :: ERROR :: StreamGear failed to initiate stream for this video source!

Environment

  • VidGear version: 0.1.9
  • Python version: 3.8
  • PiP version: 20
  • Operating System and version: docker-python image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 26 (14 by maintainers)

Commits related to this issue

Most upvoted comments

this output after run command $ ffprobe -i /usr/src/app/media/upload/2021/01/1609541608-vide-finnanc.mp4 ffprobe version 4.1.6-1~deb10u1 Copyright (c) 2007-2020 the FFmpeg developers built with gcc 8 (Debian 8.3.0-6) configuration: --prefix=/usr --extra-version='1~deb10u1' --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-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56015c1a1f80] stream 0, timescale not set Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/usr/src/app/media/upload/2021/01/1609541608-vide-finnanc.mp4: Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2017-04-30T01:17:30.000000Z Duration: 00:00:27.31, start: 0.000000, bitrate: 717 kb/s Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x352 [SAR 1:1 DAR 20:11], 614 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default) Metadata: creation_time : 2017-04-30T01:17:30.000000Z handler_name : IsoMedia File Produced by Google, 5-11-2011 Stream #0:2: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 480x360 [SAR 1:1 DAR 4:3], 90k tbr, 90k tbn, 90k tbc

@esmaily Thanks for this output, indeed there was a regex bug in parsing multiple streams, I’ve pushed a commit to fix it. You can try this fix by running following commands:

  # clone the repository and get inside
  git clone https://github.com/abhiTronix/vidgear.git && cd vidgear

  # checkout the latest `development` branch
  git checkout development

  # install normally
  pip3 install .

after enable sreamgear logging: ValueError [StreamGear:ERROR] :: Kindly provide a valid output value. Refer Docs for more information. /usr/local/lib/python3.8/site-packages/vidgear/gears/streamgear.py, line 225, in init /usr/local/bin/python 3.8.3

@esmaily That’s all? I need complete output from commandline to debug what is happening. Also check if path /usr/src/app/media/upload/ exist or not? If not, then run command mkdir -p /usr/src/app/media/upload first in docker and then specify path '/usr/src/app/media/upload/1609541608-vide-finnanc.mpd' in StreamGear.

ValueError [StreamGear:ERROR] :: Kindly provide a valid output value. Refer Docs for more information.

This means there is no value on output parameter at StreamGear, meaning your code is incorrect. If you need to enable logging you just do:

streamer = StreamGear(output=encodeUrl, logging=True, format="dash", **stream_params)

running ffmpeg -i video-finance.mp4 -filter_complex "[0]split=6[mid0][mid1];[mid0]scale=320:-1[out0];[mid1]scale=640:-1[out1]" -map [out0] -map 0:a -map [out1] -map 0:a -c:a aac -c:v:0 libx264 -c:v:1 libvpx-vp9 -use_timeline 1 -use_template 1 -window_size 6 -adaptation_sets "id=0,streams=v id=1,streams=a" -hls_playlist true -f dash output.mpd in bash it works but run this command in project with subprocess occer this error

Errno 2] No such file or directory: 'ffmpeg -i /usr/src/app/media/upload/2021/01/video-finance.mp4 -filter_complex "[0]split=6[mid0][mid1];[mid0]scale=320:-1[out0];[mid1]scale=640:-1[out1]" -map [out0] -map 0:a -map [out1] -map 0:a -c:a aac -c:v:0 libx264 -c:v:1 libvpx-vp9 -use_timeline 1 -use_template 1 -window_size 6 -adaptation_sets "id=0,streams=v id=1,streams=a" -hls_playlist true -f dash output.mpd'

But after append shell=True it works subprocess.run(CMD,shell=True)

how add shell=True in vidgear??

Why not valid path?

this output after run command $ ffprobe -i /usr/src/app/media/upload/2021/01/1609541608-vide-finnanc.mp4 ffprobe version 4.1.6-1~deb10u1 Copyright (c) 2007-2020 the FFmpeg developers built with gcc 8 (Debian 8.3.0-6) configuration: --prefix=/usr --extra-version='1~deb10u1' --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-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x56015c1a1f80] stream 0, timescale not set Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/usr/src/app/media/upload/2021/01/1609541608-vide-finnanc.mp4: Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2017-04-30T01:17:30.000000Z Duration: 00:00:27.31, start: 0.000000, bitrate: 717 kb/s Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x352 [SAR 1:1 DAR 20:11], 614 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default) Metadata: creation_time : 2017-04-30T01:17:30.000000Z handler_name : IsoMedia File Produced by Google, 5-11-2011 Stream #0:2: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 480x360 [SAR 1:1 DAR 4:3], 90k tbr, 90k tbn, 90k tbc