unnivm / javacv

Automatically exported from code.google.com/p/javacv
0 stars 0 forks source link

Encoded H264 video using FFmpegFrameRecorder missing last few frames #302

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Tried creating sample video using AV_CODEC_ID_H264 codec & 
FFmpegFrameRecorder.
2. Video is created successfully but wont play in any media player, correct 
format is not detected.
3. Have tried AV_CODEC_ID_MPEG4 codec and it works successfully.

What is the expected output? What do you see instead?
Sample H264 encode video.

What version of the product are you using? On what operating system?
x264,  FFmpeg 1.2, Opencv 2.4.4, Ubuntu 12.04 32 bit

Please provide any additional information below.
Output: 
Output #0, mp4, to 'video.mp4':
    Stream #0:0: Video: h264, yuv420p, 704x576, q=-1--1, 2200 kb/s, 90k tbn, 1 tbc
[libx264 @ 0xb69aa2c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
[libx264 @ 0xb69aa2c0] profile High, level 2.2
[libx264 @ 0xb69aa2c0] 264 - core 129 - H.264/MPEG-4 AVC codec - Copyleft 
2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 
deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 
mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 
fast_pskip=1 chroma_qp_offset=-2 threads=1 lookahead_threads=1 sliced_threads=0 
nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 
b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 
keyint=12 keyint_min=1 scenecut=40 intra_refresh=0 rc_lookahead=12 rc=abr 
mbtree=1 bitrate=2200 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 
ip_ratio=1.40 aq=1:1.00
[swscaler @ 0xb12f9b40] Warning: data is not aligned! This can lead to a 
speedloss
[libx264 @ 0xb69aa2c0] final ratefactor: -9.88

Original issue reported on code.google.com by paddy...@gmail.com on 11 Apr 2013 at 10:33

Attachments:

GoogleCodeExporter commented 8 years ago
10 frames might not be enough to fill up H.264's buffer. Please try with 
something like 1000 frames.

Original comment by samuel.a...@gmail.com on 11 Apr 2013 at 10:38

GoogleCodeExporter commented 8 years ago
Hi Samuel,

Thanks, that worked. It seems to work as low as 20 frames. Can you advise the 
best codec to use for web videos (ogg, webm). I have tried this sample H264 
encoded video but it does not seem to work on chrome.

Thanks

Original comment by paddy...@gmail.com on 11 Apr 2013 at 11:00

GoogleCodeExporter commented 8 years ago
An MP4 file created with JavaCV 0.5 and your Test.java file (with more than > 
100 frames) plays just fine on Chrome 26.0.1410.63 on my machine. If you have 
more details about the failure, please let me know.

Original comment by samuel.a...@gmail.com on 11 Apr 2013 at 12:18

GoogleCodeExporter commented 8 years ago
Hi Samuel,
I have retried on chrome with 100 frames and it plays successfully. Is there 
any method of using a smaller number of frames with this codec, perhaps 
flushing the H.264's buffer. Ideally i will need to be able to use small frame 
numbers.

Many thanks for your help.
Paddy

Original comment by paddy...@gmail.com on 11 Apr 2013 at 12:50

GoogleCodeExporter commented 8 years ago
Please try the ffmpeg command program. If that works, then we should be able to 
do whatever they do in ffmpeg.c, but I haven't figured it out myself yet. If 
you do, please let me know so I can fix this, thank you

Original comment by samuel.a...@gmail.com on 11 Apr 2013 at 12:54

GoogleCodeExporter commented 8 years ago
It's actually sort of documented in the header files, and I think I was able to 
put something together that works:
http://code.google.com/p/javacv/source/detail?r=9fab7522f5904904eaec4744e7f99b7b
d8f48ac6
Can you check if that works for your application? Thanks

Original comment by samuel.a...@gmail.com on 14 Apr 2013 at 12:15

GoogleCodeExporter commented 8 years ago
Hi Samual,

I am using the javacv 0.5 library. I have one mp3 file with length 48 secs I 
want to convert this mp3 to mp4 file. I used FFmpegFrameGrabber class and 
FFmpegFrameRecorder class. The problem that I am getting is that I get mp4 file 
of the mp3. The length of this mp4 file is 12 secs. But it was expected to be 
48 secs and audio in final mp4 is also not good. I have attached both mp3 and 
converted mp4 file. Please help me. I was waiting for your response. I have 
also email you the mp3 and mp4 file.

Thanks,

Original comment by anisharm...@gmail.com on 18 Jun 2013 at 5:59

Attachments:

GoogleCodeExporter commented 8 years ago
Fix has been included in JavaCV 0.6, thanks for reporting!

@anisharma Sorry for not noticing your comment before. A lot of things have 
changed since you posted it, so please try out JavaCV 0.6 and let me know if 
you still have problems with that, thanks!

Original comment by samuel.a...@gmail.com on 16 Sep 2013 at 4:14