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
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?
Trying to add a timestamp for ffmpeg for capture card recoridngs but its not working at all.
ffmpeg -f dshow -rtbufsize 100M -i video="Game Capture HD60 S (Video) (#01)":audio="Game Capture HD60 S (Audio) (#01)" -c:v mpeg2video -q:v 0 -r 29.97 -c:a aac -b:a 192k -threads 12 -flags +ilme+ildct -top 1 -strftime 1 "file-%Y%m%d-%%04d.ts"
The output file is basically just "file-%Y%m%d-%%04d.ts", no dates or times. Any help?
strftime is not a generic option for all muxers; it is specific to a few.
However, you can work around this by using the segment muxer. The segment muxer is meant for when the output needs to be split across, umm.. segments. However, by setting a very large segment time, it effectively will write a single file.
So,
ffmpeg -f dshow -rtbufsize 100M -i video="Game Capture HD60 S (Video) (#01)":audio="Game Capture HD60 S (Audio) (#01)" -c:v mpeg2video -q:v 0 -r 30000/1001 -c:a aac -b:a 192k -threads 12 -flags +ilme+ildct -top 1 -f segment -segment_time 99999 -strftime 1 "file-%Y%m%d-%%04d.ts"
(Set r value to exact representation)
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.
My ffmpeg Option :
ffmpeg -i test.mp4 -max_delay 50000 -map 0:v -map 0:a -c copy -flags:v +global_header -bsf:v h264_mp4toannexb -f ssegment -segment_time 10 -segment_list playlist.m3u8 -segment_format mpegts -initial_offset 10 segment_%05d.ts
if the WIFI, .m3u8 file plays not loading.
if the 3G, the loading takes longer.
my Works :
.m3u8 URL : http://mytest/test/test.m3u8
Simply call this URL into browser
my Question is :
Question 1.
Can I split the HD video in .mp4 smaller capacity .ts files to .m3u8 file through the option of ffmpeg?
Question 2.
.m3u8 when you play there a set way of WIFI and 3G options for ffmpeg?
Answer1: Split your big HD mp4 file to smaller ts segments using ffmpeg command as
ffmpeg -i test.mp4 -max_delay 50000 -map 0 -f segment -segment_time 1 -segment_list_flags live -segment_list_size 6 -segment_wrap 0 -segment_list playlist.m3u8 -segment_format mpegts segment_%05d.ts
Answer2: For playing ts streams on iPad or iPhone devices, transcode it to baseline profile using libx264
ffmpeg -i test.mp4 -max_delay 50000 -map 0 -c copy -c:v libx264 -profile:v baseline -flags -global_header -f segment -segment_time 1 -segment_list_flags live -segment_list_size 6 -segment_wrap 0 -segment_list playlist.m3u8 -segment_format mpegts segment_%05d.ts
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.