1

Hi I have some questions regarding NVENC, DVB subs and overlay feature.

I managed to burn dvb subtitles to the input video but I noticed that this cannot be performed fully on the GPU because I am using the Overlay feature of FFMPEG which is only possible with software.

Current code Scales the subtitles to 1920x1080 before applying the overlay. I noticed that this uses more CPU than just overlaying the subtitles directly over the video. The problem is that I want to overlay the subtitles in the center bottom. Current code centers the subtitles in the center of the screen (kinda annoying)

Eventually I would like a full hw transcode option (guess it's not possible? is it)

I would like the subtitles unscaled in the center bottom (cpu load 50% less) I would like the subtitles scaled 50% in the center bottom (cpu load 30% less) this makes the subtitles better readable.

Current code for subtitles scaled to video size (how to full hw transcode?):

Code subtitle unscaled but centered. How to change to center bottom:

-hwaccel_device 4 -hwaccel cuvid -vcodec h264_cuvid -resize 1920x1080 -deint 2 -drop_second_field 1 -i 'http://stream' -filter_complex "[i:0x1389]hwdownload,format=nv12[base];[base][i:0x13ee]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2[v];[v]hwupload_cuda[k]" -map "[k]" -map i:0x1393 -acodec libfdk_aac -b:a 96k -c:v h264_nvenc -gpu 4 -preset llhq -vprofile high -rc:v vbr -qmin:v 26 -qmax:v 32 -b:v 4M -maxrate 4M -bufsize 8M -threads 0 -r 25 -g 100 -f flv 'rtmp://127.0.0.1:8001/input/nvenctest.stream'

ffprobe output:

[mpegts @ 0x3786200] sub2video: using 1920x1080 canvas
[Parsed_showinfo_0 @ 0x3785340] config in time_base: 1/90000, frame_rate: 0/1
[Parsed_showinfo_0 @ 0x3785340] config out time_base: 0/0, frame_rate: 0/0
No information about the input framerate is available. Falling back to a default value of 25fps for output stream #0:0. Use the -r option if you want a different framerate.
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf58.3.100
    Stream #0:0: Video: wrapped_avframe, bgra, 1920x1080, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.9.100 wrapped_avframe
[Parsed_showinfo_0 @ 0x3785340] n:   0 pts:      0 pts_time:0       pos:       -1 fmt:bgra sar:0/1 s:1920x1080 i:P iskey:1 type:? checksum:00000000 plane_checksum:[00000000] mean:[0] stdev:[0.0]
[Parsed_showinfo_0 @ 0x3785340] n:   1 pts:      0 pts_time:0       pos:       -1 fmt:bgra sar:0/1 s:1920x1080 i:P iskey:1 type:? checksum:00000000 plane_checksum:[00000000] mean:[0] stdev:[0.0]
[Parsed_showinfo_0 @ 0x3785340] n:   2 pts:  39599 pts_time:0.439989 pos:       -1 fmt:bgra sar:0/1 s:1920x1080 i:P iskey:1 type:? checksum:00000000 plane_checksum:[00000000] mean:[0] stdev:[0.0]
[graph 0 input from stream 0:2 @ 0x37c9340] Changing frame properties on the fly is not supported by all filters.
Segmentation fault (core dumped)
Sambir
  • 129
  • 1
  • 3
  • 15

1 Answers1

2

To reposition the scaled subtitles, supply x & y exprs: overlay=x=0:y=H/2

To reposition the unscaled subtitles, overlay=x=(W-w)/2:y=H-h-20.

A OpenCL overlay filter is available, but it won't provide much benefit as the subtitle stream still has to be decoded in software, and the upload/download steps will take up resources.

Gyan
  • 85,394
  • 9
  • 169
  • 201
  • Ok i tried both commands. the first command puts the subtitle in the left lower corner (unscaled) the second scales the subtitle and put's it in the right spot but I dont want it to be scaled... – Sambir Jun 27 '18 at 10:08
  • The first command is for scaled subtitles, not unscaled. See the order in your Q. – Gyan Jun 27 '18 at 16:59
  • I haven't added any scale filters. There are either present or not in your original commands. You need to check your commands for them. – Gyan Jun 27 '18 at 18:42
  • `ffprobe stream 2> textfile` – Gyan Jun 27 '18 at 19:00
  • Not enough info, run `ffmpeg -i stream -filter_complex "[i:0x1196]showinfo" -t 10 -vn -an -sn -dn -f null - -report` and link to the report. – Gyan Jun 27 '18 at 19:09
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/173914/discussion-between-sambir-and-gyan). – Sambir Jun 27 '18 at 19:27
  • I changed the Q – Sambir Jun 27 '18 at 19:40
  • It's the same res as the video. You shouldn't need to scale it. – Gyan Jun 27 '18 at 19:48
  • I want to downscale the video to 720p and add subs but it keeps showing this: '[mpegts @ 0x3786200] sub2video: using 1920x1080 canvas' Maybe that is the reason? – Sambir Jun 27 '18 at 19:54
  • Shouldn't be a problem; scale filter operates after the MPEG-TS demuxer. – Gyan Jun 27 '18 at 19:58
  • hmm ok. Well on some channels the subs are sd and when i upscale it it is centered fine by just applying overlay filter without any extra stuff. but then it uses more cpu since it is scaled to the main video resolution. Not a big issue im fine with that for now. but this channel the subtitles are somehow not centered but on alligned to the left. On tv, it is centered fine but after encoding it is not. – Sambir Jun 27 '18 at 20:04
  • https://ibb.co/nfC39o please have a look at the screenshot. It is on the left of the screen and not cented. the text just is directly underneath eachother... – Sambir Jun 27 '18 at 20:17
  • I tested it with vlc and this shows the same result for the raw input i guess the tv has some smart algoritm to center the subs correctly. On some channels subs are SD and when scaled they are centered correctly but this channel the subs are in HD already and strangly not centered correctly bu ffmpeg nor vlc. – Sambir Jun 27 '18 at 20:29