example code for re-stream

Useful and helpful Windows specific command line samples and examples.
Post Reply
samlolol
Posts: 1
Joined: Sun Sep 17, 2017 2:53 pm

example code for re-stream

Post by samlolol » Sun Sep 17, 2017 2:55 pm

hello.
i try to re-stream hls >> rtmp
i found this code -

Code: Select all

ffmpeg -i "http://hls.com/example.m3u8" -ar 44100 -vcodec libx264 -r 25 -b:v 500k -f flv "rtmp://rtmp.com/stream";
its work great except the quality..
the original stream is HD but after i stream that i get so bad quality
can someone give me a code for restreaming not lose the orginal stream qaulity?
~thanks! :)

navilor
Posts: 44
Joined: Thu May 12, 2011 5:19 pm

Re: example code for re-stream

Post by navilor » Mon Nov 06, 2017 12:08 am

Your bitrate is really low and you are not specifying an audio codec.

Code: Select all

ffmpeg -i "http://hls.com/example.m3u8" -ar 44100 -vcodec libx264 -r 25 -b:v 500k -f flv "rtmp://rtmp.com/stream"
Never I never trust my input. This would be an example for you to look at as a base for creating a better bitrate and command line that conforms to streaming media specifications. You will need to adjust the command line below to accommodate for your needs.

Code: Select all

ffmpeg -i inputfile.mp4 -pix_fmt yuv420p -vsync 1 -vcodec libx264 -r 25 -vf "scale=640:360" -threads 0 -b:v: 1024k -bufsize 1220k -maxrate 1280k -preset medium -profile:v high -tune film -g 50 -x264opts no-scenecut -acodec aac -b:a 192k -ac 2 -ar 44100 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -f mp4 -y outputfile.mp4
or for restreaming your HLS source to RTMP:

Code: Select all

ffmpeg -i http://hls.com/example.m3u8 -pix_fmt yuv420p -vsync 1 -vcodec libx264 -r 25 -vf "scale=640:360" -threads 0 -b:v: 1024k -bufsize 1220k -maxrate 1280k -preset medium -profile:v high -tune film -g 50 -x264opts no-scenecut -acodec aac -b:a 192k -ac 2 -ar 44100 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -f flv rtmp://rtmp.com/stream
If you do trust your input then why are you encoding the output? If you want the same parameters as the original then just pass through everything.

Code: Select all

ffmpeg -i http://hls.com/example.m3u8 -codec copy -f flv rtmp://rtmp.com/stream
You also do not need to use quotes unless you have spaces in your filenames, paths, or filters.

Post Reply