I have a ffmpeg command which converts rtmp stream to http live stream:
ffmpeg.exe -loglevel info -i %stream_input% -g 250 -r 15 -sc_threshold 0 -preset slow -keyint_min 15 -c:v libx264 -ar 44100 -b:v 200k -b:a 64k -profile:v baseline -level 3.0 -s 400x224 -aspect 16:9 -maxrate 200k -bufsize 1000k -map 0 -flags -global_header -f segment -segment_time 10 -segment_wrap 3 -segment_list_flags +live -segment_list_type m3u8 -segment_list playlist.m3u8 -segment_format mpegts segment%05d.ts 1>output.txt
This command creates ts files and m3u8 playlist. What I want to do is to keep ts file names same but rename them in the playlist. For example, Segment file: segment00000.ts, in playlist: Segment.aspx?ts=00000
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:17
#EXTINF:16.692244,
segment00000.ts -> Rename it to Segment.aspx?ts=00000
#EXTINF:16.680789,
segment00001.ts
Is it possible with ffmpeg?
I'm assuming you are doing this because you are running a service in front of the server to manage content rights or something. In that case, I would have the server handle the request for the .m3u8 and generate a new one with the filename you are looking for. Its a trivial file format and whatever language your using should be very easily able to do this.
No, it's not possible in ffmpeg. It's fairly trivial to change the way the filenames are generated and recompile it.
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
I've already tried to create HLS stream from a UDP continuous input stream, it was fairly easy, now I want to create a simulated live HLS stream from multiple MP4 sources with ffmpeg, the idea behind it is to be able to create a TV channel with non-live data, so the input must be a loop of non-live data to simulate live stream continuity. I tried to do it with the below command but after the first round, ffmpeg exits with this error:
concat:1.mp4|2.mp4|3.mp4" Resource temporarily unavailable.
ffmpeg command:
ffmpeg -i "concat:1.mp4|2.mp4|3.mp4" -strict experimental -sn -ac 2 -map_metadata -1 -s 720x576 -g 250 -c:v libx264 -pix_fmt yuv420p -flags -global_header -hls_time 10 -hls_list_size 5 -hls_wrap 12 -hls_flags delete_segments -f hls -strftime 1 -segment_time 10 -segment_format mpegts -segment_list_flags +live -hls_allow_cache 0 -segment_wrap 12 -segment_list_size 5 -hls_base_url http://192.168.1.100/0/ -hls_segment_filename /data/0/live_0_%02d.ts /data/0/live_0.m3u8
If anyone has a nice solution to this issue, I would appreciate any input.
Cheers,
Navid
I tried to convert a UDP stream (that genrated from DVB signal) to HLS m3u8 file with this code:
ffmpeg -i udp://239.1.2.1:60001 -acodec aac -strict -2 -vcodec libx264 -hls_wrap 100 -f hls /var/www/html/ts/1.m3u8
and output m3u8 file is :
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:66
#EXTINF:0.960000,
21.ts
#EXTINF:2.080000,
22.ts
#EXTINF:2.400000,
23.ts
#EXTINF:1.760000,
24.ts
#EXTINF:2.080000,
20.ts
I tried to change the target duration to 10 in this file with the option -segment_time 10 but the target duration doesn't change in m3u8 file, can anybody help me with this problem?
I solve this problem with code:
ffmpeg -i udp://239.1.2.4:60004?fifo_size=50000000 -acodec copy -vcodec copy -preset ultrafast -flags -global_header -f hls -hls_time 20 -hls_wrap 5 /var/www/html/ts/4.m3u8
Add this option to ffmpeg fix problem
-preset ultrafast -flags -global_header
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.