Skip to content

Instantly share code, notes, and snippets.

@orm011
Created September 18, 2020 17:42
Show Gist options
  • Save orm011/04f8190ee9b242c4467ad11038c7bbe4 to your computer and use it in GitHub Desktop.
Save orm011/04f8190ee9b242c4467ad11038c7bbe4 to your computer and use it in GitHub Desktop.
scikit video with custom gpu ffmpeg
import os
ffmpeg_install_dir = '/nvme_drive/orm/ffmpeg_install2/'
os.environ['LD_LIBRARY_PATH'] = f'{ffmpeg_install_dir}/lib/'
import skvideo
skvideo.setFFmpegPath(f'{ffmpeg_install_dir}/bin/')
import skvideo.io
## minimal options
device=0
file = /big_fast_drive/orm/birds/birds_panama.mp4',
vr = skvideo.io.vreader(file,
inputdict={'-hwaccel':'nvdec',
'-hwaccel_device':f'{device}',
'-c:v':'h264_cuvid'})
for frm in tqdm(vr): # should be using gpu
pass
## some other filters (but note currently broken)
device=0
target_height=1080
target_width=int(np.round((target_height/1080)*1920))
vr1 = skvideo.io.vreader('/big_fast_drive/orm/birds/birds_panama.mp4', #height=target_height, width=target_width,
inputdict={'-hwaccel':'nvdec',
'-hwaccel_device':f'{device}',
'-c:v':'h264_cuvid',
},
outputdict={
'-vf':f'hwupload_cuda,scale_npp=-1:{target_height}:interp_algo=cubic,hwdownload,format=nv12'}, verbosity=1)
for frm in tqdm(vr1): # should show more gpu usage than previous option
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment