Newest 'x264' Questions - Stack Overflow
Les articles publiés sur le site
-
Streaming protocol relay without involving codec
4 décembre 2015, par kiran_gI am trying to use libav to relay an RTSP stream. It involves PULLing the stream from an IP camera and then PUSHing to wowza.
The video encoding in the IP camera stream is h264. To enable h264 in my libav application I need to enable x264. But as x264 is GPL, it will not work with my business plan.
My questions is whether libav (ffmpeg) can be made to work like a dumb relay which is encoding-agnostic? so that I dont need to integrate x264 with ffmpeg.
This SO post says that I can use the "copy" argument, but does that allow me to exclude x264?
BTW, is x264 actually needed by ffmpeg for decoding h264? Is x264 only used in encoding?
See here for my current code.
-
avconv complains "non monotonically increasing dts to muxer in stream" when piping from libx264 on 14.04
1er décembre 2015, par MikeI have a piece of code that takes a stream of images and writes them to a file using x264 to encode and avconv. The relevant bits are as follows
// Setup encoder sprintf(cmd, "avconv -i pipe: -vcodec copy %s", filename); fp = popen(cmd, "w"); x264_param_default_preset(¶ms, "ultrafast", "stillimage,zerolatency"); params.i_fps_num = fps; params.i_fps_den = 1; x264_picture_alloc(&in, X264_CSP_I420, width, height); params.i_csp = X264_CSP_I420; in.img.i_csp = X264_CSP_I420; x.params.b_vfr_input = 0; in.i_pts = -1; out.i_pts = -1; params.i_width = width; params.i_height = height; encoder = x264_encoder_open(¶ms); in.img.i_plane = 1; in.img.i_stride[0] = width; ret = x264_encoder_headers(encoder, &nals, &nheader); header_size = nals[0].i_payload + nals[1].i_payload + nals[2].i_payload; fwrite(nals[0].p_payload, header_size, 1, fp); ... // Loop body ++in.i_pts; frame_size = x264_encoder_encode(encoder, &nals, &num_nals, &in, &out); fwrite(nals[0].p_payload, frame_size, 1, fp);
I've left out error checking for clarity, but no error is ever returned. Indeed, until I upgraded my system to 14.04, this code worked perfectly (and continues to work perfectly for colleagues who've yet to upgrade).
Only now running Ubuntu 14.04, I get this output from avconv
[h264 @ 0x98dec0] Estimating duration from bitrate, this may be inaccurate Input #0, h264, from 'pipe:' Duration: N/A, bitrate: N/A Stream #0.0: Video: h264 (Constrained Baseline), yuv420p, 640x480, 25 fps, 25 tbr, 25 tbn, 60 tbc Output #0, mp4, to '../reel/test.mp4': Metadata: encoder : Lavf54.20.3 Stream #0.0: Video: libx264, yuv420p, 640x480, q=2-31, 25 tbn, 25 tbc Stream mapping: Stream #0:0 -> #0:0 (copy) [mp4 @ 0x1347800] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 2 >= 2 av_interleaved_write_frame(): Invalid argument
Despite the error,
out.i_dts
does monotonically increase over the whole duration of the video (it's always equal toin.i_pts
).My general assumption is that newer versions of avconv are more strict with the parameters of the input stream, so while my choice of parameters may have worked before, they do not work now.
Another curiousity, which might be related, is avconv detecting that the stream is 25 FPS, even though x264 is configured with an input FPS of 30.
Edit: Some further information, the same dts error (
2>=2
) happens regardless of the initial pts (with the output dts matching as expected). -
Building x264 on a Mac for android “No working C compiler found”
20 novembre 2015, par LostPuppyI am trying to build x264 and eventually use it to build ffmpeg the following is my script:
#!/bin/bash NDK="/Users/account/Documents/FFmpeg/android-ndk-r10e" TOOL_DIR_ARM="/Users/account/Documents/FFmpeg/android-ndk-r10e/sources/ffmpeg-2.8.2/my-android-toolchain" SYSROOT=$NDK/platforms/platforms/android-21/arch-arm echo "removing tool chain directory if it exists" rm -r $TOOL_DIR_ARM $NDK/build/tools/make-standalone-toolchain.sh \ --platform=android-21 \ --arch=arm \ --install-dir=$TOOL_DIR_ARM \ --toolchain=arm-linux-androideabi-clang3.6\ --llvm-version=3.6 \ --system=darwin-x86_64 if [ -d $SYSROOT ]; then echo "$SYSROOT is a valid directory" fi function build_x264 { cd x264 # another build for phone ./configure \ --cross-prefix=arm-linux-androideabi- \ --sysroot=$SYSROOT \ --host=arm-linux \ --enable-static \ --enable-pic \ --disable-cli make -j4 make install cd ../ } function build_one { cd # another build for phone ./configure \ --sysroot=$SYSROOT \ --target-os=linux \ --arch=arm \ --cross-prefix=$TOOL_DIR_ARM/bin/arm-linux-androideabi- \ --cc=$TOOL_DIR_ARM/bin/clang \ --enable-cross-compile \ --enable-encoder=mpeg4 \ --enable-pthreads \ --enable-gpl \ --enable-libx264 \ --enable-pic \ --extra-cflags='-I/usr/local/include' \ --extra-ldflags='-L/usr/local/lib' make clean make -j4 make install } echo "Building x_264 library" build_x264 echo "Building FFmpeg" build_one
I get an error saying
No working C compiler found. Makefile:3: config.mak: No such file or directory
The following is the output from the config.log file
checking for -mdynamic-no-pic... yes checking for -arch x86_64... yes x264 configure script checking whether gcc works... yes checking whether gcc supports for( int i = 0; i < 9; i++ ); with -std=gnu99... yes checking for -mpreferred-stack-boundary=5... no Failed commandline was: -------------------------------------------------- gcc conftest.c -m64 -Qunused-arguments -Wall -I. -I$(SRCPATH) -mdynamic-no-pic -arch x86_64 -std=gnu99 -mpreferred-stack-boundary=5 -m64 -lm -arch x86_64$ clang: error: unknown argument: '-mpreferred-stack-boundary=5' -------------------------------------------------- Failed program was: -------------------------------------------------- int main (void) { return 0; } -------------------------------------------------- checking whether yasm supports vpmovzxwd ymm0, xmm0... yes
Solutions that I tried:
I made sure I have a working GCC
I have the update to date version of clang
I have the update to date version of LLVM
-
High Quality Screen Capture with FFmpeg
18 novembre 2015, par plumzlI'm trying to figure out a command for high quality screen capture on REHL.
I have tried various options, but none really worked. The quality is not good enough. I'm quite new to ffmpeg and doesn't quite understand all the different flags. So any help would be appreciated!
The commands I have tried:
ffmpeg -y -f x11grab -r 30 -s 1920x1080 -i :0.0+0,0 -vcodec libx264 -strict -2 -b:v 16M output.mov
The first command I tried. The weird thing is it doesn't seem to preserve the bitrate specified
-b:v 16M
. The output video's bitrate is only 2mb/s. Is that not the correct way to specify bitrate when doing screen capture?ffmpeg -f x11grab -s 1920x1080 -r 30 -i :0.0 -qscale 0 -vcodec huffyuv output.mov
The huffyuv codec is supposed to be lossless, but the quality doesn't seem to be any better than the libx264 output.
ffmpeg -f x11grab -r 30 -s 1920x1080 -i :0.0+0,0 -vcodec copy -pix_fmt yuv420p -qscale 0 -an output.mkv ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 1920x1080 -r 30 -i output.mkv -an -c:v libx264 -qscale 0 result.mov
I'm even trying to capture rawvideo and then convert it to libx264 codec viedeo. But the output is corrupted.
I'm using the version of ffmpeg that's built on April 23rd this year. It doesn't have the preset like
-vpre lossless_ultrafast
which I see mentioned in a lot posts.Edit:
After more research, this is the command I end up using. I have to use h264 codec and yuv420p as pixel_fmt since I need to be able to play the quicktimes using quicktime.
ffmpeg -y -f x11grab -framerate 30 -video_size 1920x1080 -i :0.0+0,0 -c:v libx264 -pix_fmt yuv420p -qp 0 -preset ultrafast output.mov
The quality doesn't seem to be much improved even though -qp is set to 0. But it could also because of the rgb conversion to yuv color space according to this post.
-
Volume adjust and channel merge on video using FFMPEG
6 novembre 2015, par user1566352I'm trying to convert a recorded AVI (1 video stream, 2 audio streams[1st is stereo, 2nd is mono]) video file to H264/AAC.
I want the second audio stream to be at 60% volume and the first at 100%.
I also want to merge the first and second audio stream.
Output should be H264 with AAC audio.
The command I tried to use is:
"ffmpeg.exe" -i "input.avi" -filter_complex " [0:a:0]aformat=channel_layouts=stereo,volume=1.0[a1]; [0:a:1]aformat=channel_layouts=mono,volume=0.6[a2]; [a1][a2]amerge,pan=stereo|c0code>
But I get the error: [AVFilterGraph @ 0000000ceb630c00] The following filters could not choose their formats: Parsed_amerge_4 Consider inserting the (a)format filter near their input or output. Error configuring complex filters. Error number -5 occurred
What am I doing wrong and how can it be fixed?
Complete Console Log:
ffmpeg version N-76456-g6df2c94 Copyright (c) 2000-2015 the FFmpeg developers built with gcc 5.2.0 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib libavutil 55. 5.100 / 55. 5.100 libavcodec 57. 14.100 / 57. 14.100 libavformat 57. 14.100 / 57. 14.100 libavdevice 57. 0.100 / 57. 0.100 libavfilter 6. 14.101 / 6. 14.101 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.100 / 2. 0.100 libpostproc 54. 0.100 / 54. 0.100 [avi @ 000000b1cfa6bc20] non-interleaved AVI Guessed Channel Layout for Input Stream #0.1 : stereo Guessed Channel Layout for Input Stream #0.2 : mono Input #0, avi, from 'input.avi': Metadata: encoder : DxtoryCore ver2.0.0.122 ISRC : Video:Lagarith Lossless Codec Audio0:Lautsprecher (2- USB Audio CODEC ) Audio1:Mikrofon (2- USB Audio CODEC ) Duration: 00:27:55.60, start: 0.000000, bitrate: 181780 kb/s Stream #0:0: Video: lagarith (LAGS / 0x5347414C), rgb24, 1920x1017, 179663 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s Stream #0:2: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 1 channels, s16, 705 kb/s [Parsed_amerge_4 @ 000000b1cfaf3200] No channel layout for input 1 Last message repeated 1 times [AVFilterGraph @ 000000b1cfa70c00] The following filters could not choose their formats: Parsed_amerge_4 Consider inserting the (a)format filter near their input or output. Error configuring complex filters. Error number -5 occurred