SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Github Development
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Github Development Discussion related to SageTV Open Source Development. Use this forum for development topics about the Open Source versions of SageTV, hosted on Github.

Reply
 
Thread Tools Search this Thread Display Modes
  #181  
Old 10-25-2022, 05:31 PM
CptKirk CptKirk is offline
Sage Aficionado
 
Join Date: Sep 2010
Posts: 268
Started testing with the following batch file. Nothing fancy added. Just used the basics commands from the nvidia docs for nvenc, copied the audio and do each of the seven presets (using only the first 2 minutes of the show to make testing faster).

Used a 1-hour .ts file recorded on my system "Bones - S06E18 - The Truth in the Myth - 3342227-0.ts" renamed to Original.ts.

Using your x64 1.2.2 (built from ffmpeg 4.4.2) from github.

Code:
C:\Tmp\SageTV\SageTVTranscoder.exe -hwaccel cuda -hwaccel_output_format cuda -t 00:02:00 -i C:\Tmp\SageTV\Original.ts -c:a copy -c:v h264_nvenc -preset p1 C:\Tmp\SageTV\P1.mp4
C:\Tmp\SageTV\SageTVTranscoder.exe -hwaccel cuda -hwaccel_output_format cuda -t 00:02:00 -i C:\Tmp\SageTV\Original.ts -c:a copy -c:v h264_nvenc -preset p2 C:\Tmp\SageTV\P2.mp4
C:\Tmp\SageTV\SageTVTranscoder.exe -hwaccel cuda -hwaccel_output_format cuda -t 00:02:00 -i C:\Tmp\SageTV\Original.ts -c:a copy -c:v h264_nvenc -preset p3 C:\Tmp\SageTV\P3.mp4
C:\Tmp\SageTV\SageTVTranscoder.exe -hwaccel cuda -hwaccel_output_format cuda -t 00:02:00 -i C:\Tmp\SageTV\Original.ts -c:a copy -c:v h264_nvenc -preset p4 C:\Tmp\SageTV\P4.mp4
C:\Tmp\SageTV\SageTVTranscoder.exe -hwaccel cuda -hwaccel_output_format cuda -t 00:02:00 -i C:\Tmp\SageTV\Original.ts -c:a copy -c:v h264_nvenc -preset p5 C:\Tmp\SageTV\P5.mp4
C:\Tmp\SageTV\SageTVTranscoder.exe -hwaccel cuda -hwaccel_output_format cuda -t 00:02:00 -i C:\Tmp\SageTV\Original.ts -c:a copy -c:v h264_nvenc -preset p6 C:\Tmp\SageTV\P6.mp4
C:\Tmp\SageTV\SageTVTranscoder.exe -hwaccel cuda -hwaccel_output_format cuda -t 00:02:00 -i C:\Tmp\SageTV\Original.ts -c:a copy -c:v h264_nvenc -preset p7 C:\Tmp\SageTV\P7.mp4
The first three encoded with no problems. Here is the output of P1. P2 and P3 basically look the same.

