Opened 2 years ago

Last modified 2 years ago

#8711 new enhancement

Wrong 'Stream mapping' selection

Reported by: giuliano Owned by:
Priority: normal Component: ffmpeg
Version: git-master Keywords: mpegts
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
I'm trying to save a multi variant live streaming (input) using as output a HLS format.
The problem is that the result is a video-audio out of sync.

The input live streaming has a HLS format with several variants.
From the ffmpeg output log I can see:
...
Program 0

...
Stream #0:0: Data: timed_id3 (ID3 / 0x20334449)
...
Stream #0:1: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 704x396 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
...
Stream #0:2: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp

Program 1

...
Stream #0:3: Data: timed_id3 (ID3 / 0x20334449)
...
Stream #0:4: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 512x288 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
...
Stream #0:5: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp
...

Program 2

...
Stream #0:6, 1, 1/90000: Data: timed_id3 (ID3 / 0x20334449), 0/1
...
Stream #0:7, 21, 1/90000: Video: h264 (Main), 1 reference frame ([27][0][0][0] / 0x001B), yuv420p(left), 512x288 [SAR 1:1 DAR 16:9], 0/1, 25 fps, 25 tbr, 90k tbn, 50 tbc
...
Stream #0:8, 36, 1/90000: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
...

In case I do not specify the 'map' ffmpeg parameter, ffmpeg is selecting streams from different 'Programs', i.e. Stream #0:7 and Stream #0:2, and we have the video-audio out of sync.

In case I specifies the 'map' ffmpeg parameter selecting streams belonging to the same 'Program', i.e. Stream #0:4 and Stream #0:5, we do NOT have anymore the video-audio out of sync.
The problem with this solution is that, in case the variants/streams of the input live streaming changes, I have always to change my map parameters.

The fix I'm asking to be evaluated, to avoid the video-audio out of sync, is the following:
In case the 'map' parameter is not specified, ffmpeg should select streams belonging to the same 'Program'.
Does it has sense for you?

How to reproduce:

% ffmpeg -v 9 -loglevel 99 -nostdin -re -i http://mediapolis.rai.itelinker/relinkerServlet.htm?cont=746966 -t 30 -c:v copy -c:a copy -f segment -segment_list /.../liveRecorder.list -segment_time 10 -segment_atclocktime 1 -strftime 1 /.../liveRecorder_%Y-%m-%d_%H-%M-%S_%s.ts > outputLog.txt 2>&1

ffmpeg version 4.2.2

built on Ubuntu 18.04.4 LTS

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Attachments (1)

outputLog.txt (782.9 KB ) - added by giuliano 2 years ago.
ffmpeg output log

Download all attachments as: .zip

Change History (7)

by giuliano, 2 years ago

Attachment: outputLog.txt added

ffmpeg output log

comment:1 by Carl Eugen Hoyos, 2 years ago

Component: ffmpegundetermined
Keywords: mpegts added
Version: 4.2git-master

Consider to provide an input sample. For future tickets: Please remember that only current FFmpeg git head is supported on this bug tracker.

I thought this is a duplicate but couldn't find a related ticket.

comment:2 by giuliano, 2 years ago

Input sample:

it is a "live" input, you can see the input URL from the ffmpeg command, anyway,
it is: http://mediapolis.rai.itelinker/relinkerServlet.htm?cont=746966

Since it is a duplicated ticket, do you know if it was already fixed?

comment:3 by giuliano, 2 years ago

Sorry, I'm thinking now that the input URL might not work outside Italy since I guess it is geo-blocked.
In this case I do not have another input.

comment:4 by Gyan, 2 years ago

Component: undeterminedffmpeg
Keywords: mpegts removed
Type: defectenhancement

The default streams, in absence of map, are evaluated independently. Maybe an option can be added to allow some form of pairing preference.

in reply to:  2 comment:5 by Carl Eugen Hoyos, 2 years ago

Replying to giuliano:

it is: http://mediapolis.rai.itelinker/relinkerServlet.htm?cont=746966

You can use mplayer -dumpstream to produce a sample input file.

comment:6 by Carl Eugen Hoyos, 2 years ago

Keywords: mpegts added
Note: See TracTickets for help on using tickets.