VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or Try ConvertXtoDVD and convert all your movies to DVD. Free trial ! :)
+ Reply to Thread
Results 1 to 13 of 13
Thread
  1. Hi since weeks I'm trying to reach best and fast method to transcode Full HD h264 online media source to SD output with no success .
    I'm using rented VPS that have `Intel xeon E3-1240 v5`
    The video transcoding start fast at 1x speed "Im using -r option" but after few seconds it drop to 0.02x with ~ 0.6fps
    Click image for larger version

Name:	Transcoding_H264_Full_HD.jpg
Views:	117
Size:	73.4 KB
ID:	45697
    this is transcoding parameters I use

    Code:
    ffmpeg -re  -i  https://someurl/test.ts  -i  logo.png  -filter_complex "crop=iw:ih-100:iw:-100:keep_aspect=1,scale=w=854:h=480,overlay=x=(main_w-overlay_w)-20:y=40" -bufsize 1216k -c:v libx264 -preset ultrafast -qscale 0 -vb 290k -c:a aac -ab 35k -f flv "rtmp://rtmp-api.facebook.com:80/rtmp/ssssssssssss"
    do I need to add/remove any more tweaking codes , and do you thing is't CPU throttling (form my host ) prevent me from having needed CPU resource ?
    Quote Quote  
  2. Are you able to run same command on local computer (you can redirect output to null or file)?
    Quote Quote  
  3. Running that ffmpeg command line with local files (input and output on SSD), I get about 25 fps. For a quick comparison, I ran a similar encoding using AviSynth (same crop, resize, overlay) and the x264 cli encoder (no audio handling) and it encoded at 93 fps. Using the veryfast preset instead of ultrafast encoded at 91 fps and gave much better quality.
    Quote Quote  
  4. Originally Posted by jagabo View Post
    Running that ffmpeg command line with local files (input and output on SSD), I get about 25 fps. For a quick comparison, I ran a similar encoding using AviSynth (same crop, resize, overlay) and the x264 cli encoder (no audio handling) and it encoded at 93 fps. Using the veryfast preset instead of ultrafast encoded at 91 fps and gave much better quality.
    With '-re' processing is performed with native frame speed - such framerate encoding drop as described by OP means probably some issue - not sure if VBV bufer size and expected bitrate are unrealistic and they forcing some weird libx264 behaviour . I saw some strange behaviour on virtual machines with real time processing and IMHO they are (VM) not reliable unless specially configured.
    Quote Quote  
  5. I'm doing rebroadcasting of live stream my current home connection can't allow me to do the same commands (since I only have 1Mbit Internet connection ),
    My suspension is on Video filter I use could increase CPU usage or the VPS single Virtual cores , didn't have the power to handle Full HD stream (even I face same problem with SD stream now ) frame rate dropped a lot
    This is my last code :-
    ffmpeg -thread_queue_size 2612 -re -i https://someurl/test.ts -i /root/small.png \
    -filter_complex crop=iw:ih-33:iw:-33:keep_aspect=1,scale=w=854:h=480,overlay=x=(main _w-overlay_w):y=(main_w-overlay_w)-12 \
    -x264-params nal-hrd=cbr -vb 280k -minrate 280k -maxrate 280k -bufsize 300k -c:v libx264 -c:a aac -ab 38k -ar 44100 -f flv rtmp://localhost/hls/live
    Here I tried my best decres CPU usage
    BTW I have tow VPS do you agree with the idea that I do video filter on first VPS and send the output to the second one (VIA Nginx RTMP ) , to reduce CPU usage .
    I ran a similar encoding using AviSynth (same crop, resize, overlay) and the x264 cli encoder (no audio handling) and it encoded at 93 fps. Using the veryfast preset instead of ultrafast encoded at 91 fps and gave much better quality.
    thanks for the value info , I didn't try AviSynth before even x264 directly , my VPS uses Linux Debian 64bit with 512MB of RAM I don't know if these tools runs the same way on Linux

    --- Update I completely remove all video filters and the transcoding continued for ~ half hour with no frame dropping

    Click image for larger version

