Created
September 18, 2020 17:42
-
-
Save orm011/04f8190ee9b242c4467ad11038c7bbe4 to your computer and use it in GitHub Desktop.
scikit video with custom gpu ffmpeg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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