I am trying to put a simple text on the bottom of video using ffmpeg on Ubuntu 12.04 . I tried this which is suggested in several places:
ffmpeg -i input.avi -vf drawtext="fontfile=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf:text='Text to write':fontsize=20:fontcolor=black:x=100:y=100" output.avi
But I get this error each time:
ffmpeg version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
built on Jun 12 2012 16:37:58 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Input #0, avi, from 'input.avi':
Duration: 04:09:09.66, start: 0.000000, bitrate: 480 kb/s
Stream #0.0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 320x240 [PAR 1:1 DAR 4:3], 45 tbr, 45 tbn, 45 tbc
Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 64 kb/s
[buffer # 0x860d5a0] w:320 h:240 pixfmt:yuv420p
Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'
[ac3 # 0x8607a00] invalid bit rate
Output #0, avi, to 'output.avi':
Stream #0.0: Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 45 tbc
Stream #0.1: Audio: ac3, 48000 Hz, stereo, flt, 200 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Error while opening encoder for output stream #0.1 - maybe incorrect parameters such as bit_rate, rate, width or height
Appreciate your help.
The documentation shows that you can use other parameters with x or y such as input video height and width and text width and height. To place the text on the bottom one method is y=main_h-text_h. If you want a little padding on the bottom you can use y=main_h-(text_h*2) To center it horizontally use x=(main_w/2-text_w/2).
Related
I want to overlay a video with the showcqt effect on the right corner, I know that I have to use a filter graph but don't know how, the documentation is large but not very accessible for me. ffmpeg outputs this:
Input #0, matroska,webm, from 'cover.webm':
Metadata:
ENCODER : Lavf58.20.100
Duration: 00:03:14.58, start: -0.007000, bitrate: 206 kb/s
Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709), 1280x720, SAR 1:1 DAR 16:9, 24 fps, 24 tbr, 1k tbn, 1k tbc (default)
Metadata:
DURATION : 00:03:14.541000000
Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Metadata:
DURATION : 00:03:14.581000000
You can use the showcqt and overlay filters:
ffmpeg -i input.webm -filter_complex "showcqt=s=320x180[cqt];[0][cqt]overlay=main_w-overlay_w:main_h-overlay_h" -c:a copy output.webm
The audio is stream copied (-c:a copy) in this example to avoid re-encoding. Remove -c:a copy if you want it to automatically re-encode to an appropriate audio format for whatever output container you choose.
While using ffmpeg to concatenate similar m4a files:
ffmpeg -f concat -safe 0 -i <(for f in ./*.m4a; do echo "file '$PWD/$f'"; done) -c copy output.m4a
ffmpeg reports an error:
[ipod # 0x7f8db8014a00] Could not find tag for codec mjpeg in stream #0, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
The files used are: chapter1.m4a, chapter2.m4a. Their ffprobe have no differences other than the duration. Possible related output is:
Duration: 00:13:16.72, start: 0.000000, bitrate: 48 kb/s
Stream #0:0(eng): Audio: aac (HE-AAC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 46 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 640x360 [SAR 100:100 DAR 16:9], 90k tbr, 90k tbn, 90k tbc
I just found out the error was due to the Stream #0, which is the cover art, and covers the actual audio track.
After removing the cover artworks in all files, I was able to concatenate them. And the speed is quite fast : speed=1.92e+03x.
I am trying to use ffmpeg to convert MTS files to MP4 files. It seems as though the command is running correctly, but the resulting files end up being empty.
joshua#joshua-VirtualBox:~$ ffmpeg -i /media/sf_2017-04/SD_044/00007.MTS /media/sf_2017-04/SD_04/000007.mp4
ffmpeg version 0.8.17-4:0.8.17-0ubuntu0.12.04.2, Copyright (c) 2000-2014 the Libav developers
built on Apr 1 2016 14:28:02 with gcc 4.6.3
The ffmpeg program is only provided for script compatibility and will be removed
in a future release. It has been deprecated in the Libav project to allow for
incompatible command line syntax improvements in its replacement called avconv
(see Changelog for details). Please use avconv instead.
Input #0, mpegts, from '/media/sf_2017-04/SD_044/00007.MTS':
Duration: 00:01:17.07, start: 1.927822, bitrate: 25053 kb/s
Program 1
Stream #0.0[0x1011]: Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 59.96 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
Stream #0.2[0x1200]: Data: [144][0][0][0] / 0x0090
File '/media/sf_2017-04/SD_04/000007.mp4' already exists. Overwrite ? [y/N] y
[buffer # 0x88772a0] w:1920 h:1080 pixfmt:yuv420p
ffmpeg -i /media/sf_2017-04/SD_044/00007.MTS /media/sf_2017-04/SD_04/000007.mp4
ffmpeg version 0.8.17-4:0.8.17-0ubuntu0.12.04.2, Copyright (c) 2000-2014 the Libav developers
built on Apr 1 2016 14:28:02 with gcc 4.6.3
The ffmpeg program is only provided for script compatibility and will be removed
in a future release. It has been deprecated in the Libav project to allow for
incompatible command line syntax improvements in its replacement called avconv
(see Changelog for details). Please use avconv instead.
Input #0, mpegts, from '/media/sf_2017-04/SD_044/00007.MTS':
Duration: 00:01:17.07, start: 1.927822, bitrate: 25053 kb/s
Program 1
Stream #0.0[0x1011]: Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 59.96 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
Stream #0.2[0x1200]: Data: [144][0][0][0] / 0x0090
File '/media/sf_2017-04/SD_04/000007.mp4' already exists. Overwrite ? [y/N] y
[buffer # 0x88772a0] w:1920 h:1080 pixfmt:yuv420p
encoder 'aac' is experimental and might produce bad results.
Add '-strict experimental' if you want to use it.
In your ffmpeg version, aac codec in ffmpeg is still experimental, ffmpeg automatically select aac for the output codec since you didn't specify with -c:a. But you need to manually enable it.
Like the output information said, add extra parameters -strict -2 or -strict experimental will work.
I'm getting the error bitrate tolerance too small for bitrate so far no problem. I know that there are several switches to increase that but nothing works.
ffmpeg -y -r 1/30 -b:v 999999k -bt 999999k -maxrate 999999k -i in.flv out%03d.jpg
The source of that commandline is directly from ffmpeg. But that crashes:
ffmpeg version N-44123-g5d55830 Copyright (c) 2000-2012 the FFmpeg developers
built on Sep 2 2012 20:23:29 with gcc 4.7.1 (GCC)
[...]
Input #0, flv, from 'in.flv':
Duration: 00:05:00.13, start: 0.000000, bitrate: 259 kb/s
Stream #0:0: Video: flv1, yuv420p, 320x240, 1k tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: nellymoser, 22050 Hz, mono, s16
[mjpeg # 04356860] bitrate tolerance too small for bitrate
[mjpeg # 04317540] ff_frame_thread_encoder_init failed
Output #0, image2, to 'out%03d.jpg':
Stream #0:0: Video: mjpeg, yuvj420p, 320x240, q=2-31, 200 kb/s, 90k tbn, 0.03 tbc
Stream mapping:
Stream #0:0 -> #0:0 (flv -> mjpeg)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Some ideas what I'm doing wrong?
I have created a server system based on Xuggle to encode an incoming file to H264 and segment it. However, when playing the video back in Quicktime it almost works (with a small hiccup in the audio sometimes) but when changing fro one quality stream to another the image gets lost.
So I ran the 'mediastreamvalidator'and got the following error:
ERROR: (-1) Unknown video codec: 1836069494 (program 0, track 0)
ERROR: (-1) failed to parse segment as either an MPEG-2 TS or an ES
So I used FFMPEG to get some info on the codex:
The result of my Xuggler encoding:
Input #0, mpegts, from 'segment_0.ts':
Duration: 00:00:09.40, start: 0.000000, bitrate: 3618 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0.0[0x100]: Video: mpeg2video (Main), yuv420p, 960x540 [PAR 1:1 DAR 16:9], 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0.1[0x101]: Audio: mp2, 48000 Hz, stereo, s16, 128 kb/s
The result of a file created by Compressor:
Seems stream 0 codec frame rate differs from container frame rate: 180000.00 (180000/1) -> 25.00 (25/1)
Input #0, mpegts, from 'fileSequence1.ts':
Duration: 00:00:09.97, start: 19.984578, bitrate: 5308 kb/s
Program 1
Stream #0.0[0x101]: Video: h264 (Main), yuv420p, 960x540, 25 tbr, 90k tbn, 180k tbc
Stream #0.1[0x102]: Audio: aac, 22050 Hz, stereo, s16, 32 kb/s
The main difference seems to me that for the Xuggler encoded file it says Video: mpeg2video instead of h264. However, while encoding I did specifically set the Coder to ICodec.ID.CODEC_ID_H264.
How can I force it to use h264. The same with audio. I specified AAC and get MP2.
I subsequent used FFMPEG directly and that results in:
Input #0, mpegts, from 'encoded.ts':
Duration: 00:00:24.16, start: 1.400000, bitrate: 360 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0.0[0x100]: Video: h264 (Main), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0.1[0x101](eng): Audio: aac, 48000 Hz, stereo, s16, 57 kb/s
That looks better. I could use FFMPEG directly, but by using Xuggler I can segment the file while easier keep track of progress of the process.
I moved away form Xuggle for the moment and use FFMPEG for the encoding and the segmenting and only use it to get encoding info etc.
Currently two processes needed (first encode, then segment with FFMPEG), but hopefully soon FFMPEG will allow to segment on the fly while encoding