Newest 'libx264' Questions - Stack Overflow
Les articles publiés sur le site
-
X264 encoding using Opencv
29 novembre 2011, par user573193I am working with a high resolution camera: 4008x2672. I a writing a simple program which grabs frame from the camera and sends the frame to a avi file. For working with such a high resolution, I found only x264 codec that could do the trick (Suggestions welcome). I am using opencv for most of the image handling stuff. As mentioned in this post http://doom10.org/index.php?topic=1019.0 , I modified the AVCodecContext members as per ffmpeg presets for libx264 (Had to do this to avoid broken ffmpeg defaults settings error). This is output I am getting when I try to run the program
libx264 @ 0x992d040]non-strictly-monotonic PTS 1294846981.526675 1 0 //Timestamp camera_no frame_no 1294846981.621101 1 1 1294846981.715521 1 2 1294846981.809939 1 3 1294846981.904360 1 4 1294846981.998782 1 5 1294846982.093203 1 6 Last message repeated 7 times [avi @ 0x992beb0]st:0 error, non monotone timestamps -614891469123651720 >= -614891469123651720 OpenCV Error: Unspecified error (Error while writing video frame) in icv_av_write_frame_FFMPEG, file /home/ajoshi/ext/OpenCV-2.2.0/modules/highgui/src/cap_ffmpeg.cpp, line 1034 terminate called after throwing an instance of 'cv::Exception' what(): /home/ajoshi/ext/OpenCV-2.2.0/modules/highgui/src/cap_ffmpeg.cpp:1034: error: (-2) Error while writing video frame in function icv_av_write_frame_FFMPEG
Aborted
Modifications to the AVCodecContext are:
if(codec_id == CODEC_ID_H264) { //fprintf(stderr, "Trying to parse a preset file for libx264\n"); //Setting Values manually from medium preset c->me_method = 7; c->qcompress=0.6; c->qmin = 10; c->qmax = 51; c->max_qdiff = 4; c->i_quant_factor=0.71; c->max_b_frames=3; c->b_frame_strategy = 1; c->me_range = 16;
c->me_subpel_quality=7; c->coder_type = 1; c->scenechange_threshold=40; c->partitions = X264_PART_I8X8 | X264_PART_I4X4 | X264_PART_P8X8 | X264_PART_B8X8; c->flags = CODEC_FLAG_LOOP_FILTER; c->flags2 = CODEC_FLAG2_BPYRAMID | CODEC_FLAG2_MIXED_REFS | CODEC_FLAG2_WPRED | CODEC_FLAG2_8X8DCT | CODEC_FLAG2_FASTPSKIP; c->keyint_min = 25; c->refs = 3; c->trellis=1; c->directpred = 1; c->weighted_p_pred=2; }I am probably not setting the dts and pts values which I believed ffmpeg should be setting it for me.
Any sugggestions welcome.
Thanks in advance -
Getting either incorrect output resolution or FPS from ffmpeg
5 novembre 2011, par AdamI am capturing an RTSP stream from a security camera, and transcoding it for (live streaming) to iphone, using OSX as the encoding platform. I have it working correctly, and Im tuning it. However, it seems that it is not outputting the requested resolution. This is my script
/Applications/SecurityCamera/openRTSP -v -c -t rtsp://10.0.1.118/ch1-s1 | \ /Applications/SecurityCamera/ffmpeg \ -r 10 -i - \ -y -an -ab 64000 -f mpegts -vcodec copy -s 960x640 \ -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 \ -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 \ -sc_threshold 40 -i_qfactor 0.71 -bt 400k -maxrate 524288 -bufsize 524288 \ -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 \ -aspect 960:640 -r 10 -g 10 -async 2 -\ |/Applications/SecurityCamera/mediastreamsegmenter -b http://localhost:8080/\ -f /Library/WebServer/Documents/ -i stream.m3u8 -t 10 -s 4 -D
This is the status report:
Input #0, h264, from 'pipe:': Duration: N/A, bitrate: N/A Stream #0.0: Video: h264, yuv420p, 1600x1200, 10 fps, 10 tbr, 1200k tbn, 20 tbc [mpegts @ 0x10100c200] muxrate VBR, pcr every 1 pkts, sdt every 200, pat/pmt every 40 pkts Output #0, mpegts, to 'pipe:': Metadata: encoder : Lavf52.93.0 Stream #0.0: Video: libx264, yuv420p, 1600x1200 [PAR 1:1 DAR 4:3], q=2-31, 90k tbn, 10 tbc Stream mapping: Stream #0.0 -> #0.0
You can see that its working, but it is outputting 1600x1200 for some reason. (possibly
-vcodec copy
copies all codec parameters, not just the codec type?)If I change the
-vcodec copy
to-vcodec libx264
then I get the correct status report (stating 960x640, correct), but the streaming switches to 2 FPS (why? Im forcing both input and output!) and it halts after 54 frames (see output below)Seems stream 0 codec frame rate differs from container frame rate: 20.00 (20/1) -> 10.00 (20/2) Input #0, h264, from 'pipe:': Duration: N/A, bitrate: N/A Stream #0.0: Video: h264, yuv420p, 1600x1200, 10 fps, 10 tbr, 1200k tbn, 20 tbc [buffer @ 0x100d02420] w:1600 h:1200 pixfmt:yuv420p [scale @ 0x100d026f0] w:1600 h:1200 fmt:yuv420p -> w:960 h:640 fmt:yuv420p flags:0x4 [libx264 @ 0x10100d400] using SAR=1/1 [libx264 @ 0x10100d400] frame MB size (60x40) > level limit (1620) [libx264 @ 0x10100d400] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowCTZ SlowAtom [libx264 @ 0x10100d400] profile Constrained Baseline, level 3.0 [mpegts @ 0x10100c200] muxrate VBR, pcr every 1 pkts, sdt every 200, pat/pmt every 40 pkts Output #0, mpegts, to 'pipe:': Metadata: encoder : Lavf52.93.0 Stream #0.0: Video: libx264, yuv420p, 960x640 [PAR 1:1 DAR 3:2], q=10-51, 200 kb/s, 90k tbn, 10 tbc Stream mapping: Stream #0.0 -> #0.0 read pmap fffps= 3 q=37.0 size= 37kB time=0.10 bitrate=3008.0kbits/s bits/s video pid set at 100 found sequence start next segment value 1026000 written bytes 376 skipped 0 frame= 54 fps= 2 q=-1.0 Lsize= 160kB time=5.40 bitrate= 242.0kbits/s video:141kB audio:0kB global headers:0kB muxing overhead 12.872737% frame I:6 Avg QP:34.68 size: 23524 [libx264 @ 0x10100d400] frame P:48 Avg QP:41.53 size: 75 [libx264 @ 0x10100d400] mb I I16..4: 63.9% 0.0% 36.1% [libx264 @ 0x10100d400] mb P I16..4: 0.1% 0.0% 0.0% P16..4: 0.8% 0.1% 0.0% 0.0% 0.0% skip:99.0% [libx264 @ 0x10100d400] final ratefactor: 38.54 [libx264 @ 0x10100d400] coded y,uvDC,uvAC intra: 57.7% 22.3% 2.0% inter: 0.0% 0.1% 0.0% [libx264 @ 0x10100d400] i16 v,h,dc,p: 23% 35% 27% 15% [libx264 @ 0x10100d400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 32% 16% 4% 3% 3% 7% 4% 8% [libx264 @ 0x10100d400] i8c dc,h,v,p: 83% 11% 5% 0% [libx264 @ 0x10100d400] kb/s:214.43
-
How to compile ffmpeg on android with external library
2 novembre 2011, par Curtis KiuI would like to build ffmpeg using android ndk. The basic clean build is work fine for me. However, I would like to add librtmp,libfaac,libx264 into ffmpeg. Then I add --enable-libXXXXX in build file,but it fail to do so. So can anyone tell me how can I build those file for ffmpeg? Where and what file should I put into the ffmpeg file? Please give me a helping hand Thank you
-
Encoding h.264 with libavcodec/x264
21 décembre 2010, par LeviathanI am attempting to encode video using libavcodec/libavformat. I'm trying to change the standard output-example.c from ffmpeg source. The AVI file is created on the disk, but the only sound is encoded. I tried adding a lot of options for x264 from here. All the other codecs works fine, mpeg2, mpeg4, mjpeg, xvid. In addition to specifying the parameters x264, I also set the codec to AVOutputFormat structure. That's all I've done.
AVOutputFormat *pOutFormat; // in header file av_register_all(); AVCodec *codec = avcodec_find_encoder_by_name("libx264"); pOutFormat = guess_format("avi", NULL, NULL); pOutFormat->video_codec = codec->id;
The debug output of my application:
Output #0, mp4, to 'D:\1.avi': Stream #0.0: Video: libx264, yuv420p, 320x240, q=10-51, 500 kb/s, 90k tbn, 25 tbc Stream #0.1: Audio: aac, 44100 Hz, 1 channels, s16, 128 kb/s [libx264 @ 0x694010]using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 [libx264 @ 0x694010]bitrate tolerance too small, using .01 [libx264 @ 0x694010]profile Main, level 2.0 [libx264 @ 0x694010]frame I:150 Avg QP:14.76 size: 2534 [libx264 @ 0x694010]mb I I16..4: 75.9% 0.0% 24.1% [libx264 @ 0x694010]final ratefactor: 17.57 [libx264 @ 0x694010]coded y,uvDC,uvAC intra: 42.7% 92.4% 47.4% [libx264 @ 0x694010]i16 v,h,dc,p: 11% 14% 2% 73% [libx264 @ 0x694010]i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 18% 29% 5% 8% 10% 3% 3% 2% [libx264 @ 0x694010]kb/s:506.79