Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use ffmpeg with gpu support on macos

when i exec ffmpeg command, it use my cpu to render videos, it take long time to do this job, how i can force ffmpeg use my gpu to render? i have a mac os with AMD Radeon R9 M370X 2048 MB Graphic card. what i must install and what command i must use for this work? i use this commands when my script run:

    $source_decoder = "ffmpeg -i $film_aval_source -vf drawtext=\"text_shaping=1:fontfile=$font_source:
               text='$esme_film': fontcolor=black: fontsize=$font_size: box=1: boxcolor=black@0:
                boxborderw=0: x=(w-text_w)/2: y=(h-text_h)/2 :enable='between(t,5,10)'\"  -c:a copy -force_key_frames 0:05:00,0:6:00 $film_aval_dest";

    $source_decoder = "ffmpeg -i $film_aval_source -i ".$path."/Data.jpg -filter_complex '[0:v][1:v]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:enable=between(t\,5\,10)' -codec:a copy $film_aval_dest";

    $convert1 = "ffmpeg -i $film_aval_dest -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra ".$path."output1.ts";

    $convert_logo = "ffmpeg -i $path_tmp -i ".$main_path."/data/logo.png -filter_complex 'overlay=4:4' -codec:a copy $path_tmp2";

    $convert2 = "ffmpeg -i $path_tmp2 -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra ".$path."output2.ts";
    $merge = "ffmpeg -i 'concat:".$path."output1.ts|".$path."output2.ts' -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra ".$path."output_new.ts";
    $convert3 = "ffmpeg -i  ".$path."output_new.ts -acodec aac -vcodec copy ".$path."video_out2.mp4";

thanks

like image 575
Soroush Tayyebi Avatar asked Oct 01 '18 12:10

Soroush Tayyebi


People also ask

Can FFmpeg use GPU?

FFmpeg with NVIDIA GPU acceleration is supported on all Linux platforms.


1 Answers

For hardware accelerated video encoding on macOS use:

Format Encoder
H.264 -c:v h264_videotoolbox
HEVC/H.265 -c:v hevc_videotoolbox

Example:

ffmpeg -i input.mov -c:v h264_videotoolbox output.mp4
  • For options specific to these encoders see ffmpeg -h encoder=h264_videotoolbox and ffmpeg -h encoder=hevc_videotoolbox.
  • These encoders do not support -crf so you must use -b:v to set the bitrate, such as -b:v 6000k.
like image 137
llogan Avatar answered Nov 15 '22 08:11

llogan