Code:
C:\Tmp\SageTV>C:\Tmp\SageTV\SageTVTranscoder.exe -hwaccel cuda -hwaccel_output_format cuda -t 00:02:00 -i C:\Tmp\SageTV\Original.ts -c:a copy -c:v h264_nvenc -preset p1 C:\Tmp\SageTV\P1.mp4
ffmpeg version SageTVTranscoder_v1.2.2_from_FFmpeg_v4.4.2 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8.3-win32 (GCC) 20190406
  configuration: --arch=x86 --target-os=mingw64 --cross-prefix=x86_64-w64-mingw32- --enable-libx264 --enable-libx265 --enable-dxva2 --enable-nvenc --enable-cuvid --enable-cuda --disable-ffplay --disable-ffprobe --enable-gpl --enable-static --pkg-config='pkg-config --static' --disable-shared --disable-devices --disable-bzlib --disable-demuxer=msnwc_tcp --extra-cflags='-static -I./pkgconfig/include -lstdc++ -lpthread' --extra-ldflags='-static -L./pkgconfig/lib -static-libgcc -static-libstdc++'
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
[h264 @ 0000000002655fc0] Increasing reorder buffer to 2
[h264 @ 0000000002655fc0] Increasing reorder buffer to 3
Input #0, mpegts, from 'C:\Tmp\SageTV\Original.ts':
  Duration: 01:00:01.89, start: 25198.280433, bitrate: 3719 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0.0[0x100]: Video: h264, yuv420p, 1280x720, 1001/60000, AR: 16:9, progressive, Closed Captions, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0.1[0x101](eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s
File 'C:\Tmp\SageTV\P1.mp4' already exists. Overwrite? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_nvenc))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0000000002fbe800] track 1: codec frame size is not set
Output #0, mp4, to 'C:\Tmp\SageTV\P1.mp4':
    Stream #0.0: Video: h264, cuda, 1280x720, 1001/60000, AR: 16:9, progressive, q=2-31, 2000 kb/s, 59.94 fps, 60k tbn
    Side data:
      cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: N/A
    Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s
frame= 7259 fps= 57 q=31.0 Lsize=  196817kB time=0.010 bitrate= 447.8kbits/s dup=66 drop=0 speed=28.4x
video:31654kB audio:164570kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.302863%
P4, P5, P6 and P7 all failed with "No decoder surfaces left" once the encode tried to start.

Code:
C:\Tmp\SageTV>C:\Tmp\SageTV\SageTVTranscoder.exe -hwaccel cuda -hwaccel_output_format cuda -t 00:02:00 -i C:\Tmp\SageTV\Original.ts -c:a copy -c:v h264_nvenc -preset p4 C:\Tmp\SageTV\P4.mp4
ffmpeg version SageTVTranscoder_v1.2.2_from_FFmpeg_v4.4.2 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8.3-win32 (GCC) 20190406
  configuration: --arch=x86 --target-os=mingw64 --cross-prefix=x86_64-w64-mingw32- --enable-libx264 --enable-libx265 --enable-dxva2 --enable-nvenc --enable-cuvid --enable-cuda --disable-ffplay --disable-ffprobe --enable-gpl --enable-static --pkg-config='pkg-config --static' --disable-shared --disable-devices --disable-bzlib --disable-demuxer=msnwc_tcp --extra-cflags='-static -I./pkgconfig/include -lstdc++ -lpthread' --extra-ldflags='-static -L./pkgconfig/lib -static-libgcc -static-libstdc++'
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
[h264 @ 0000000002695fc0] Increasing reorder buffer to 2
[h264 @ 0000000002695fc0] Increasing reorder buffer to 3
Input #0, mpegts, from 'C:\Tmp\SageTV\Original.ts':
  Duration: 01:00:01.89, start: 25198.280433, bitrate: 3719 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0.0[0x100]: Video: h264, yuv420p, 1280x720, 1001/60000, AR: 16:9, progressive, Closed Captions, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
    Stream #0.1[0x101](eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_nvenc))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0000000002ffe800] track 1: codec frame size is not set
Output #0, mp4, to 'C:\Tmp\SageTV\P4.mp4':
    Stream #0.0: Video: h264, cuda, 1280x720, 1001/60000, AR: 16:9, progressive, q=2-31, 2000 kb/s, 59.94 fps, 60k tbn
    Side data:
      cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: N/A
    Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s
[h264 @ 000000000271b780] No decoder surfaces left010 bitrate=   0.3kbits/s dup=66 drop=0 speed=27.8x
[h264 @ 000000000271eac0] No decoder surfaces left
[h264 @ 0000000002803f40] No decoder surfaces left
Error while decoding stream #0:0: Invalid data found when processing input
    Last message repeated 1 times
[h264 @ 000000000271b780] No decoder surfaces left
Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0
Conversion failed!
I am going to have to dig into the error and see if there is a way to get around it.

