Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: name 'videolist' is not defined #9

Open
wanfuse123 opened this issue Jul 30, 2020 · 1 comment
Open

NameError: name 'videolist' is not defined #9

wanfuse123 opened this issue Jul 30, 2020 · 1 comment

Comments

@wanfuse123
Copy link

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 'video/driving.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf58.29.100
Duration: 00:19:47.84, start: 0.000000, bitrate: 1028 kb/s
Stream #0:0(und): Video: av1 (av01 / 0x31307661), none, 1920x1080, 891 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 24k tbc (default)
Metadata:
handler_name : ISO Media file produced by Google Inc.
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 133 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:1 -> #0:0 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, mp3, to 'sound.mp3':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
TSSE : Lavf57.83.100
Stream #0:0(und): Audio: mp3 (libmp3lame), 44100 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc57.107.100 libmp3lame
size= 27841kB time=00:19:47.84 bitrate= 192.0kbits/s speed=49.6x
video:0kB audio:27841kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.002701%

NameError Traceback (most recent call last)
in ()
13 get_ipython().system('ffmpeg -y -i $vid -vn -ar 44100 -ac 2 -ab 192K -f mp3 sound.mp3')
14
---> 15 for videoname in videolist:
16 vidcap = cv2.VideoCapture('video/intermediate/' + videoname)
17 success,image = vidcap.read()

NameError: name 'videolist' is not defined

@wanfuse123
Copy link
Author

#@title ← FPS Recovery

  | fps_of_video = int(cv2.VideoCapture(vid).get(cv2.CAP_PROP_FPS))
  | frames_of_video = int(cv2.VideoCapture(vid).get(cv2.CAP_PROP_FRAME_COUNT))
  |  
  | !rm -rf frames
  | !mkdir frames
  |  
  | play_video = True #@param {type:"boolean"}
  | play_html = ''
  |  
  | add_audio = True #@param {type:"boolean"}
  | if add_audio == True:
  | !ffmpeg -y -i $vid -vn -ar 44100 -ac 2 -ab 192K -f mp3 sound.mp3
  |  
  | for videoname in videolist:
  | vidcap = cv2.VideoCapture('video/intermediate/' + videoname)
  | success,image = vidcap.read()
  | count = 0
  | success = True
  | while success:
  | cv2.imwrite("frames/frame%09d.jpg" % count, image)
  | success,image = vidcap.read()
  | count += 1
  |  
  | frames = []
  | img = os.listdir("frames/")
  | img.sort()
  | for i in img:
  | frames.append(imageio.imread("frames/"+i))
  | frames = np.array(frames)
  | dstvid = 'video/final/' + videoname
  | imageio.mimsave(dstvid, frames, fps=fps_of_video)
  |  
  | !rm -rf frames
  | !mkdir frames
  |  
  | print('Assembly completed for ' + videoname)
  |  
  | if add_audio == True:
  | tmpfile = dstvid.replace('.mp4', '-audio.mp4')
  | !ffmpeg -i sound.mp3 -i $dstvid $tmpfile
  | !rm -rf $dstvid
  | !mv -f $tmpfile $dstvid
  |  
  | if play_video == True:
  | video = io.open(dstvid, 'r+b').read()
  | encoded = base64.b64encode(video)
  | play_html = play_html + (''.format(encoded.decode('ascii')))
  |  
  | clear_output()
  | HTML(data=play_html)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant