Compiled FFmpeg not accepting -c:v and -c:a - ffmpeg

I compiled FFmpeg with libsrt, with the online compile guide. https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu & how to compile ffmpeg with enabling libsrt
It seems to compile correctly.
ffmpeg version N-96575-g843c24a Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
configuration: --prefix=/home/ubuntu/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/ubuntu/ffmpeg_build/include --extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/ubuntu/bin --enable-gpl --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libsrt --enable-nonfree
libavutil 56. 38.100 / 56. 38.100
libavcodec 58. 67.100 / 58. 67.100
libavformat 58. 37.100 / 58. 37.100
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 72.100 / 7. 72.100
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
But when running this command to convert a incoming SRT stream to HLS, it doesn't know the -c:a command. When switching the order, it runs that it doesn't know about the -c:v command.
ffmpeg -re -i srt://0.0.0.0:25000?pkt_size=1316&mode=listener -c:a copy -c:v copy -strict -f hls -hls_time 4 -hls_playlist_type event stream.m3u8
~$ ffmpeg -re -i srt://0.0.0.0:25000?pkt_size=1316&mode=listener -c:a copy -c:v copy -strict -f hls -hls_time 4 -hls_playlist_type event stream.m3u8
[2] 9930
ffmpeg version N-96575-g843c24a Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
configuration: --prefix=/home/ubuntu/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/ubuntu/ffmpeg_build/include --extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/ubuntu/bin --enable-gpl --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libsrt --enable-nonfree
libavutil 56. 38.100 / 56. 38.100
libavcodec 58. 67.100 / 58. 67.100
libavformat 58. 37.100 / 58. 37.100
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 72.100 / 7. 72.100
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
-c:a: command not found
[2]+ Stopped ffmpeg -re -i srt://0.0.0.0:25000?pkt_size=1316
I have searched the issue, but I could not find anything similar.
Does someone know what I have missed in the setup?
Everything is manually compiled through the guide, this was the final command I run to compile FFmpeg:
cd ~/ffmpeg_sources && \
wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \
tar xjvf ffmpeg-snapshot.tar.bz2 && \
cd ffmpeg && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-libs="-lpthread -lm" \
--bindir="$HOME/bin" \
--enable-gpl \
--enable-libaom \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-libsrt \
--enable-nonfree && \
PATH="$HOME/bin:$PATH" make && \
make install && \
hash -r

Nothing to do with ffmpeg. The shell treats 1316 as the end of the command and & as the background operator.
Enclose the full URL in quotes to avoid this.
"srt://0.0.0.0:25000?pkt_size=1316&mode=listener"

Related

MLT query video_codecs not listing libx264