Since SageTV queue's up shows to encode and does them one after the other this error might end up happening if used.
__________________
SageTV running on: Win10 21H2
SageTV 9.2.6.976 (64 bit)
Java 1.8.0 311 (64 bit)
OpenDCT 0.5.32 (64 bit)
Clients: HD300 (x2)
HDHR3-CC Prime 20220822 (Comcast CableCard) - 3 Tuners
HDFX-4K Flex 20220822 (OTA) - 4 Tuners
Reply With Quote
  #182  
Old 10-25-2022, 06:36 PM
CptKirk CptKirk is offline
Sage Aficionado
 
Join Date: Sep 2010
Posts: 268
In regards to the "No decoder surfaces left" error.

I found folks mentioning it in nvidia and ffmpeg forums.

The recommendation was to use -extra_hw_frames to add more buffers. To start with 2 and increase until the "No decoder surfaces left" error stopped.

-extra_hw_frames 2, still get "No decoder surfaces left" error starting with P4.
-extra_hw_frames 4, still get "No decoder surfaces left" error starting with P4.
-extra_hw_frames 6, get a completely new error starting with P1.

Code:
[h264 @ 0000000002bfe940] decoder->cvdl->cuvidCreateDecoder(&decoder->decoder, params) failed -> CUDA_ERROR_INVALID_VALUE: invalid argument
[h264 @ 0000000002bfe940] Using more than 32 (33) decode surfaces might cause nvdec to fail.
[h264 @ 0000000002bfe940] Try lowering the amount of threads. Using 13 right now.
[h264 @ 0000000002bfe940] Failed setup for format cuda: hwaccel initialisation returned error.
At that point, it continues on with the encode, but since the nvidia part crashed it does the encode only using the CPU.

I can check that by opening Task Manager, Performance tab, clicking on the NVidia graphics card. When NVENC is being used the NVidia graphics card is running at 95% to 100%.

That's all for tonight. Will try to investigate some more tomorrw.
__________________
SageTV running on: Win10 21H2
SageTV 9.2.6.976 (64 bit)
Java 1.8.0 311 (64 bit)
OpenDCT 0.5.32 (64 bit)
Clients: HD300 (x2)
HDHR3-CC Prime 20220822 (Comcast CableCard) - 3 Tuners
HDFX-4K Flex 20220822 (OTA) - 4 Tuners
Reply With Quote
  #183  
Old 10-27-2022, 04:08 PM
CptKirk CptKirk is offline
Sage Aficionado
 
Join Date: Sep 2010
Posts: 268
So I got NVidia hardware encoding working, but not with the 100% optimal solution.

The NVIDIA FFmpeg Transcoding Guide does a great job of outlining how it is done and how to use it. They state the three things recommended for your command line:

Code:
-hwaccel cuda			chooses appropriate hw accelerator
-hwaccel_output_format cuda	keeps the decoded frames in GPU memory
-c:v h264_nvenc			selects the NVIDIA hardware accelerated H.264 encoder
What I found is that using "-hwaccel_output_format cuda" always ends up with the "No decoder surfaces left" error.

So I just left it out. That means that the decoded raw frames would be copied back to system memory via the PCIe bus. Later, the same image would be copied back to GPU memory via the PCIe bus to encode on the GPU. This adds a little bit of latency.

Maybe I will post this as a bug on the FFmpeg site and give them my sample file, who knows it could be fixed.

Which I have found odd in that my NVidia 2070 has 8GB of dedicated video memory, and another 8GB of shared system memory to use. When I do a transcode I can see in the task manager that the NVidia 2070 only uses a max of 0.3GB of graphics video memory.

So why it keeps choking on keeping the decoded frames in GPU memory is a mystery.

Command line I used:
Code:
SageTVTranscoder.exe -y -hide_banner -hwaccel cuda -i Original.ts -c:a copy -c:v h264_nvenc -preset p1 P1.mp4
I am going to start testing through all of the 7 new presets and record the encode time, file size, and my subjective evaluation of quality.

I am also going to compare it with the latest FFmpeg v5.1.2 that I downloaded from the FFmpeg site. To see if there are any differences between it and Josh's SageTVTranscoder v1.2.2_from_FFmpeg_v4.4.2.

