Opened 5 years ago

Closed 4 years ago

#390 closed defect (fixed)

Audio/Video not selectable in mmsh stream

Reported by: qrtt1 Owned by: michael
Priority: normal Component: avformat
Version: git-master Keywords: mmsh
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

There is a mms stream which contains five video/audio streams.

qty:ffmpeg_bug qrtt1$ ./ffprobe mmsh://media.uvcm.eu/maya4ok
ffprobe version N-31809-g9acffed, Copyright (c) 2007-2011 the FFmpeg developers
  built on Aug 11 2011 03:55:29 with gcc 4.2.1 (Apple Inc. build 5666) (dot 3)
  configuration: --prefix=HERE
  libavutil    51. 11. 1 / 51. 11. 1
  libavcodec   53. 10. 0 / 53. 10. 0
  libavformat  53.  6. 0 / 53.  6. 0
  libavdevice  53.  2. 0 / 53.  2. 0
  libavfilter   2. 28. 1 /  2. 28. 1
  libswscale    2.  0. 0 /  2.  0. 0
[asf @ 0x10104e600] max_analyze_duration 5000000 reached at 5120000
[asf @ 0x10104e600] Estimating duration from bitrate, this may be inaccurate
Input #0, asf, from 'mmsh://media.uvcm.eu/maya4ok':
  Metadata:
    WM/ParentalRating: Uploaded by: www.evangelist-online.net
    Uploaded by     : www.evangelist-online.net
    WMFSDKVersion   : 10.00.00.4005
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 0
    genre           : Христианское ТВ "Библейский маяк"
    title           : "1-й комплекс 4-й день"
    copyright       : ТРК "3 Ангела"
    comment         : "Вместе веселей"
  Duration: N/A, start: 14.120000, bitrate: 1730 kb/s
    Stream #0.0: Audio: wmav2, 48000 Hz, 2 channels, s16, 128 kb/s
    Stream #0.1: Audio: wmav2, 48000 Hz, 2 channels, s16, 96 kb/s
    Stream #0.2: Audio: wmav2, 44100 Hz, 2 channels, s16, 80 kb/s
    Stream #0.3: Audio: wmav2, 44100 Hz, 2 channels, s16, 31 kb/s
    Stream #0.4: Video: wmv3 (Main), yuv420p, 640x480, 864 kb/s, 1k tbr, 1k tbn, 1k tbc
    Stream #0.5: Video: wmv3 (Main), yuv420p, 384x288, 240 kb/s, 1k tbr, 1k tbn, 1k tbc
    Stream #0.6: Video: wmv3 (Main), yuv420p, 384x288, 158 kb/s, 1k tbr, 1k tbn, 1k tbc
    Stream #0.7: Video: wmv3 (Main), yuv420p, 384x288, 84 kb/s, 1k tbr, 1k tbn, 1k tbc
    Stream #0.8: Audio: wmav2, 8000 Hz, 2 channels, s16, 12 kb/s
    Stream #0.9: Video: wmv3 (Main), yuv420p, 192x144, 36 kb/s, 12.50 tbr, 1k tbn, 1k tbc


I can play it in the default settings, but can't play with the desired streams,
both video and audio disappear.

./ffplay -ast 2 -vst 4  mmsh://media.uvcm.eu/maya4ok

I try to figure out what's wrong with it,
and find the av_read_frame always read the stream index at 8 and 9.
It can reproduce from git source revision 9acffed9e0d7c454b7bc5c947f33cdf8cab3758c (cloned today.)
Just print which index the av_read_frame given.

qty:ffmpeg_bug qrtt1$ git diff
diff --git a/ffplay.c b/ffplay.c
index b62e9ef..703eac2 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -2495,6 +2495,8 @@ static int read_thread(void *arg)
             continue;
         }
         ret = av_read_frame(ic, pkt);
