Opened 4 years ago

Last modified 2 years ago

#1806 open defect

Audio/video stream order reversed in remuxed VOB files

Reported by: paulbu Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: mpegps
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
I am using ffmpeg to edit and remultiplex unencrypted VOB files (from a HD recorder). When copying (ie not transcoding) the streams ffmpeg ALWAYS insists on making the audio stream ID 0 and video stream ID 1 even though the input file was the other way round and it reports itself as NOT doing this.

Using the -map commands also seem to be ignored wherever they appear on the command line.

(This is a problem because I am using dvdauthor on the files and it only seems to work with VOB files with video as the first stream. Fails with infamous ERR: Cannot infer pts for VOBU if there is no audio or video and it is the first VOBU.)

How to reproduce (with any vob file 'input.vob'):
% ffmpeg -i input.vob -target pal-dvd -codec copy output.vob
ffmpeg version N-45279-g1a104bf Copyright (c) 2000-2012 the FFmpeg developers

built on Oct 10 2012 19:21:13 with gcc 4.7.2 (GCC)

Input #0, mpeg, from 'input.vob':

Duration: 00:01:28.15, start: 137.626044, bitrate: 2858 kb/s

Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 352x576 [SAR 24:11 DAR 4:3], 3060 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x80]: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s

Output #0, dvd, to 'output.vob':

Metadata:

encoder : Lavf54.31.100
Stream #0:0: Video: mpeg2video, yuv420p, 352x576 [SAR 24:11 DAR 4:3], q=2-31

, 3060 kb/s, 25 fps, 90k tbn, 25 tbc

Stream #0:1: Audio: ac3, 48000 Hz, stereo, 256 kb/s

Stream mapping:

Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)

But running ffprobe on resulting 'output.vob':
Input #0, mpeg, from 'output.vob':

Duration: 00:01:28.15, start: 1.000000, bitrate: 2877 kb/s

Stream #0:0[0x80]: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p, 352x576 [SAR 24:11 DAR 4:3], 3060 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc

Streams swapped round!

Attachments (1)

test-ffmpeg.vob (1.8 MB) - added by paulbu 4 years ago.
Short VOB file with audio-video delay.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 4 years ago by richardpl

  • Component changed from FFmpeg to avformat
  • Status changed from new to open
  • Version changed from unspecified to git-master

Changed 4 years ago by paulbu

Short VOB file with audio-video delay.

comment:2 Changed 4 years ago by paulbu

Clearer information on this issue from more investigation:
My input VOB files have a time delay between audio and video streams. When remultiplexing (using -codec copy) ffmpeg is repositioning the packets in the streams into time order SO it ends up with a whole VOBU at the start of file containing only audio packets. This causes the (incorrect) 'dvdauthor' error message as it can't determine video time from the first VOBU.

I have attached a short VOB file sample to test with. Run:
ffmpeg -i test-ffmpeg.vob -target pal-dvd -codec copy <out.vob>

and the output file will have an audio only first VOBU and ffprobe will report the audio and video stream IDs have been reversed.
In my view the excess audio before the video starts should be discarded but it maybe the problem is more with 'dvdauthor' here?

comment:3 Changed 4 years ago by cehoyos

  • Keywords mpegps added; stream VOB removed

comment:4 Changed 2 years ago by wim_arbor

AFAIK mpeg ps files do not contain stream numbers other than the stream ID. The Stream ID for video streams start with 0xE0, MP2 audio streams start with 0xC0, AC3 is encoded in private stream 1 (0xBD) with substream number starting at 0x80. So the stream id for mpeg ps depends on the format and is independent of the stream number ffmpeg uses internally.

That would mean the problem is not the stream number of the video stream in the file used for dvdauthor, and ffmpeg is not doing any wrong stream mapping.

If I convert the attached file with this commandline:

ffmpeg -i test-ffmpeg.vob -target pal-dvd -codec copy out.vob

I am able to create a DVD with dvdauthor 0.6.9 but not with dvdauthor 0.7.1. (I did not test other versions). This could mean an issue with dvdauthor.

Note when I delay the audiostream, both versions of dvdauthor work.

ffmpeg -i test-ffmpeg.vob -itsoffset 1.5 -i test-ffmpeg.vob -map 1:v -map 0:a -target pal-dvd -codec copy out2.vob

Indeed ffprobe displays swapped video and audio stream number;

Input #0, mpeg, from 'out.vob':
  Duration: 00:00:05.59, start: 0.500000, bitrate: 2759 kb/s
    Stream #0:0[0x1bf]: Data: dvd_nav_packet
    Stream #0:1[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 256 kb/s
    Stream #0:2[0x1e0]: Video: mpeg2video (Main), yuv420p(tv), 352x576 [SAR 24:11 DAR 4:3], max. 3060 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Input #0, mpeg, from 'out2.vob':
  Duration: 00:00:06.43, start: 0.620000, bitrate: 2385 kb/s
    Stream #0:0[0x1bf]: Data: dvd_nav_packet
    Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv), 352x576 [SAR 24:11 DAR 4:3], max. 3060 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 256 kb/s

That is a problem in ffmpeg too if you refer to a stream with a number (like 0:1).

Note: See TracTickets for help on using tickets.