I use FFmpeg for encoding my iphone video (on debian) and mediafilesegmenter (on mac OS server). For encoding this is my commande :
ffmpeg -i INPUT -y -acodec libfaac -ar 22000 -ab 40k -vcodec libx264 -b 600k \
-bt 600k -vpre slow -vpre baseline -threads 1 -level 30 -r 10 -s 400x224 \
-map_chapters -1:-1 -f ipod INPUT.mp4
When i read the INPUT.mp4 everything is OK with audio.
But when I use the Apple Segmenter (mediafilesegmenter) i have a descync between audio & video.
Is my command line is wrong ? or it's a Apple segmenter bug. The mediastreamvalidator show me :
WARNING: Media segment contains a video track but does not contain any IDR access unit with a SPS and a PPS
But i don't know if cause the audio desync.
I have the latest mediafilesegmenter download from connect.apple.com.
Related
I need to record video from RaspberryPi, using this Bash script:
#!/bin/sh
/usr/bin/ffmpeg -f video4linux2 -input_format h264 -video_size 320x240 -framerate 15 -i /dev/video0 -vcodec copy -an "/var/ayron/videotrap/videos/pctrace_$(date +"%Y_%m_%d_%H_%M_%S").h264"
In this way, I can report the date and time of start recording. But I need to show on video the Date and Time during registration. Which kind of filter must I use?
Thanks for your supply.
Use drawtext filter:
/usr/bin/ffmpeg -f video4linux2 -input_format h264 -video_size 320x240 -framerate 15 -i /dev/video0 -an -vf "drawtext=text='%{localtime\:%Y_%m_%d_%H_%M_%S}'" "/var/ayron/videotrap/videos/pctrace_$(date +"%Y_%m_%d_%H_%M_%S").h264"
You can't filter and stream copy the video at the same time so -vcodec copy has been omitted.
If you want to use colons (:) in the time then you'll have to do some ugly escaping as shown in How to drawtext colon with localtime in ffmpeg -filter_complex?
In almost all the online references related to FFMPEG and RTMP, I am getting -f as flv. Is there any other formats.
(I have tried avi, mpeg and h264, but no success.)
Currently, I am running following command -
ffmpeg -re -i video.mp4 -f s16le -ar 48000 -ac 2 -i audio.wav -c copy -f flv rtmp://192.168.0.1:1935/myapp/stream
The issues with -f flv in my case are -
It doesn't support 48k sample rate.
None of my input videos are in flv format (I have to convert it to flv externally).
P.S. - I am using VLC as RTMP player.
EDIT -
I am getting following error with 48k audio file -
[flv # 0x5650ba7afb80] FLV does not support sample rate 48000, choose from (44100, 22050, 11025)
I've been attempting to transcode a stream produced by obs studio to my nginx server and send it off to youtube. Now I've made it work with twitch and I know these settings are actually transcoding it mostly correctly and is viewable. The problem being that youtube live picks it up as Bad video settings and tells me to change the current video container format. The other side effect that is probly unrelated is the stream looks really poorly on youtube. Looks like it was streamed at a poor bitrate and stuff but the real problem is the bad video settings error.
The ffmpeg command being used is as follows
ffmpeg -i rtmp://localhost/Private/Private1 -vb 6000k -minrate 6000k -maxrate 6000k -bufsize 6000k -s 1280x720 -c:v libx264 -preset faster -r 50 -g 100 -keyint_min 50 -x264opts nal-hrd=cbr:force-cfr=1 -sws_flags lanczos -tune film -pix_fmt yuv420p -c:a copy -f flv -threads 6 -strict normal rtmp://a.rtmp.youtube.com/live2/{key}
I've tried with different framerates and been googling for awhile and found nothing or interpreted everything wrongly. Either way I would be very happy for some help here.
System info.
OS: Ubuntu Server 16.04 LTS
Ram: 10gb
Processor: AMD Phenom(tm) II X6 1090T
GPU: Geforce GT 520
Internet.
Upload 15mbit
Download 150mbit
If you need any more info I will gladly send it. Thanks for reading.
Edit 1
After some googling about what I'm doing wrong I decided to try and change stuff slightly and came up with this command
ffmpeg -re -i rtmp://localhost/(app)/(key) -c:v libx264 -r 50 -g 100 -keyint_min 100 -x264opts "keyint=100:min-keyint=100:no-scenecut" -sws_flags lanczos -profile:v baseline -preset veryfast -vb 6000K -minrate 6000k -maxrate 6000k -bufsize 6000k -s 1280x720 -tune film,zerolatency -pix_fmt yuv420p -f flv -c:a copy -ac 1 -strict normal rtmp://(output site)/(output app)/(output key)
which as of my current testing seems to at least have a healthy stream for longer than 2 minutes if i only output to youtube live directly. Ive found output to my nginx server then youtube live breaks things.
my nginx rtmp settings are on this link https://pastebin.com/siE99Tv8
Edit 2
If I push the stream to a site like restream to stream it to youtube then it seems to be working. tested for 25 minutes with no change of them saying bad video container or anything. So I'm going to say nginx is partly to blame in how its distributing the files? Unsure what I'm doing wrong. I am pretty sure ffmpeg isn't to blame here at least
Seems YouTube does not like nginx. I found two solutions for this.
Solution 1
Add "meta copy;" to you nginx config as follow:
rtmp {
server {
listen 1935;
application youtube{
live on;
meta copy;
push rtmp://a.rtmp.youtube.com/live2/(key);
}
}
}
Solution 2
Modify nginx-rtmp-module/ngx_rtmp_codec_module.c and replace the line:
ngx_string("Server"),
with
ngx_string("xtradata"),
then recompile nginx.
to insert a time code in a video I use
avconv -y -i in.mp4 -vf "drawtext=fontfile=/usr/share/fonts/truetype/DroidSans.ttf: fontsize=22: timecode='00\:00\:00\:00': r=25: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=black#0.5" -an -y out.mp4
when reading the video
ffplay out.mp4
everything is ok but when using a pipe to feed the rtmp server and then reading the stream with ffplay the time code won't display. Is it due to the flv conversion ?
for example streaming from a raspberry pi camera
/opt/vc/bin/raspivid -n -hf -vf -fl -mm matrix -w 800 -h 600 -fps 25 -g 80 -t 0 -b 6000000 -o - | avconv -re -i - -nostats -c copy -vf "drawtext= ..... -f flv rtmp://myserver/cam/live
doesn't output the timecode.
Can anyone walk me through the steps of taking a video from our website and changing it to a m3U8 so we can then insert it to our app dashboard to have video on our app?
Download FFMPEG
then download a http segmenter e.g. apple's one or the google one
Now run the command prompt using cmd.
Go to bin directory of the FFMPEG from the command prompt.
Type ffmpeg –h to find various option of the ffmpeg.
This sample code converts a mp4 to a ts file:
ffmpeg -i myvideo.mp4 -acodec libfaac -ar 48000 -ab 64k -s 320x320 -vcodec libx264 -vbsf h264_mp4toannexb -f mpegts myvideo.ts
then run the segmenter to break up the ts file into smaller segments
segmenter -i myvideo.ts -d 20 -o la -x test/myvideo.m3u8
add the following to your htaccess file if you are running on apache
.M3U8 application/x-mpegURL
.ts video/MP2T
that's about it
Use gstreamill, which can transcode video to m3u8 format.