garry18 / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

Using Vorbis Audio Codec in FFmpegFrameRecorder throws errors #428

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Using JavaCV 0.7 on Windows 8 64 bit, whenever I try to encode something using 
the Vorbis audio codec from FFMPEG it will throw errors.

The reason I’m using Vorbis for an audio codec is that it’s the only format 
supported by the HTML5 video tag when trying to do pseudo-streaming, aka 
“fast seek”.

The replication case is attached as “RecordToVorbis.java”. I tried to 
reduce it to the minimal case, so the attached example uses only audio, no 
video – after testing I discovered the problem is only related to audio and 
is independent of video settings. I have reproduced the problem just as well 
when using video and audio, as long as the audio uses Vorbis, no matter which 
video format (e.g. MP4, Ogg Theora, or WebM), and I reproduced it with every 
audio file I tested (MP3, WAV). When I test with ffmpeg.exe (without javacv) I 
don’t get any errors. 

When I run the attached sample, this is the output I see:

com.googlecode.javacv.FrameRecorder$Exception: av_write_frame() error -22 while 
writing audio frame.
    at com.googlecode.javacv.FFmpegFrameRecorder.record(FFmpegFrameRecorder.java:883)
    at com.googlecode.javacv.FFmpegFrameRecorder.record(FFmpegFrameRecorder.java:847)
    at com.googlecode.javacv.FrameRecorder.record(FrameRecorder.java:286)
    at uxtrackrecorder.RecordToVorbis.main(RecordToVorbis.java:28)
Exception in thread "main" com.googlecode.javacv.FrameRecorder$Exception: 
av_write_frame() error -22 while writing audio frame.
    at com.googlecode.javacv.FFmpegFrameRecorder.record(FFmpegFrameRecorder.java:883)
    at com.googlecode.javacv.FFmpegFrameRecorder.stop(FFmpegFrameRecorder.java:603)
    at uxtrackrecorder.RecordToVorbis.main(RecordToVorbis.java:37)
Successful frames: 4
Output #0, ogg, to 
'D:\Dropbox\DevDocs\ParallelSurfing\EclipseWorkspace\OpenCVTesting\Test.ogg':
    Stream #0:0: Audio: vorbis, 44100 Hz, mono, flt, 64 kb/s
Input #0, mp3, from 'Sound.mp3':
  Metadata:
    title           : VoiceBunny
    artist          : VoiceBunny
    date            : 2013
  Duration: 00:00:11.91, start: 0.000000, bitrate: 163 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, mono, s16p, 160 kb/s
[ogg @ 000000000cef8d40] Encoder did not produce proper pts, making some up.
[ogg @ 000000000cef8d40] Application provided invalid, non monotonically 
increasing dts to muxer in stream 0: 9223372036854775744 >= NOPTS
[ogg @ 000000000cef8d40] Application provided invalid, non monotonically 
increasing dts to muxer in stream 0: 9223372036854775744 >= NOPTS
[libvorbis @ 000000000cef9520] 16 frames left in the queue on closing

Do you have any suggestions? Thanks!

Original issue reported on code.google.com by aaronpowers on 11 Feb 2014 at 10:27

Attachments:

GoogleCodeExporter commented 8 years ago
It looks like libvorbis requires the same kind of hack as libx264. Should be 
fix in this revision:
http://code.google.com/p/javacv/source/detail?r=e6450930b63e3f4c76695627bb671b36
08c44557
Thanks for reporting!

Original comment by samuel.a...@gmail.com on 15 Feb 2014 at 11:10

GoogleCodeExporter commented 8 years ago
Hi Samuel,
Thanks! I downloaded and tested your patch and the fix works perfectly, Vorbis 
now encodes with no errors and plays fine. Thanks for the quick response and 
the fix!

Original comment by aaronpowers on 23 Feb 2014 at 9:16

GoogleCodeExporter commented 8 years ago
The fix has been included in the latest release of JavaCV 0.8. There are a lot 
of other changes with this release, so please make sure to read the news 
release here:
    http://bytedeco.org/release/2014/04/28/first-release.html

Incidentally, the project is now hosted on GitHub:
    https://github.com/bytedeco/javacv

Thanks once again for reporting!

Original comment by samuel.a...@gmail.com on 29 Apr 2014 at 1:37