Name:	VPS_CPU_USAGE_H264_Low.png
Views:	42
Size:	20.0 KB
ID:	45710

    This is my code and ffmpeg output
    root@:~# ffmpeg -thread_queue_size 2612 -re -i http://someurl/test.ts -x264-params "nal-hrd=cbr" -vb 280k -minrate 280k -maxrate 280k -bufsize 300k -c:v libx264 -c:a aac -ab 38k -ar 44100 -f flv rtmp://localhost/hls/live

    ffmpeg version N-88046-g0cb8369bce-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2017 the FFmpeg developers
    built with gcc 6.4.0 (Debian 6.4.0-8) 20171010
    configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
    libavutil 56. 0.100 / 56. 0.100
    libavcodec 58. 0.100 / 58. 0.100
    libavformat 58. 0.100 / 58. 0.100
    libavdevice 58. 0.100 / 58. 0.100
    libavfilter 7. 0.100 / 7. 0.100
    libswscale 5. 0.100 / 5. 0.100
    libswresample 3. 0.100 / 3. 0.100
    libpostproc 55. 0.100 / 55. 0.100
    Input #0, mpegts, from 'https://someurl/test.ts':
    Duration: N/A, start: 9655.635011, bitrate: N/A
    Program 1
    Metadata:
    service_name : Service01
    service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 640x360 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 73 kb/s
    Stream mapping:
    Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
    Stream #0:1 -> #0:1 (aac (native) -> aac (native))
    Press [q] to stop, [?] for help
    [libx264 @ 0x52ed2c0] using SAR=1/1
    [libx264 @ 0x52ed2c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
    [libx264 @ 0x52ed2c0] profile High, level 3.0
    [libx264 @ 0x52ed2c0] 264 - core 152 r19 ba24899 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=cbr mbtree=1 bitrate=280 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=280 vbv_bufsize=300 nal_hrd=cbr filler=1 ip_ratio=1.40 aq=1:1.00
    Output #0, flv, to 'rtmp://localhost/hls/live':
    Metadata:
    encoder : Lavf58.0.100
    Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p(progressive), 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 280 kb/s, 25 fps, 1k tbn, 25 tbc
    Metadata:
    encoder : Lavc58.0.100 libx264
    Side data:
    cpb: bitrate max/min/avg: 280000/0/280000 buffer size: 300000 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, 38 kb/s
    Metadata:
    encoder : Lavc58.0.100 aac
    frame= 7205 fps= 25 q=34.0 size= 11488kB time=00:04:48.01 bitrate= 326.7kbits/s speed=0.999x
    Quote Quote  
  6. cbr is not a good idea IMHO, focus on quality and guide encoder to limit peak bitrate - it looks like crf should be around 28 - 32 to match expected bitrate - quality will be low but... not sure about specified thread buffer size - this is Kib or something else? native aac has some limitations. filters in ffmpeg are mostly single thread type... they may be explanation of the slow encoding - particularly overlay may be an issue - check color space, perhaps you can use https://www.ffmpeg.org/ffmpeg-filters.html#movie-1 instead two inputs, you may try to experiment with threading type.
    Quote Quote  
  7. Originally Posted by pandy View Post
    Originally Posted by jagabo View Post
    Running that ffmpeg command line with local files (input and output on SSD), I get about 25 fps. For a quick comparison, I ran a similar encoding using AviSynth (same crop, resize, overlay) and the x264 cli encoder (no audio handling) and it encoded at 93 fps. Using the veryfast preset instead of ultrafast encoded at 91 fps and gave much better quality.
    With '-re' processing is performed with native frame speed.
    Ah, I see. The goal is to have real time processing, not faster or slower.

    Removing the realtime constraint, ffmpeg ran the full command line at 150 fps. 130 fps with veryfast instead of ultrafast. So the processing in ffmpeg isn't the problem.

    I thought the problem might have something to do with source frames being read out-of-order. But that doesn't seem likely since the ultrafast preset uses no b-frames and only one reference frame.
    Last edited by jagabo; 23rd May 2018 at 21:54.
    Quote Quote  
  8. Originally Posted by pandy View Post
    Are you able to run same command on local computer (you can redirect output to null or file)?
    I use the first on my laptop ant reach 0.43x after few minutes
    Click image for larger version

Name:	OnMyLaptop.png
Views:	101
Size:	81.3 KB
ID:	45712

    when I use my second code it drooped to 0.74x with 16% CPU usage
    Code:
    ffmpeg -thread_queue_size 2612 -re -i https://someurl/test.ts -i small.png \
    -filter_complex crop=iw:ih-33:iw:-33:keep_aspect=1,scale=w=854:h=480,overlay=x=(main _w-overlay_w):y=(main_w-overlay_w)-12 \
    -x264-params nal-hrd=cbr -vb 280k -minrate 280k -maxrate 280k -bufsize 300k -c:v libx264 -c:a aac -ab 38k -ar 44100 -f flv NULL
    Originally Posted by pandy View Post
    cbr is not a good idea IMHO, focus on quality and guide encoder to limit peak bitrate - it looks like crf should be around 28 - 32 to match expected bitrate - quality will be low but... not sure about specified thread buffer size - this is Kib or something else? native aac has some limitations.
    cbr is the only parameter that gived me better pic quality and less CPU usage I didn't try cfr alone before (without bitrate )
    removing the audio didn't solve the issue (I tried with -c:a copy ) and didn't even decrease CPU usage either .

    Originally Posted by pandy View Post
    filters in ffmpeg are mostly single thread type... they may be explanation of the slow encoding - particularly overlay may be an issue - check color space, perhaps you can use https://www.ffmpeg.org/ffmpeg-filters.html#movie-1 instead two inputs, you may try to experiment with threading type.
    But not with my laptop CPU (core i5 3210m) I test it with the SD source and cpu usage were ~16% only .
    I didn't try Movie filter method yet as I din't see many people use it before , but I'll give it try .
    Quote Quote  
  9. Where is https://someurl/test.ts from ? Your local home connection to the VPS ?

    Maybe your bottleneck is your 1Mbit bandwidth. Next, test a local file input instead of https, locally on your laptop
    Quote Quote  
  10. Originally Posted by poisondeathray View Post
    Where is https://someurl/test.ts from ? Your local home connection to the VPS ?
    Maybe your bottleneck is your 1Mbit bandwidth. Next, test a local file input instead of https, locally on your laptop
    It's from live video source from Internet it has 600 kbs bitrate ,, anyway I did like what you said when I use local file framerate didn't drops at all it at 1x all the time even I notice q value showed on ffmpeg command at 29.0 , CPU usage were at 25% (I was keep Opera browser open while encoding )
    Click image for larger version

Name:	NULL.png
Views:	30
Size:	63.0 KB
ID:	45713
    Quote Quote  
  11. Likely you have bandwidth bottleneck. You can't really do anything in terms of hardware, or commandline, or even expensive VPS for that - it won't help since that's not the problem. It has more to do with the "live video source" bandwidth - it's not feeding your laptop or the VPS fast enough

    You can also test VPS, with another URL (a fast server) to rule out VPS bandwidth issue. (But it' s unlikely)

    In the 1st post it said "Full HD h264" online media, was that 600kbps too ? Pretty low bitrate for "Full HD"
    Quote Quote  
  12. Originally Posted by poisondeathray View Post
    . It has more to do with the "live video source" bandwidth - it's not feeding your laptop or the VPS fast enough
    In the 1st post it said "Full HD h264" online media, was that 600kbps too ? Pretty low bitrate for "Full HD"
    My VPS have no network issue I reach 20MB/s download speed and it have 100Mbit/s upload line , - I have two sources one with ~ 5Mbits bitrate speed (The Full HD) and the other source with ~600Kbit/s (SD ) and I don't think the source dropping connection as I was able to download the SD source with my home connection (IDM) and the file were played with correct framerate .
    Lat CPU usage on my VPS was always at 100% when I use filter (both codes) but when I use the transcoding without any filters I was able to continue the transcoding for more then hour with few dropping farms from time to time (I guess that from the source ) since my VPS CPU usage were less than 50% .
    Quote Quote  
  13. Where is someurl ? Where is the live stream being sent from?

    Laptop some url => 11fps
    Laptop local file => 25fps no drop. Perfect.

    Both same commandline, same hardware otherwise

    This means problem is the source "some url" bandwidth either server up , or down for you locally . At least for your laptop.


    Lat CPU usage on my VPS was always at 100% when I use filter (both codes) but when I use the transcoding without any filters I was able to continue the transcoding for more then hour with few dropping farms from time to time (I guess that from the source ) since my VPS CPU usage were less than 50% .
    Then the VPS is also bottleneck if it's pegged at 100%. Pay for a better VPS. Pay for better service, or complain to the host

    But if you are using "some url" to feed the VPS, then it has 2 bottlenecks
    Quote Quote  



Similar Threads