I'm a problem with a code of ffmpeg: ffmpeg -rtsp_transport tcp -i "rtsp://admin:passw#xxxxxxxx.ddns.net:554/live/ch0" -deinterlace -vcodec libx264 -pix_fmt yuv420p -preset medium -s 1920x1080 -b:v 5000k -acodec aac -strict -2 -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 128k -f flv "rtmp://a.rtmp.youtube.com/live2/key"
It's used for a live streaming by a ip camera, but I have this problem
[flv # 0x558333a41100] Non-monotonous DTS in output stream 0:1; previous: 73709, current: 73220; changing to 73709. This may result in incorrect timestamps in the output file.
[aac # 0x558333a0f100] Queue input is backward in time14.43 bitrate=1288.8kbits/s dup=0 drop=5 speed=0.486x
[flv # 0x558333a41100] Non-monotonous DTS in output stream 0:1; previous: 74591, current: 73614; changing to 74591. This may result in incorrect timestamps in the output file.
who can help me?
Especially in live streams, there will occasionally happen some "jumps" on timestamps. Why this happens... well, there are many reasons, including packet losses.
When this happens this will cause momentary distortion in the output.
Here FFmpeg tells you a jump has occurred. I consider this not an error on your sideājust a warning.
As the warning says, FFmpeg already handled it (by correcting the timestamps).
There isn't anything much to do, other than sometimes you may need to restart the FFmpeg, because of the unexpected changes on the stream.
thank you so much.
I proceeded to change the code with a simpler one."ffmpeg -rtsp_transport tcp -i "rtsp://xxxxxxxxxxxxxxxxxxx.ddns.net:554/live/ch0" -tune zerolatency -s 1920x1080 -vcodec libx264 -c:v libx264 -c:a aac -preset ultrafast -g 50 -f flv "rtmp://a.rtmp.youtube.com/live2/key"
actually the problem was that the live of yt would end even if ffmper kept processing so suddenly. With the new code the terminal no longer gives the error but the problem persists
Related
I want to create a video from combination of all these files which includes single audio file, still image in background and multiple image frames at several times, i have achieved this with video file on this help Now i have tried a failure attempt to create audio with same approach. But got an error which is obvious because still lack of knowledge in FFMPEG
Following is my failure attempt with error Output with label 'v2' does not exist in any defined filter graph, or was already used elsewhere.
ffmpeg -y -loop 1 -i bg.jpg -i img/%07d.png -i dia.mp3 -c:v libx264 -tune stillimage -pix_fmt yuv420p -c:a aac -b:a 128k -shortest -vf "[0:v]scale=1280:1280:force_original_aspect_ratio=increase,crop=1280:1280[v1],[v1][2]overlay=10:10:enable='between(t,0,6)'[v2]" -map "[v2]" out.mp4 2>&1
Use
ffmpeg -y -loop 1 -i bg.jpg -i img/%07d.png -i dia.mp3 -c:v libx264 -tune stillimage -pix_fmt yuv420p -c:a aac -b:a 128k -shortest -filter_complex "[0:v]scale=1280:1280:force_original_aspect_ratio=increase,crop=1280:1280[v1];[v1][1]overlay=10:10:enable='between(t,0,6)'" out.mp4 2>&1
The pad numbering is wrong, and there should be a semi-colon after the bg image scale.
So I have a video called 1.mkv and would like to mix in a variety of different audio clips at certain points. To do this I'm using the -filter_complex option. However, I'm running into some problems because when ffmpeg tries to mix in the first audio stream the audio works for a short while when the clip is playing and then all audio cuts out. I'm running ffmpeg version 2.8.15-0(which is up to date with my distro). Another "weird" thing about the video output is that in xplayer the video will freeze after the audio cuts out, and will work if you skip far enough ahead in the video(not sure if this is helpful but it might give some extra clues).
Full command:
ffmpeg -i "1.mkv" -i "5.wav" -i "2.wav" -i "3.wav" -i "6.wav" -i "7.wav" -i "4.wav" -i "9.wav" -i "8.wav" -i "10.wav" -filter_complex "[0:0]setdar=4/3[v0];
[2:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,adelay=20000|20000,volume=0.5[ad2];
[4:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,adelay=900000|900000,volume=0.5[ad4];
[3:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,adelay=300000|300000,volume=0.5[ad3];
[1:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,adelay=720000|720000,volume=0.5[ad1];
[7:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,adelay=1140000|1140000,volume=0.5[ad7];
[9:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,adelay=1260000|1260000,volume=0.5[ad9];
[8:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,adelay=1020000|1020000,volume=0.5[ad8];
[5:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,adelay=960000|960000,volume=0.5[ad5];
[6:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,adelay=480000|480000,volume=0.5[ad6];
[0:1]volume=1[ad0];
[ad0][ad2][ad4][ad3][ad1][ad7][ad9][ad8][ad5][ad6]amix=inputs=10:duration=first:dropout_transition=0,dynaudnorm[a0]" -map "[v0]" -map "[a0]" -c:v libx264 -ar 44100 -c:a libmp3lame -preset ultrafast -crf 17 -b:v 1M out2.flv
partial command
ffmpeg -i "1.mkv" -i "2.wav" -filter_complex "[0:0]setdar=4/3[v0];
[1:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,adelay=20000|20000,volume=0.5[ad2];
[0:1]volume=1[ad0];
[ad0][ad2]amix=inputs=2:duration=first:dropout_transition=0,dynaudnorm[a0]" -map "[v0]" -map "[a0]" -c:v libx264 -ar 44100 -c:a libmp3lame -preset ultrafast -crf 17 -b:v 1M out2.flv
So I managed to solve this by playing around with the audio filters. The fix was converting the mono stream into a stereo before applying the audio filters. I was considering deleting the question but I'll leave it up incase someone has the same problem in the future.
mono to stereo
[1][1]amerge=inputs=2[a1]
I used FFmpeg to generate a test clip with color bars and a tone. I also made a special filter to dump out the raw audio data to check it. I was surprised to find that there is significant noise riding on the audio tone after it has gone through the AAC codec. Is this expected? Is there a way to prevent it?
To make the test file I used:
ffmpeg -f lavfi -i "smptehdbars=duration=600:size=1280x720:rate=59.94" -qscale:v 1 -pix_fmt yuv420p smpte_r59_720.mp4
then
ffmpeg -i smpte_r59_720.mp4 -f lavfi -i "sine=frequency=1000:sample_rate=48000:duration=600" -qscale:v 1 -vcodec copy -c:a aac -b:a 192k -shortest -map 0:0 -map 1:0 smpte_r59_720T.mp4
and then
ffmpeg -i smpte_r59_720T.mp4 -y -map 0 -acodec aac -vcodec libx264 -crf 23 -bsf:v h264_mp4toannexb smpte_r59_720T.ts
(Trying to do this all in one step kept failing.)
Other variations on this have varying degrees of noise, sometimes above nominal amplitude and sometimes below.
After finding this problem I pulled a third party test tone .WAV file with 44.1KHz sample rate from the web and checked it. The raw file is clean, but the encoded file I made has noise.
Noise on TS SMPTE bars
Clean audio from MP4
I am using the following command to take an audio mp3 file and make a video out of it (by using a static jpg picture). My aim is to get a mp3 audio that is as small as possible with still acceptable quality.
frequency="11000"
bitrate="45000"
avconv -loop 1 -i a.jpg -i audio.mp3 -shortest -r 1 -metadata STEREO_MODE=mono -c:v libx264 -ar "$frequency" -b:a "$bitrate" -ac 0 result.mkv
My questions are:
1. how can I achieve that the resulting file is MONO?
2. is it possible to reduce the bitrate furthermore? I would like to use values below 45000, too.
3. My aim is to get control of the parameters that influence the file size most significantly. Presently I know that the frequency is quite important. Are there any other parameters that would help me to get a very small output file with still acceptable quality?
Thanks in advance.
Since you are coding to a compressed audio codec, the frequency doesn't directly affect the file size. However, a frequency of 11 kHz will reduce quality of music.
Instead, I'd suggest
frequency="22050"
bitrate="48000"
ffmpeg -loop 1 -i a.jpg -i audio.mp3 -shortest -r 1 -c:v libx264 -crf 28 \
-ar "$frequency" -b:a "$bitrate" -ac 1 result.mkv
The CRF parameter controls video quality - lower values produce better quality but larger files. You'll get more savings from controlling that than audio bitrate, which is at the lower end anyway.
If your build has libfdk_aac included, you can instead use
frequency="22050"
bitrate="32000"
ffmpeg -loop 1 -i a.jpg -i audio.mp3 -shortest -r 1 -c:v libx264 -crf 28 \
-ar "$frequency" -c:a libfdk_aac -profile:a aac_he_v2 -b:a "$bitrate" -ac 1 result.mkv
I have a script that takes in input a video file (generally avi or mp4) and converts it to a "lower quality" mkv video optimized for web streaming.
The ffmpeg command I use is this one:
ffmpeg -fflags +genpts -i file:"$input" -sn -codec:v:0 libx264 -force_key_frames expr:gte\(t,n_forced*5\) -vf "scale=trunc(min(max(iw\,ih*dar)\,1280)/2)*2:trunc(ow/dar/2)*2" -pix_fmt yuv420p -preset superfast -crf 23 -b:v 1680000 -maxrate 1680000 -bufsize 3360000 -vsync vfr -profile:v high -level 41 -map_metadata -1 -threads 8 -codec:a:0 libmp3lame -ac 2 -ab 320000 -af "aresample=async=1" -y "$output"
The problem is that this command only includes the first audio track of my video. I have some dual language videos (italian and english) for which I want to include both languages.
Is there a simple ffmpeg command option that automatically includes all audio tracks found in a video?
Add -map 0:a to include all audio streams.