Querying video codecs does not list libx264 as an available codec
[terry#localhost ~]$ melt -query video_codecs | grep 264
- h264_nvenc
- h264_v4l2m2m
- h264_vaapi
- nvenc_h264
- h264
- h264_cuvid
But I can use it in a command such as:
melt avformat:DarkStar.webm -consumer avformat:output.mp4 acodec=aac vcodec=libx264
and it works successfully.
This is causing a problem with kdenlive. When selecting Render and choosing the format MP4 - the dominating format (H264/AAC) the render option is disabled with the error Unsupported video codec: libx264.
kdenlive checks the profile codec against the list obtained from MLT using:
Mlt::Properties vcodecs(mlt_properties(consumer->get_data("vcodec")));
which seems to get the same list as query video_codecs.
For info here is what ffmpeg says about the codecs:
[terry#localhost ~]$ ffmpeg -codecs | grep 264
ffmpeg version 4.3 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.0 (PCLinuxOS 9.3.0-1pclos2020)
configuration: --prefix=/usr --enable-shared --enable-pic --libdir=/usr/lib64 --shlibdir=/usr/lib64 --incdir=/usr/include --extra-cflags=-I/usr/include/nvenc --disable-stripping --enable-postproc --enable-gpl --enable-pthreads --enable-libtheora --enable-libvorbis --disable-encoder=vorbis --enable-libvpx --enable-runtime-cpudetect --enable-libdc1394 --enable-librtmp --enable-libspeex --enable-libfreetype --enable-libgsm --enable-libcelt --enable-libopus --enable-libopencv --enable-libopenjpeg --enable-libtwolame --enable-libxavs --enable-frei0r --enable-libmodplug --enable-libass --enable-gnutls --enable-libcdio --enable-libpulse --enable-libv4l2 --enable-avresample --enable-opencl --enable-libmp3lame --enable-libaom --enable-sndio --enable-libdav1d --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3 --enable-libx264 --enable-libx265 --enable-libvo-amrwbenc --enable-libxvid --enable-decoder=atrac3 --enable-decoder=atrac3p --enable-libwebp --enable-libfdk-aac --enable-nonfree --enable-cuda --enable-cuvid --enable-nvenc --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m h264_cuvid ) (encoders: libx264 libx264rgb h264_nvenc h264_v4l2m2m h264_vaapi nvenc nvenc_h264 )
Software versions:
mlt-6.20.0
ffmpeg-4.3
x264-1.157.20190309
libx264 is not a codec, its an encoder implementation of a codec. use ffmpeg -encoders | grep 264
There were changes in ffmpeg 4.3 which required MLT to be rebuilt against it.

ffmpeg: Encoder (codec amr_nb) not found for output stream #0:1

I'm using this command to convert flv to 3gp
ffmpeg -y -i in.flv -ar 8000 -b:a 12.20k -ac 1 -s 176x144 out.3gp
And it's giving this error
Encoder (codec amr_nb) not found for output stream #0:1
I have searched for amr_nb packages on yum but didn't able to find it.
I'm on CentOS 7
ffmpeg -version
ffmpeg version 2.6.8 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --enable-libfaac --enable-nonfree --enable-libfdk-aac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
I'm not sure what's missing.
Edit:
I followed this guide https://s3bubble.com/installing-ffmpeg-on-centos-6-6-in-usrlocalbin/ + alijandro's advice.
The ffmpeg installed in your system didn't support encoder amr-nb which is the default encoder for 3gp format.
See if you can find in the encoders list
$ ffmpeg -encoders |grep amr_nb
You can try
use h263/aac as the output encoder, add the option -vcodec h263 -acodec aac
or build ffmpeg with amr-nb support
get opencore source from here https://sourceforge.net/projects/opencore-amr
compile the source and install to /path/to/opencore-amr
get the source of ffmpeg
configure ffmpeg with the options
$./configure --enable-libopencore-amrnb \
--enable-libopencore-amrwb \
--enable-version3 \
...
--extra-cflags="-I/path/to/opencore-amr/include" \
--extra-ldflags="-L/path/to/opencore-amr/lib"
...
# more configure options
compile and install ffmpeg, then your command will work

FFmpeg for marking time video based on a reference date

I am trying to mark a timestamp in a video using drawtext filter.
FFmpeg easily marks timestamps based on localtime, gmtime or even PTS. However, I want to assign a reference time (start time) for the timestamp in order to represent the time the video was recorded (not encoded).
Reading the documentation, I found that option basetime can be used for this purpose. However it seems that is not working or I am missing something.
The command line I am using is:
ffmpeg -y -i input.mp4 -filter_complex drawtext="fontfile=/tmp/UbuntuMono-B.ttf: fontsize=36: fontcolor=yellow: box=1: boxcolor=black#0.4: text='Wall Clock Time\: %{gmtime\:%Y-%m-%d %T}': basetime=1456007118" output.mp4
By using basetime=1456007118, it was expected the start time was set to '02/20/2016 20:25:18' since 1456007118 is the UTC time for that time and date:
date -d '02/20/2016 20:25:18' +"%s" # format MM/DD/AAAA hh:mm:ss
1456007118
However, no error is issued by FFmpeg and the video is marked with current GMT, ignoring basetime option.
Any hint?
Thanks.
Complete information about FFmpeg version and output is:
ffmpeg -y -i /home/denio/Videos/Interstellar_2014_Trailer_4_5.1-1080p-HDTN.mp4 -filter_complex drawtext="fontfile=/tmp/UbuntuMono-B.ttf: fontsize=36: fontcolor=yellow: box=1: boxcolor=black#0.4: text='Wall Clock Time\: %{gmtime\:%Y-%m-%d %T}': basetime=1470226363" /tmp/x.mp4
ffmpeg version 3.1.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.3.1 (Ubuntu 5.3.1-14ubuntu2.1) 20160413
configuration: --enable-libxavs --enable-bzlib --enable-libfaac --enable-libfreetype --enable-libfontconfig --enable-libmp3lame --enable-libschroedinger --enable-libspeex --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid --enable-zlib --enable-x11grab --enable-static --enable-pthreads --enable-gpl --enable-nonfree --enable-version3 --disable-ffserver --enable-libgsm --enable-librtmp --enable-libvpx --enable-libschroedinger --enable-libopencore-amrnb --enable-libopenjpeg
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
...
...
I see the basetime in the source code, but not in the web documentation, so not sure how it's supposed to work.
You can instead use the pts function.
ffmpeg -y -i input.mp4 -vf "drawtext=fontfile=/tmp/UbuntuMono-B.ttf:
fontsize=36:fontcolor=yellow:
box=1:boxcolor=black#0.4:
text='Wall Clock Time\: %{pts\:gmtime\:1456007118}'"
output.mp4
You may need to reset PTS (setpts=PTS-STARTPTS) before the drawtext.

spaces in ffmpeg bash script filename variables

I am using OS X Yosemite. I want to make a simple bash script that allows me to transcode a video. Everything works well as long as a file is not located in a directory which has spaces.
Here is my script:
#!/bin/sh
ffmpeg -i “$1” -c:v ffv1 -level 3 -g 1 -c:a copy “$1.mkv”
Initially, I did not have the double quotes around the variable, but I read some stack overflows that used this as a solution. I'd rather not have to alter the path or add slashes etc. I want to just run:
./script.sh filename.mov
Here's the error I get:
Kierans-iMac:~ bla$ ./firstscript.command "/Users/bla/Desktop/untitled\ folder\ 2/v210.mov.mkv"
ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.7.2_1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libfreetype --enable-libfaac --enable-libass --enable-ffplay --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.2_1/include/openjpeg-1.5 ' --enable-nonfree --enable-vda
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
“/Users/bla/Desktop/untitled\: No such file or directory
You are quoting the spaces twice:
./firstscript.command "/Users/bla/Desktop/untitled\ folder\ 2/v210.mov.mkv"
should just be
./firstscript.command "/Users/bla/Desktop/untitled folder 2/v210.mov.mkv"
A quoted string "foo" is equivalent to \f\o\o; every character is escaped. The backslashes in your original are treated as literal backslashes.
Inside the script, you still need to quote the parameter expansion:
ffmpeg -i "$1" -c:v ffv1 -level 3 -g 1 -c:a copy "$1.mkv"
Note that you have to use regular ASCII quotes ("), not the "smart" quotes (“) implied by the error message in your link.

ffmpeg cannot recognize the '-af' option

The ffmpeg cannot recognize the '-af' option. How can I fix this?
$ ffmpeg -i 01.wav -af pan=1:c0=c1 01mono.wav
ffmpeg version 0.10.12-7:0.10.12-1~precise1 Copyright (c) 2000-2014 the FFmpeg developers
built on Apr 26 2014 09:49:36 with gcc 4.6.3
configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.12-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
[wav # 0x19dd680] max_analyze_duration 5000000 reached at 5015510
Input #0, wav, from '01.wav':
Duration: 00:40:20.40, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
Unrecognized option 'af'
Failed to set value 'pan=1:c0=c1' for option 'af'
Your ffmpeg is too old. See the FFmpeg Download page and get a static build, or refer to a compile guide. FFmpeg development is very active, so it is recommended to always use a recent build.

Resources