Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Encoding video for real time streaming
15 septembre 2019, par lilrooMiguel Grinberg's article video streaming with flask, covers sending multiple JPG formatted images to a client through a multipart response to stream video to the browser.
After doing some reading, I quickly realized that MJPEG is not a real video format, JPEGs are not optimized for video streaming and MJPEG cannot be streamed to a HTML5 video element.
for my application (a screen sharing application written in python), I need to be able to encode and stream relatively smooth video (smoother than MJPEG anyway) in semi-realtime to the browser.
I think what I need to do is encode a video stream using a tool like FFmpeg and then send chunks of that output to a browser using a multipart response - however it doesn't look like there is a way to get FFmpeg (using python bindings) to write to an in-memory buffer.
Is ffmpeg up to this task?
I appreciate that this question may sound nieve, but I would be thankful for being pointed in the right direction.
-
FFmpeg overlay filter_complex is slow on Android
15 septembre 2019, par nor0xI'm using FFmpeg on Android (Xamarin) to add a watermark to a video. I have tested the operation with multiple videos and i think overall performance is pretty bad. I wanted to share my results and see how if anyone has similar or better benchmarks.
I'm using the following command for adding a png watermark to the video.
$"-i {video} -i {watermark} -filter_complex \"overlay=W-w-5:H-h-5\" -codec:a copy -preset ultrafast -loglevel debug {output} -y";
The watermark is a 150x150 png with a filesize of 18KB.
Video 1 - 13 seconds - 3840x2160 - 60FPS - 125MB FFmpeg duration: 156 seconds
Video 2 - 4 seconds - 3840x2160 - 30FPS - 17MB FFmpeg duration: 35 seconds
Video 3 - 10 seconds - 1920x1080 - 60FPS - 35MB FFmpeg duration: 79 seconds
What do you think of these results, is it legit that adding an overlay takes that long? Maybe there is something wrong with my command? I ran these tests on an Asus Zenfone 6 (Snapdragon 855, 8GB RAM)
EDIT: I'm using FFmpeg version 3.0.1.1 compiled for ARM. (https://github.com/gperozzo/XamarinAndroidFFmpeg/tree/master/binary/3.0.1.1/arm).
All videos are mp4 files with the H.264 format.
-
ffmpeg stream rejected by youtube because it's too slow
15 septembre 2019, par DeadlyBaconI have an app that sends WebM video to a socket in my server, the socket then executes ffmpeg to transform the video to flv and send it to a youtube rtmp ingester.
Thing is, youtube rejects the stream, saying that the broadcast status is incorrect, no matter what I do.
In my naivette I initially tried to stream 1080p and 720p, that failed, so I went down, assuming that that might help me with the bitrate issue... It did not.
The error that Youtube gives me is in spanish but it basically says that the stream is too slow and I should lower resolution or bitrate(I'm already @ 240p and it's not working).
Edit: Here's the error, translated:
Main broadcast: YouTube is not receiving enough video to guarantee a fluid broadcast. Buffering will occur.
Main Broadcast: We are not receiving video data at a fast enough speed. Your audience may experience buffering. Make sure that your connection is fast enough o consider using a lower bitrate.
Here is my call to ffmpeg thus far (language is node.js if that matters.):
const ffmpeg = child_process.spawn('ffmpeg', [ '-f', 'lavfi', '-i', 'anullsrc', // '-re', // I was told i shouldnt use this parameter. i dont know, honestly. // FFmpeg will read input video from STDIN '-i', '-', // Because we're using a generated audio source which never ends, // specify that we'll stop at end of other input. Remove this line if you // send audio from the browser. '-shortest', '-vcodec', 'libx264', '-acodec', 'aac', //ffmpeg //-re -loop 1 //-framerate 2 -i test1.jpg -i https://xxxxxxxxxxx:8443/live.ogg //-c:a aac //-s 2560x1440 //-ab 128k -vcodec libx264 -pix_fmt yuv420p -maxrate 2048k -bufsize 2048k //'-framerate', '30', '-r', '24', //'-s', '2560x1440', '-force_key_frames','expr:gte(t\,n_forced/2)', '-preset', 'ultrafast', '-pix_fmt', 'yuv420p', '-s', '426x240', '-crf', '23', '-bf', '2', '-q:a', '1', '-ac', '2', '-ar','48000', '-use_editlist','0', '-movflags','+faststart', // '-ab', '128k', '-g', '48', //'-minrate', '1500k', '-minrate', '1000k', '-maxrate', '2000k', '-bufsize', '2000k',/* '-g', '30',*/ //'-keyint_min', '30', //'-t', '30', //// '-deadline', 'realtime', '-cpu-used','-16', '-tune', 'zerolatency', '-threads', '4', //-g 2 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/xxxxxxxxxxxxx // FLV is the container format used in conjunction with RTMP '-f', 'flv', // The output RTMP URL. // For debugging, you could set this to a filename like 'test.flv', and play // the resulting file with VLC. Please also read the security considerations // later on in this tutorial. rtmpUrl ]);
Edit: input is fed via stdin whenever the socket receives data.
In my completely uneducated opinion, the "-deadline realtime" & the "-tune zerolatency" parts seemed to help somewhat but not enough to get me streamin'.
Here is some of the output of ffmpeg:
FFmpeg STDERR: frame= 35 fps=3.1 q=23.0 size= 104kB time=00:00:08.44 bitrate= 100.4kbits/s dup=0 drop=3 speed=0.76x FFmpeg STDERR: frame= 35 fps=3.0 q=23.0 size= 104kB time=00:00:08.44 bitrate= 100.4kbits/s dup=0 drop=3 speed=0.726x FFmpeg STDERR: frame= 35 fps=2.9 q=23.0 size= 104kB time=00:00:08.44 bitrate= 100.4kbits/s dup=0 drop=3 speed=0.696x FFmpeg STDERR: frame= 36 fps=2.8 q=23.0 size= 109kB time=00:00:09.45 bitrate= 94.6kbits/s dup=0 drop=3 speed=0.747x FFmpeg STDERR: frame= 36 fps=2.7 q=23.0 size= 109kB time=00:00:09.45 bitrate= 94.6kbits/s dup=0 drop=3 speed=0.719x FFmpeg STDERR: frame= 38 fps=2.8 q=23.0 size= 121kB time=00:00:11.45 bitrate= 86.7kbits/s dup=0 drop=3 speed=0.839x
This is extremely frustrating.
Please, guys, any guidance is good. what is it that I should be maximizing or minimizing? how do I do that? I honestly do not care about everything else going to hell (for example the video freezing or being severely pixelated at times) I just care about being able to stream
Thank you in advance for anything that might help me!
UPDATE: I created a new broadcast, with variable bitrate, I broadcasted to it, it was at "status:optimal" for a few seconds then fps and speed went down and the stream went back to "status: incorrect"
-
Adding mp3 metadata with space in ffmpeg using bash [duplicate]
15 septembre 2019, par ctrlnotThis question already has an answer here:
I have this bash script on downloading youtube videos then convert it to mp3 using youtube-dl and ffmpeg.
#!/bin/bash ytlink="" outputFileName="" title="" artist="" album="" while getopts l:o:t:r:b: flag; do case "${flag}" in l) ytlink="${OPTARG}";; o) outputFileName="${OPTARG}";; t) title="${OPTARG}";; r) artist="${OPTARG}";; b) album="${OPTARG}";; esac done youtube-dl "$ytlink" --add-metadata --extract-audio --audio-format mp3 --output "temp.%(ext)s" tempFilename="temp.mp3" outputFileName="$outputFileName.mp3" args+=("-i" "$tempFilename" "-metadata" "title='$title'" "-metadata" "artist='$artist'" "-metadata" "album='$album'" "-metadata" "comment=Source:$ytlink") ffmpeg -loglevel debug ${args[@]} -acodec copy "$outputFileName" rm "$tempFilename"
This script is fine if I have one word title/artist/album. However, if I have a space, ffmpeg interprets each word before space as another parameter. This is how I use this on command line:
./yttomp3.sh -l "https://www.youtube.com/watch?v=KwQnSHAilOQ" -o "Lee - Autumn Day" -t "Autumn Day" -r "Lee" -b "(Free) Lo-fi Type Beat - Autumn Day"
The debug output of ffmpeg:
Splitting the commandline. Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'. Reading option '-i' ... matched as input url with argument 'temp.mp3'. Reading option '-metadata' ... matched as option 'metadata' (add metadata) with argument 'title='Autumn'. Reading option 'Day'' ... matched as output url. Reading option '-metadata' ... matched as option 'metadata' (add metadata) with argument 'artist='Lee''. Reading option '-metadata' ... matched as option 'metadata' (add metadata) with argument 'album='(Free)'. Reading option 'Lo-fi' ... matched as output url. Reading option 'Type' ... matched as output url. Reading option 'Beat' ... matched as output url. Reading option '-' ... matched as output url. Reading option 'Autumn' ... matched as output url. Reading option 'Day'' ... matched as output url. Reading option '-metadata' ... matched as option 'metadata' (add metadata) with argument 'comment=Source:https://www.youtube.com/watch?v=KwQnSHAilOQ'. Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'copy'. Reading option 'Lee - Autumn Day.mp3' ... matched as output url. Finished splitting the commandline.
I tried enclosing the arguments to quotes on the script but it's still not working. How should I deal with this? Thanks.
-
Is there any way for merge MKV files with .SRT subtitles in .net ? (without encoding) [on hold]
15 septembre 2019, par Blogsky ProjectI need to merge .mkv files with .srt in VB.net, is there any way for it without re encoding video?