ns-mkusper / direct-play-nice

CLI utility to convert video files to direct-play formats
GNU General Public License v3.0
1 stars 0 forks source link

Lack of GPU-enabled HW transcoding support #9

Open ns-mkusper opened 2 months ago

ns-mkusper commented 2 months ago

FFMPEG has support for GPU transcoding. This project should allow for finding common video codecs that allow for GPU-accelerated transcoding (ie. nvenc) when it satisfies the provided streaming devices.

ns-mkusper commented 1 week ago

GPU Video transcoding has significantly improved over the last 10 years. We can probably expect something similar to this observed 4x performance improvement over CPU transcoding time:

** test.mkv
**** time ~/git/direct-play-nice/target/release/direct_play_nice --streaming-devices=chromecast_1st_gen test.mkv test-dpn.mp4

real    9m12.746s
user    57m26.520s
sys     0m18.424s
-rw-r--r-- 1 mkusper 674M Oct 10 12:44 'test-dpn.mp4'

  Duration: 00:25:49.27, start: 0.000000, bitrate: 3644 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 3508 kb/s, 23.98 fps, 23.98 tbr, 90k tbn (default)
      Metadata:
        handler_name    : Bento4 Video Handler
        vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](jpn): Audio: aac  (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 130 kb/s (default)
      Metadata:
        handler_name    : Bento4 Sound Handler
        vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](eng): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
      Metadata:
        handler_name    : SubtitleHandler
  Stream #0:3[0x4](ind): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s
      Metadata:
        handler_name    : SubtitleHandler
  Stream #0:4[0x5](tha): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s
      Metadata:
        handler_name    : SubtitleHandler
**** GPU ACCEL timeout -s9 -k 5 600m ffmpeg -fix_sub_duration -analyzeduration 200000000 -probesize 200000000 -loglevel verbose -nostdin -hwaccel auto -hwaccel_device 0 -i '/mnt/data1/videos/test.mkv' -map 0:v -map 0:a -c:v h264_nvenc -minrate 4500k -maxrate 16000k -bufsize 32000k -profile:v high -level:v 4.1 -movflags +faststart 
-pix_fmt yuv420p -c:a aac -map 0:s:0 -c:s:0 mov_text -map 0:s:1 -c:s:1 mov_text -map 0:s:2 -c:s:2 mov_text '/mnt/data1/videos/test temp.mp4' -y

real    2m38.154s
user    4m28.732s
sys     0m18.588s
-rw-r--r-- 1 plex    393M Oct 10 12:42 'test fixed.mp4'

  Duration: 00:25:49.27, start: 0.000000, bitrate: 2123 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 1986 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default)
      Metadata:
        handler_name    : Bento4 Video Handler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc61.3.100 h264_nvenc
  Stream #0:1[0x2](jpn): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 130 kb/s (default)
      Metadata:
        handler_name    : Bento4 Sound Handler
        vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](eng): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
      Metadata:
        handler_name    : SubtitleHandler
  Stream #0:3[0x4](ind): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s
      Metadata:
        handler_name    : SubtitleHandler
  Stream #0:4[0x5](tha): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s
      Metadata:
        handler_name    : SubtitleHandler
**** NO GPU ffmpeg -fix_sub_duration -analyzeduration 200000000 -probesize 200000000 -loglevel verbose -nostdin -i test.mkv -map 0:v -map 0:a -minrate 4500k -maxrate 16000k -bufsize 32000k -profile:v high -level:v 4.1 -movflags +faststart -pix_fmt yuv420p -c:a aac -map 0:s:0 -c:s:0 mov_text -map 0:s:1 -c:s:1 mov_text -map 0:s:2 -c:s:2 mov_text '/mnt/data1/videos/test temp.mp4' -y

real    10m27.680s
user    73m43.249s
sys     0m30.566s
-rw-r--r-- 1 mkusper 436M Oct 10 13:32 'test temp.mp4'

  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 2220 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default)
      Metadata:
        handler_name    : Bento4 Video Handler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc61.3.100 libx264
  Stream #0:1[0x2](jpn): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 130 kb/s (default)
      Metadata:
        handler_name    : Bento4 Sound Handler
        vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](eng): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
      Metadata:
        handler_name    : SubtitleHandler
  Stream #0:3[0x4](ind): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s
      Metadata:
        handler_name    : SubtitleHandler
  Stream #0:4[0x5](tha): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s
      Metadata:
        handler_name    : SubtitleHandler