0

I am processing videos stored on my google drive on google colab using moviepy. I want to save the trimmed video in my current working directory on gogle drive, but I am unable to do so. Below is the code I am using (IIUC targetname is where I specify the name of the new file I am making):

ffmpeg_extract_subclip("A1203.mp4", start_time, end_time, targetname='test.mp4')
files.download('test.mp4')

Here is my error message:

[MoviePy] Running:
>>> /usr/bin/ffmpeg -y -i D1203H.mp4 -ss 0.00 -t 300.00 -vcodec copy -acodec copy test.mp4
[MoviePy] This command returned an error !
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-4-8d9207533dd4> in <module>()
      2 end_time = 300
      3 
----> 4 ffmpeg_extract_subclip("D1203H.mp4", start_time, end_time, targetname='test.mp4')
      5 files.download('test.mp4')

1 frames
/usr/local/lib/python3.6/dist-packages/moviepy/tools.py in subprocess_call(cmd, verbose, errorprint)
     47     if proc.returncode:
     48         verbose_print(errorprint, "\n[MoviePy] This command returned an error !")
---> 49         raise IOError(err.decode('utf8'))
     50     else:
     51         verbose_print(verbose, "\n... command successful.\n")

OSError: ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D1203H.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : HandBrake 0.10.0 2014112200
  Duration: 01:57:36.82, start: 0.000000, bitrate: 1975 kb/s
    Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 720x480 [SAR 8:9 DAR 4:3], 1803 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 30k tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 166 kb/s (default)
    Metadata:
      handler_name    : Stereo
test.mp4: Read-only file system
connor449
  • 1,549
  • 2
  • 18
  • 49

1 Answers1

0

The code you provided and the code within the error message differ. In the latter it states:

ffmpeg_extract_subclip("D1203H.mp4", start_time, end_time, targetname=files.download('test.mp4'))

And this is also the reason why the execution fails. Via files.download('test.mp4') you try to download test.mp4 from your current directory, but since it doesn't exist yet, it fails. So you have to call the command without the files.download() first and do the download afterwards

ffmpeg_extract_subclip("D1203H.mp4", start_time, end_time, targetname='test.mp4')
files.download('test.mp4')
Solvalou
  • 1,133
  • 1
  • 10
  • 19