I will most likely create a new forum post with my results and will also put together the Transcoding Profiles I will use in SageTV.
__________________
SageTV running on: Win10 21H2
SageTV 9.2.6.976 (64 bit)
Java 1.8.0 311 (64 bit)
OpenDCT 0.5.32 (64 bit)
Clients: HD300 (x2)
HDHR3-CC Prime 20220822 (Comcast CableCard) - 3 Tuners
HDFX-4K Flex 20220822 (OTA) - 4 Tuners
Reply With Quote
  #184  
Old 02-18-2023, 11:58 AM
nyplayer nyplayer is offline
SageTVaholic
 
Join Date: Sep 2005
Posts: 4,997
Code:
Transcode MP4

transcoder/formats/mp4-H264fast\ mp4=f\=mp4;MCompressionDetails\=-preset fast -c\:v libx264;
transcoder/formats/mp4-H264faster\ mp4=f\=mp4;MCompressionDetails\=-preset faster -c\:v libx264;
transcoder/formats/mp4-H264Medium\ mp4=f\=mp4;MCompressionDetails\=-preset medium -c\:v libx264;
transcoder/formats/mp4-H264slow\ mp4=f\=mp4;MCompressionDetails\=-preset slow -c\:v libx264;
transcoder/formats/mp4-H264slower\ mp4=f\=mp4;MCompressionDetails\=-preset slower -c\:v libx264;
transcoder/formats/mp4-H264superfast\ mp4=f\=mp4;MCompressionDetails\=-preset superfast -c\:v libx264;
transcoder/formats/mp4-H264veryfast\ mp4=f\=mp4;MCompressionDetails\=-preset veryfast -c\:v libx264;
transcoder/formats/mp4-H264veryslow\ mp4=f\=mp4;MCompressionDetails\=-preset veryslow -c\:v libx264;


Transcode MKV keep audio.

transcoder/formats/MKV-H264fast\ MKV=f\=matroska;MCompressionDetails\=-c copy -preset fast -c\:v libx264;
transcoder/formats/MKV-H264faster\ MKV=f\=matroska;MCompressionDetails\=-c copy -preset faster -c\:v libx264;
transcoder/formats/MKV-H264Medium\ MKV=f\=matroska;MCompressionDetails\=-c copy -preset medium -c\:v libx264;
transcoder/formats/MKV-H264slow\ MKV=f\=matroska;MCompressionDetails\=-c copy -preset slow -c\:v libx264;]
transcoder/formats/MKV-H264slower\ MKV=f\=matroska;MCompressionDetails\=-c copy -preset slower -c\:v libx264;
transcoder/formats/MKV-H264superfast\ MKV=f\=matroska;MCompressionDetails\=-c copy -preset superfast -c\:v libx264;
transcoder/formats/MKV-H264veryfast\ MKV=f\=matroska;MCompressionDetails\=-c copy -preset veryfast -c\:v libx264;
transcoder/formats/MKV-H264veryslow\ MKV=f\=matroska;MCompressionDetails\=-c copy -preset veryslow -c\:v libx264;
transcoder/formats/MKV-Remux\ MKV=f\=matroska;MCompressionDetails\=-c copy;
__________________
Channels DVR UBUNTU Server 2 Primes 3 Connects TVE SageTV Docker with input from Channels DVR XMLTV and M3U VIA Opendct.

Last edited by nyplayer; 04-05-2023 at 10:46 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SageTVTranscoder.exe from 6.5.14 Stuntman SageTV Beta Test Software 2 05-13-2009 08:17 AM
What does SageTVtranscoder.exe do? autoboy SageTV Software 5 04-23-2008 01:55 PM
sagetvtranscoder.exe always at 50% showson1 SageTV Software 3 03-30-2008 01:46 AM
SageTVTranscoder.exe jgsouthard SageTV Beta Test Software 40 11-03-2007 01:13 PM
SageTvTranscoder.exe ?? mike_15 SageTV Software 4 10-21-2007 09:42 PM


All times are GMT -6. The time now is 11:13 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.