+        av_log(NULL, AV_LOG_WARNING, "stream index: %d\n", pkt->stream_index);
+
         if (ret < 0) {
             if (ret == AVERROR_EOF || url_feof(ic->pb))

Change History (10)

comment:1 Changed 5 years ago by qrtt1

I compared with the request sent by mplayer (packet caught by wireshark).
In stream selection header, it sent exactly two streams (video and audio):

Pragma: stream-switch-entry=ffff:1:0 ffff:6:0 \r\n

However, libavformat/mmsh.c select all the streams,
we always get the last two index 8 and 9.

I test it by hardcode stream index in mmsh.c. The ffprobe can give the desired streams:

[asf @ 0x10104e600] pkt idx 0
[PACKET]
codec_type=audio
stream_index=0
pts=175697
pts_time=175.697000 
dts=175697
dts_time=175.697000 
duration=170
duration_time=0.170000 
size=2731.000000 
pos=1581626
flags=K
[/PACKET]
[asf @ 0x10104e600] pkt idx 4
[PACKET]
codec_type=video
stream_index=4
pts=177720
pts_time=177.720000 
dts=177720
dts_time=177.720000 
duration=0
duration_time=0.000000 
size=3000.000000 
pos=1578738
flags=_
[/PACKET]

It is my test code

qty:ffmpeg_bug qrtt1$ git diff
diff --git a/libavformat/mmsh.c b/libavformat/mmsh.c
index 029baed..8b79616 100644
--- a/libavformat/mmsh.c
+++ b/libavformat/mmsh.c
@@ -268,10 +268,14 @@ static int mmsh_open(URLContext *h, const char *uri, int flags)
         return AVERROR(ENOMEM);
     for (i = 0; i < mms->stream_num; i++) {
         char tmp[20];
-        err = snprintf(tmp, sizeof(tmp), "ffff:%d:0 ", mms->streams[i].id);
-        if (err < 0)
-            goto fail;
-        av_strlcat(stream_selection, tmp, mms->stream_num * 19 + 1);
+        if(i==0||i==4)
+        {
+            err = snprintf(tmp, sizeof(tmp), "ffff:%d:0 ", mms->streams[i].id);
+            if (err < 0)
+                goto fail;
+            av_strlcat(stream_selection, tmp, mms->stream_num * 19 + 1);
+            av_log(NULL, AV_LOG_ERROR, "stream select %d %d\n", i, mms->streams[i].id);
+        }
     }
     // send play request
     err = snprintf(headers, sizeof(headers),
@@ -284,7 +288,9 @@ static int mmsh_open(URLContext *h, const char *uri, int flags)
                    "Pragma: stream-switch-count=%d\r\n"
                    "Pragma: stream-switch-entry=%s\r\n"
                    "Connection: Close\r\n",
-                   host, port, mmsh->request_seq++, mms->stream_num, stream_selection);
+                   host, port, mmsh->request_seq++, 2 /*mms->stream_num */, stream_selection);
+
+    av_log(NULL, AV_LOG_ERROR, "stream select header\n%s\n", headers);
     av_freep(&stream_selection);
     if (err < 0) {
         av_log(NULL, AV_LOG_ERROR, "Build play request failed!\n");

    

comment:2 Changed 5 years ago by cehoyos

  • Component changed from FFplay to avformat
  • Keywords mmsh added
  • Priority changed from important to normal
  • Reproduced by developer set
  • Status changed from new to open
  • Version changed from git to git-master

This is certainly reproducible (and FFmpeg does not warn that audio/video stream selection is not possible for this mms stream).

comment:3 Changed 5 years ago by cehoyos

  • Summary changed from ffplay cannot select desired audio/video stream, consider there is a bug in the av_read_frame function to Audio/Video not selectable in mmsh stream

comment:4 Changed 5 years ago by qrtt1

There is my work around for our software.
https://github.com/qrtt1/ffmpeg_icy/commit/f735b761a0c22a7618bd5e398701187e78e36cd5

However, it's not easy to use. We should open the mms first for getting stream index and choose the selected index by callback in next open stream url. It just work.

comment:5 Changed 5 years ago by cehoyos

Please do not use NULL as av_log() context and I suspect AV_LOG_DEBUG is sufficient, don't you agree?

Please send your patch to ffmpeg-devel, it can be discussed there.

comment:6 Changed 4 years ago by michael

mmsh://media.uvcm.eu/maya4ok gives HTTP error 404 Not Found

comment:7 follow-up: Changed 4 years ago by cehoyos

I find it much worse that the patch cannot be accessed anymore - instead FFmpeg binaries without source are distributed on https://github.com/qrtt1/ffmpeg_lab/tree/prebuilt/prebuilt

comment:8 in reply to: ↑ 7 Changed 4 years ago by qrtt1

Replying to cehoyos:

I find it much worse that the patch cannot be accessed anymore - instead FFmpeg binaries without source are distributed on https://github.com/qrtt1/ffmpeg_lab/tree/prebuilt/prebuilt

The source of our repo ffmpeg_lab is the same with official ffmpeg n0.8.2, no any changes with it.
This repo is used to write some tips for our team member https://github.com/qrtt1/ffmpeg_lab/wiki/FFmpeg-Tool-Notes

Our patches lived in ffmpeg_icy repo:
https://github.com/muzee-git/ffmpeg_icy (moved from my account qrtt1)

Now, I make a fork from muzee's repo to keep the old url accessable

Each extra branches made by me are public:
https://github.com/muzee-git/ffmpeg_icy/commits/m0.8.6.3

The new url for mms selection work around is at:

I am sorry to notify the owner transfered event. (qrtt1 to muzee)

Version 1, edited 4 years ago by qrtt1 (previous) (next) (diff)

comment:9 Changed 4 years ago by qrtt1

Add some multi-stream test case:

  • mms://74.54.73.194/webcasting_gunaz
  • mms://a1248.l6623941247.c66239.g.lm.akamaistream.net/D/1248/66239/v0001/reflector:41247
  • mms://www.manworthy.tv:8088/play

comment:10 Changed 4 years ago by michael

  • Resolution set to fixed
  • Status changed from open to closed

I tried ./ffplay -vst 7 mmsh://74.54.73.194/webcasting_gunaz
and it plays stream 7
I tried ./ffplay -vst 5 mmsh://74.54.73.194/webcasting_gunaz
and it plays stream 5

So id say this has been fixed, please reopen if you can still reproduce such a problem with ffmpeg git master

Note: See TracTickets for help on using tickets.