FFMPEG HLS video speed is too fast - ffmpeg

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!

Related

Pushing Live Smooth Streaming multi track audio to Azure Media Services with FFMPEG

Does anyone has a working command line for FFMPEG that shows how to stream audio from multiple devices (sound cards) using Smooth Ingest and a Basic Pass-through channel type (the cheapest option on Azure Media Services)?
The command should allow me to show multiple audio tracks (with language identifiers) using the Azure Media Player demo site (http://ampdemo.azureedge.net).
Appreciate any help.
I have tried many many examples with no success...
I have this example FFMPEG ingest for Smooth that you can try to play with. First, if you are working on Windows, you will want to list all of your DirectShow devices to get the inputs that are available. Otherwise, follow the usual ffmpeg directions for devices on other OS's.
ffmpeg -list_devices true -f dshow -i dummy
Then you can play around with this sample command line and see if you can match up your audio inputs.
Video and Audio with GoPro need to set rtbufsize to large value and I had to play around with the audio offset delay (-itsoffset) to get av sync correct.
ffmpeg -y -hide_banner -f dshow -fflags nobuffer -i audio="Headset Microphone (Logitech Stereo H650e)" -itsoffset 1.00 -f dshow -fflags nobuffer -rtbufsize 2000M -i video="GoPro Webcam" -map 0:0 -map 1:0 -c:a:0 aac -b:a:0 192k -c:v:1 libx264 -preset ultrafast -tune zerolatency -s:v:0 1280x720 -r 30-g 48 -keyint_min 48 -sc_threshold 0 -minrate:v:0 3000k -maxrate:v:0 3000k -b:v:0 3000k -f ismv -movflags isml+frag_keyframe -frag_duration 1600000 "http://<YOURCHANNEL>-nimbuspm-uswe.channel.media.azure.net/<CHANNEL_ID>/ingest.isml/Streams(video)"
I got this to work nicely with my laptop microphone, and my USB Logitec headset audio. I set one track to "english" and the other to "spanish" so it shows up in the dropdown list in the Azure Media Player demo site (ampdemo.azureedge.net). I still had to mess around with the AVSync setting (-itsoffset) a bit to make it look right.
ffmpeg -y -hide_banner -f dshow -fflags nobuffer -rtbufsize 15M -i audio="Microphone Array (Synaptics Audio)" -f dshow -fflags nobuffer -i audio="Headset Microphone (Logitech Stereo H650e)" -itsoffset 1.00 -f dshow -fflags nobuffer -rtbufsize 2000M -i video="GoPro Webcam" -map 0:a:0 -map 1:a:0 -map 2:v:0 -metadata:s:a:0 language=eng -metadata:s:a:1 language=spa -c:a:0 aac -b:a:0 192k -c:a:1 aac -b:a:1 192k -c:v:2 libx264 -preset ultrafast -tune zerolatency -s:v:0 1280x720 -r 30 -g 48 -keyint_min 48 -sc_threshold 0 -minrate:v:0 3000k -maxrate:v:0 3000k -b:v:0 3000k -f ismv -movflags isml+frag_keyframe -frag_duration 1600000 "http://<YOURCHANNEL>-nimbuspm-uswe.channel.media.azure.net/<CHANNEL_ID>/ingest.isml/Streams(video)"
To do screen recording, depending on what OS you are on, there are many ways to do that - Capture Windows screen with ffmpeg
ffmpeg -y -hide_banner -f dshow -fflags nobuffer -i audio="Headset Microphone (Logitech Stereo H650e)" -itsoffset 1.00 -f gdigrab -framerate 10 -offset_x 0 -offset_y 0 -video_size 1920x1080 -show_region 1 -i desktop -map 0:0 -map 1:0 -c:a:0 aac -b:a:0 192k -c:v:1 libx264 -preset ultrafast -tune zerolatency -s:v:0 1280x720 -r 30 -g 48 -keyint_min 48 -sc_threshold 0 -minrate:v:0 3000k -maxrate:v:0 3000k -b:v:0 3000k -f ismv -movflags isml+frag_keyframe -frag_duration 1600000 "http://<YOURCHANNEL>-nimbuspm-uswe.channel.media.azure.net/<CHANNEL_ID>/ingest.isml/Streams(video)"
I created a new page of example command lines in our Javascript/Node.js SDK sample repo up here:
https://github.com/Azure-Samples/media-services-v3-node-tutorials/blob/main/Live/FFmpeg/ffmpeg_commands.md
I gathered up as many samples as I could locate right now. Feel free to add or suggest more if you come up with any good ones.

FFmpeg, capturing video is laggy, how to eliminate that?

Lets say I dont have a very good computer and my recordings are laggy. Two version I tried:
ffmpeg -f dshow -framerate 30 -i video="screen-capture-recorder":audio="virtual-audio-capturer" -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le output.mkv
ffmpeg -f gdigrab -framerate 30 -i desktop -vcodec libx264 -crf 0 -preset ultrafast -acodec pcm_s16le output.mkv
I tried to avoid all compressing stuff, still lagging. Although Im recording 1920x1080 video... I dont care how big the result is. Isnt there an option like "store all frames, and encoding a bit later, I dont care the realtime capturing" ?

Synchronization and concurrency for creating hls resolutions for Live Streaming

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

How to generate TS streams from middle of a source video?

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

Audio is lost in some portions of a HLS stream

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.

Resources