2

I try to hardcode the dvb subtitle in the video. I managed to hardcode it but it is still misplaced. The reason for this is that the subtitle is on SD resolution 720x576 while the video is 1920x1080.

So when I use overlay the subtitle is is misplaced and on the left corner.

this is my command:

ffmpeg -canvas_size 1280x720 -y -probesize 5000000 -analyzeduration 5000000 -i http://192.168.2.9:8001 -filter_complex "[0:s]scale=1280:720[sub],[0:v]scale=1280:720,yadif=1[vid];[vid][sub]overlay[all]" -map "[all]" -map a:0 -strict -2 -dn -vcodec h264 -acodec aac -preset superfast -scodec copy -b:v 2000k -b:a 96k -maxrate 3000k -crf 26 -r 25 -ac 2 -threads 0 -hls_flags delete_segments -hls_time 10 -hls_list_size 6 testbst.ts

The subtitle needs to be upscaled and/or placed in the center bottom of the screen. Any help is appreciated.

Sambir
  • 129
  • 1
  • 3
  • 15

2 Answers2

0

Ihad this prolem with subtitles, managed to fix with:

-filter_complex "[0:s:0] scale=-1:2400 [sub],[0:v][sub] overlay=x=150:y=-80"

where:

scale - size of subtitle

overlay x= - vertical

overlay y= - horizontal

Maknol
  • 11
  • 3
  • Great i will try it and let you know the results – Sambir Jun 22 '17 at 08:29
  • For me is working: ffmpeg -i http://192.168.1.238:9099/play/a06n -metadata title="HBO 3 HD" -filter_complex "[0:s:0] scale=-1:2400 [sub],[0:v][sub] overlay=x=150:y=-80" -c:v libx264 -crf 23 -preset veryfast -aspect 16:9 -c:a aac -strict experimental -b:a 192k -flags -global_header -f segment -segment_format mpegts -segment_list_type m3u8 -segment_list /var/www/html/HBO_3.m3u8 -segment_time 5 -segment_list_flags +live -segment_wrap 6 -segment_time 10 /var/www/html/HBO_3-%00d.ts – Maknol Jun 22 '17 at 20:58
  • I tried on versions 3 (all), and on last build of 2 – Maknol Jun 22 '17 at 21:00
  • I get this error and no subtitle is shown: [graph 0 input from stream 0:2 @ 0x5626fa5b5a20] Changing frame properties on the fly is not supported by all filters. – Sambir Jun 23 '17 at 13:01
  • This command I can see the subs again but again in the corner. ffmpeg -y -probesize 5000000 -analyzeduration 5000000 -canvas_size 1920x1080 -i http://192.168.2.9:8001/1:0:19:4B83:815:600:FFFF0000:0:0:0: -map 0:0 -c:v libx264 -crf 23 -preset veryfast -map 0:1 -c:a aac -strict experimental -b:a 96k-map 0:2 -c:s dvdsub test.mkv – Sambir Jun 23 '17 at 13:56
  • Sorry, can't manage to use **-filter_complex** with **-map** option. You can test this one: https://stackoverflow.com/questions/21363334/how-to-add-font-size-in-subtitles-in-ffmpeg-video-filter – Maknol Jun 23 '17 at 21:15
  • Why not? -map option works fine with filter_complex. With the above command i can see subs on the screen but again in small resolution on the corner. Now it needs to be centralized and made bigger. Thats it. – Sambir Jun 25 '17 at 08:41
  • Try: `ffmpeg -i http://localhost:9099/play/a06d -filter_complex "[0:1:v][0:s:0]overlay" -c:v libx264 -crf 23 -preset ultrafast -flags -global_header -f segment -segment_format mpegts -segment_list_type m3u8 -segment_list /var/www/html/HBO2.m3u8 -segment_list_flags +live -segment_wrap 6 -segment_time 10 /var/www/html/%HBO2.ts` but adjust for your steams. Bouth commands for me is working on Ubuntu 14. This one is only hardcore dvb subs, without changing anything and it's fine, the other command is scaling because of ffmpeg libs. – Maknol Jun 26 '17 at 14:23
  • My command is for 1920×1080p, if it's a below that resolution, change **overlay=x=150:y=-80** and remove **scale=-1:2400** for example **overlay=x=50:y=20** (without **-** ) and see where is subtitles picture placed. After that, adapt it to your resolution. – Maknol Jul 03 '17 at 11:39
0

preview.ibb.co/ibNB4k/1.jpg First code

At the first one, subtitles are little bit high, and the code is:

ffmpeg -i http://localhost:9099/play/a07w  -metadata title="Cinemax" -filter_complex "[0:s:0] scale=-1:500 [sub],[0:v][sub] overlay=x=30:y=-10" -c:v libx264 -crf 20 -preset veryfast -aspect 16:9 -c:a aac -strict experimental -b:a 192k -flags -global_header -f segment -segment_format mpegts -segment_list_type m3u8 -segment_list /var/www/html/CINEMAX.m3u8 -segment_time 5 -segment_list_flags +live -segment_wrap 6 -segment_time 10 /var/www/html/CINEMAX-%00d.ts

At second one, subtitles are little low than the first one: https://preview.ibb.co/e6VaVQ/2.jpg Second code

ffmpeg -i http://localhost:9099/play/a07w  -metadata title="Cinemax" -filter_complex "[0:s:0] scale=-1:500 [sub],[0:v][sub] overlay=x=30:y=-1" -c:v libx264 -crf 20 -preset veryfast -aspect 16:9 -c:a aac -strict experimental -b:a 192k -flags -global_header -f segment -segment_format mpegts -segment_list_type m3u8 -segment_list /var/www/html/CINEMAX.m3u8 -segment_time 5 -segment_list_flags +live -segment_wrap 6 -segment_time 10 /var/www/html/CINEMAX-%00d.ts

And the third one they are at the bottom: https://preview.ibb.co/hyZfx5/3.jpg

nohup ffmpeg -i http://localhost:9099/play/a07w  -metadata title="Cinemax" -filter_complex "[0:s:0] scale=-1:500 [sub],[0:v][sub] overlay=x=15:y=80" -c:v libx264 -crf 20 -preset veryfast -aspect 16:9 -c:a aac -strict experimental -b:a 192k -flags -global_header -f segment -segment_format mpegts -segment_list_type m3u8 -segment_list /var/www/html/CINEMAX.m3u8 -segment_time 5 -segment_list_flags +live -segment_wrap 6 -segment_time 10 /var/www/html/CINEMAX-%00d.ts > /dev/null 2>&1

The scale option is for scaling "the font size", and it's depend from video resolution.

The current running and tested version: ffmpeg version 3.3.2-1~14.04.york1 Copyright (c) 2000-2017 the FFmpeg developers

Maknol
  • 11
  • 3