Hi all,
I have a recording in ogg format which has an opus stream inside. Foobar is able to play the file, and Media Info is able to read it, but other programs are having trouble opening it, so I'd like to losslessly extract the opus stream from it. When I try opening the ogg file with ffmpeg, it says that invalid data was found when processing the input file.
I've never dealt with this before, so I don't really know where to go from here. Are there other tools to try? Perhaps the file is corrupt? I have no idea. But Foobar is able to play it, so something has to give. I'd really hate to have to transcode because of this. Does anyone have ideas?
Thanks!
What does the "codec" tag say? Does it just say "Opus" ? Maybe you could submit the file to FFmpeg's developers for examination, if it is valid as you say.
What do you mean by codec tag?
I did make a bit of progress. If I open the ogg file in mkvtoolnix, I can extract a mka file using mkvmerge, then I can run ffmpeg on that mka file to extract an opus file. That seems to work somewhat, the file plays in some things but other things still cannot play it.
Opusinfo seems to spot some problems with the file:
"New logical stream (#1, serial: bf6aaa75): type opus
WARNING: Implausibly low preskip in Opus stream (1)
Encoded with Lavf58.33.100
User comments section follows...
BPS-eng=82387
DURATION-eng=00:00:36.599990784
NUMBER_OF_FRAMES-eng=915
NUMBER_OF_BYTES-eng=376911
_STATISTICS_WRITING_APP-eng=mkvmerge v43.0.0 ('The Quartermaster') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng=2020-04-01 00:12:32
_STATISTICS_TAGS-eng=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
encoder=Lavf58.33.100
WARNING: Samples with negative granpos in stream 1
WARNING: Sample count behind granule (145920<145921) in stream 1
WARNING: Sample count behind granule (193920<193921) in stream 1
WARNING: Sample count behind granule (241920<241921) in stream 1..."
There are approx. 20 more sample count behind granule warnings after that.
The rest looks comparatively safer:
"Opus stream 1:
Pre-skip: 0
Playback gain: 0 dB
Channels: 2
Original sample rate: 48000 Hz
Packet duration: 40.0ms (max), 40.0ms (avg), 40.0ms (min)
Page duration: 1040.0ms (max), 989.2ms (avg), 320.0ms (min)
Total data length: 380344 bytes (overhead: 0.903%)
Playback length: 0m:36.600s
Average bitrate: 83.14 kbit/s, w/o overhead: 82.38 kbit/s
Logical stream 1 ended"
well after much frustration I found a solution which seems to work by using mvkmerge and mkvextract in a chain.
mkvmerge -o <outfile.mka> <infile.ogg> (to convert ogg container to mka)
mkvextract <infile.mka> tracks 0:<outfile.opus> (to extract opus from mka)
Running mkvextract on the ogg file doesn't work. I have to convert to mka first. Ffmpeg doesn't seem to be as useful in this particular situation.
I'm almost positive this isn't at all how things are supposed to work, but at least the opus file I have now plays in everything I've tried, and opusinfo is no longer reporting sample granule errors. smh might need to contact author of the program generating the ogg files to see if something can be fixed.
You can skip the mka step in the extraction process by using gMKVExtractGUI, which requires you also have mkvtoolnix installed:
https://forum.doom9.org/showthread.php?t=170249 (https://forum.doom9.org/showthread.php?t=170249)