MPEG2 Audio track not recognized - depending on bitrate

Started by schach, November 30, 2016, 06:52:26 PM

Previous topic - Next topic

schach

Please have a look at the 2 following short video files including Audio tracks:

http://www.file-upload.net/download-12132433/5sek40mbit.mpg.html
http://www.file-upload.net/download-12132436/5sek50mbit.mpg.html

Both are identical MPEG-2 videos, just the Videobitrate differs: 40 Mbit/s and 50 Mbit/s.
When opening the 40 Mbit/s-Video, the Audio track is opened as well. But when openening the 50 Mbit/s-Video, the Audio track is not opened.

Why not, what's the problem?
For example with VLC-Player both Videos can be played without troubles including soundtack.

eumagga0x2a

This must be related to the code in the function psProbeAudio in avidemux_plugins/ADM_demuxers/MpegPS/ADM_psAudioProbe.cpp which needs a longer sample to detect audio in this case. Remuxing the second video with ffmpeg

ffmpeg -i 5sek50mbit.mpg -c copy 5sek50mbit.mkv

to MKV, opening this .mkv file in Avidemux, appending the same file to double the length, saving the resulting video in copy mode as MpegPS (.mpg) again and loading the 10 seconds long video in Avidemux allows the soundtrack to be detected correctly.

schach

I do have this problem as well with MPEG2 Videoclips of length=30 seconds. Maybe some parameter of my MPEG2-file isn't working well with Avidemux. And after reencoding with FFMPEG and AVIDEMUX into a new MPEG-file this problematic parameter got changed or removed?

eumagga0x2a

Quote from: schach on December 01, 2016, 12:19:27 PM
And after reencoding with FFMPEG and AVIDEMUX into a new MPEG-file this problematic parameter got changed or removed?

There was no reencoding, just remuxing into MKV with ffmpeg, loading this MKV in Avidemux and appending it to itself, doubling the duration, then saving a .mpg. This .mpg can be loaded in Avidemux with audio successfully.

If you still experience the same problem with longer videos, please provide such a sample. If you want to be able to edit affected mpeg2 videos with Avidemux with audio just now, please remux them as shown above with ffmpeg to MKV first.

schach

Right you are!
I converted the 5sec-50Mbit .mpg Video into a Matroska .mkv Container with Xmedia Recode (without recoding Video our Audio streams). Now AVIDEMUX is able to read the audio stream.

Now I exported the 5sec-Video with Avidemux as Mpeg-TS. AviDemux is still able to read this Mpeg-TS incl. Audio.
But when I'm exporting the Video as Mpeg-PS: AviDemux is not able to read the Audio track

Since other software like Xmedia-Recode or ffmpeg is able to read the original 5sec/50 Mbit .mpg incl. Audio, it seems there's no problem with the original file itself. But Avidemux for some reason has a problem with this and also when exporting to MPEG-PS (maybe depending on the bitrate of the source file).

eumagga0x2a

It is enough to reduce the value of PROBE_MIN_PACKET in avidemux_plugins/ADM_demuxers/MpegPS/ADM_psAudioProbe.cpp:31 from 5 to 4 to allow Avidemux to detect audio in your 5sek50mbit.mpg sample. The sample is simply too short and the packets probably very big due to the very high video bitrate. However, I can't judge if this change, made to accomodate a very edge case, is the right way to go. Maybe Mean could look at it.

diff --git a/avidemux_plugins/ADM_demuxers/MpegPS/ADM_psAudioProbe.cpp b/avidemux_plugins/ADM_demuxers/MpegPS/ADM_psAudioProbe.cpp
index ca349c2..14571b7 100644
--- a/avidemux_plugins/ADM_demuxers/MpegPS/ADM_psAudioProbe.cpp
+++ b/avidemux_plugins/ADM_demuxers/MpegPS/ADM_psAudioProbe.cpp
@@ -28,7 +28,7 @@
// Max size of a packet. Usually it is a bit more than 2300, so 10000 should be safe
#define PACKET_PROBE_SIZE (100*1024)
// Minimum of packet seen to declare it valid
-#define PROBE_MIN_PACKET 5
+#define PROBE_MIN_PACKET 4
#define PROBE_MIN_SIZE   5000
#define PROBE_ANALYZE_SIZE (300*1024) // Should be enough in all cases (need ~ 2 blocks)
#define MP2_AUDIO_VALUE 0xC0