I have setup a HLS live stream on AWS. Significant part of the video plays as expected but in some portions audio is lost while the video continues to play. Please share you thoughts/insights if you have faced such an issue.
I transcode video to h264, baseline3.1 and audio to aac stereo 2 channels before segmenting to 10s files. Following commands are being used:
Transcoding:
ffmpeg -y -i ${file_path} -b:v ${vBitrate} -minrate ${vBitrate} -maxrate ${vBitrate} -c:v libx264 -b:a ${aBitrate} -c:a libfaac -ac 2 -r 25 -s ${resolution} -profile:v baseline -level 3.1 ${output_dir}/${file_name}.ts
Ex: vBitrate: 1m, aBirate: 128k, resolution: 960x540
Splittting:
ffmpeg -i ${file_path} -c:v copy -c:a copy -flags -global_header -map 0 -f segment -segment_time ${segment} -segment_list ${output_dir}/playlist.m3u8 -segment_format mpegts tmp0/${file_name}_%02d.ts
Ex: segment: 10
Setup: segments are being served from Nginx and playlist is managed by a Python/Flask app.
Related
I'm trying to re-stream an M3U8 stream to an rtmp server but I'm often seeing this:
Skipping 1 segments ahead, expired from playlists
This causes the output stream playback to pause and lag after a while.
I'm using the following ffmpeg command:
ffmpeg -stream_loop -1 -thread_queue_size 8192 -i http://demo.m3u8 -c:a aac -c:v h264 -ar 44100 -vf scale=640:-1 -hide_banner -bf 0 -pix_fmt yuv420p -vprofile baseline -preset superfast -segment_list_flags live -segment_list_size 300 -segment_time 300 -hls_list_size 300 -hls_time 300 -flvflags no_duration_filesize -f flv rtmp://myserver
Is there a way to prevent this issue to ensure a smooth playback?
I have a program coded in python that will downloads and output h264 video and audio files every 6 seconds.
Each h264 video audio is a 10 second segment.
so basically, every 6 seconds new video.h264 and auio.h264 file replaces with video.h264 and auio.h264 file
My goal here is to create a hls playlist with these downloaded h264 files
I am using ffmpeg to transcode these h264 files and convert them into hls playlist but there is a problem here.
The playlist stops once after the first h264 video finishes. m3u8 is not fetching the next .ts which is created by ffmpeg. How do i make the hls playlist keeps on playing the .ts files and works like a live streaming ?
ffmpeg -i video.h264 -i audio.h264 -loglevel info -c:v libx264 -c:a aac -ac 1 -strict -2 -r 25 -crf 23 -profile:v baseline -preset:v ultrafast -maxrate 2048k -bufsize 2048k -pix_fmt yuv420p -s 720x576 -flags -global_header -hls_time 10 -hls_list_size 6 -hls_wrap 10 -start_number 1 test.m3u8
Is there a single command to transcode mp4 video + aac into HLS at multiple resolutions ?
I have a convert server, and I think to live stream multiple resolutions, I must create all resolutions at the same time and this process must be concurrent.
I raised this issue,because I do this process wtih running these below codes at 4 cmd seperately for creating 4 resolutions of a video examply at the same time:
1- 720p
ffmpeg -i 123.mp4 -c:a aac -strict experimental -c:v libx264 -s hd720 -aspect 16:9 -f hls -hls_list_size 0 -hls_time 2 720p/out.m3u8
2- 480p
ffmpeg -i 123.mp4 -c:a aac -strict experimental -c:v libx264 -s hd480 -aspect 16:9 -f hls -hls_list_size 0 -hls_time 2 480p/out.m3u8
3- 360p
ffmpeg -i 123.mp4 -c:a aac -strict experimental -c:v libx264 -s nhd -aspect 16:9 -f hls -hls_list_size 0 -hls_time 2 360p/out.m3u8
4- 200p
ffmpeg -i 123.mp4 -c:a aac -strict experimental -c:v libx264 -s cga -aspect 16:9 -f hls -hls_list_size 0 -hls_time 2 200p/out.m3u8
but doing in this way have some problems.
1- the .TS parts of each resolutions doesn't create with another resolutions part at the same time(this issue makes that in switching resolutions, player cannot seek to the continue of selected resolution,because that part doesn't create yet).
2- You have run some threads for each live streaming.
Here is the answer of mine,Note that you must be set -hls_time If you want the number part of each resolutions be same.
ffmpeg -re -i 123.mp4
-c:a aac -c:v libx264 -s hd480 -aspect 16:9 -f hls -hls_list_size 0 -hls_time 2 480p/out.m3u8
-c:a aac -c:v libx264 -s nhd -aspect 16:9 -f hls -hls_list_size 0 -hls_time 2 360p/out.m3u8
-c:a aac -c:v libx264 -s cga -aspect 16:9 -f hls -hls_list_size 0 -hls_time 2 200p/out.m3u8
I am using ffmpeg to create m3u8 playlist for a video (actually a live video stream). I am using the following command:
ffmpeg -i /home/ubuntu/Download/1459530099245.mkv -c:a aac -strict experimental -ac 2 -ar 48k -ab 64k -c:v libx264 -s 480x270 -aspect 16:9 -b:v 400k -r 15 -g 45 -profile:v baseline -level 3.0 -f hls -hls_time 9 -hls_list_size 0 /home/ubuntu/Download/New Playlist.m3u8
It produces m3u8 file as well as ts files.
Question: simply, how can we produce m3u8 playlist and TS files for a particular duration of source video? E.g., I want to get playlist only for first 20 seconds or so?
You can use command -to. Just add -to 00:00:20 after input path
In your variant:
ffmpeg -i /home/ubuntu/Download/1459530099245.mkv -to 00:00:20 -c:a aac -strict experimental -ac 2 -ar 48k -ab 64k -c:v libx264 -s 480x270 -aspect 16:9 -b:v 400k -r 15 -g 45 -profile:v baseline -level 3.0 -f hls -hls_time 9 -hls_list_size 0 /home/ubuntu/Download/New Playlist.m3u8
More information here: http://www.bogotobogo.com/FFMpeg/ffmpeg_seeking_ss_option_cutting_section_video_image.php
I am trying to make a .m3u8 hls playlist locally on my computer. I am using Windows 7, 32 bit.
I am a begginner of FFMPEG, and finally I combined some commands into this:
ffmpeg -re -rtbufsize 999999k -y -f dshow -video_size 640x360 -r 15 -i video="ManyCam Virtual Webcam" -c:v libx264 -crf 18 -profile:v main -maxrate 999999k -bufsize 99999k -pix_fmt yuv420p -flags -global_header -hls_time 10 -g 3 -hls_list_size 2 -hls_wrap 0 -start_number 1 D:\\stream\stream.m3u8 -tune zerolatency
The problem is that while playing the m3u8 playlist with VLC or a HLS player, the video speed is faster than normal.
If you need more info, please comment.
EDIT
If I play one of the .ts files, the problem is the same.
Thank you so much!