yixia / VitamioBundle

Vitamio for Android
http://www.vitamio.org/en/
Other
5.27k stars 2.07k forks source link

avformat_open_input: Unkown error occurred #109

Open RubenGM opened 10 years ago

RubenGM commented 10 years ago

I get this error anytime I try to play a stream from FlashStreaming (and other sites):

02-27 19:19:41.652: E/Vitamio[Player](9686): avformat_open_input: Unknown error occurred : -1313558101

The stream works on windows using FFMPEG with the same params that fail on the app: http://i.imgur.com/juQo7Wd.jpg The command was this one:

ffmpeg -i "rtmp://cdn.flashstreaming.mobi/live?token=rJk1fLtTKAMhxL8eRb2gRAExpired=1393529108 playPath=pseriessss swfUrl=http://flashstreaming.mobi/embed/noreproductor.php?o=1&kpublica=29245 pageUrl=http://flashstreaming.mobi/embed/embed.php?channel=pseriessss&w=650&h=400 live=1" test.avi

It will not work anymore due to the token needed, but I guess it should work somehow with Vitamio (with a correct token) since it is a working stream.

wmsgeek commented 10 years ago

Are you adding rtmp_ to that link? example playpath becomes rtmp_playpath and also you need rtmp_app in there.

RubenGM commented 10 years ago

This is what I am actually sending: Url:

rtmp://cdn.flashstreaming.mobi/live?token=rJk1fLtTKAMhxL8eRb2gRAExpired=1393529108

Params:

keys=[rtmp_playpath, rtmp_swfurl, rtmp_pageurl, rtmp_live]
values=[pseriessss, http://flashstreaming.mobi/embed/noreproductor.php?o=1&kpublica=29245, http://flashstreaming.mobi/embed/embed.php?channel=pseriessss&w=650&h=400, 1]

I'm using mMediaPlayer.setDataSource(url, keys, values).

Do you have any examples with rtmp_app?

wmsgeek commented 10 years ago

add rtmp_app=live

keys=[rtmp_playpath, rtmp_app, rtmp_swfurl, rtmp_pageurl, rtmp_live] values=[pseriessss, live, http://flashstreaming.mobi/embed/noreproductor.php?o=1&kpublica=29245, http://flashstreaming.mobi/embed/embed.php?channel=pseriessss&w=650&h=400, 1]

RubenGM commented 10 years ago

Done and it fails exactly in the same way.

Url=rtmp://cdn.flashstreaming.mobi/live?token=J7OemjitJcZ1TLgQ-K95XwExpired=1393539474
keys=[rtmp_playpath, rtmp_app, rtmp_swfurl, rtmp_pageurl, rtmp_live]
values=[pseriessss, live, http://flashstreaming.mobi/embed/noreproductor.php?o=1&kpublica=29245, http://flashstreaming.mobi/embed/embed.php?channel=pseriessss&w=650&h=400, 1]
02-27 22:14:46.802: I/Vitamio[Player](20031): OPEN FILE rtmp://cdn.flashstreaming.mobi/live?J7OemjitJcZ1TLgQ-K95XwExpired=1393539474
02-27 22:14:47.112: E/Vitamio[Player](20031): avformat_open_input: Unknown error occurred : -1313558101
02-27 22:14:47.112: E/Vitamio[Player](20031): error (1, -1313558101)
02-27 22:14:47.192: E/Vitamio[Player](20031): Error (1, -1313558101)
wmsgeek commented 10 years ago

Are you sure the AVoptions are sent correctly? im not too sure if vitamio accepts strings in this format mMediaPlayer.setDataSource(url, keys, values). shouldnt it be a single string ?

or maybe try adding that ?token to playpath too.

RubenGM commented 10 years ago

I tried using a HashMap (Like it is used here: https://github.com/yixia/VitamioBundle/wiki/Use-FFmpeg-AVOption-in-Vitamio-4.1.0) and also tried adding the token to the playpath or as another parameter (I tried rtmp_token and token), but nothing seems to work.

If it helps, this piece of code will fetch the parameters to be used for the Vitamio Player and show a working ffmpeg command.

    public static void doIt() {
        String chan = "pseriessss";
        String urlRef = "http://plusseries6501.blogspot.com/";
        String flashvarsValue = null;
        String dataSourceUrl = null;
        HashMap<String, String> params = new HashMap<String, String>();
        try {
            String url = "http://flashstreaming.mobi/embed/embed.php?channel=" + chan + "&w=650&h=400";
            Document doc = Jsoup.connect(url)
                    .userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
                    .referrer(urlRef)
                    .get();
            Element player = doc.getElementById("player1");
            Element movie = player.getElementsByAttributeValue("name", "movie").first();
            Element flashvars = player.getElementsByAttributeValue("name", "flashvars").first();
            flashvarsValue = flashvars.attr("value");
            String[] tmp = flashvarsValue.split("streamer=");
            dataSourceUrl = tmp[1];
            tmp = dataSourceUrl.split("&autostart");
            dataSourceUrl = tmp[0];
            tmp = tmp[0].split("token=");

            String[] tmp2 = flashvarsValue.split("&");
            String playPath = null;
            for(String tmp3 : tmp2) {
                String[] tmp4 = tmp3.split("=");
                if("file".equals(tmp4[0])) {
                    playPath = tmp4[1];
                }
            }

            params.put("rtmp_playpath", playPath);
            //params.put("token", tmp[1]);
            params.put("rtmp_app", "live");
            params.put("rtmp_swfurl", movie.attr("value"));
            params.put("rtmp_pageurl", url);
            params.put("rtmp_live", "1");
            String ffmpegCommand = "ffmpeg -i \"" + dataSourceUrl 
                    + " playPath=" + params.get("rtmp_playpath")
                    + " swfUrl=" + params.get("rtmp_swfurl")
                    + " pageUrl=" + params.get("rtmp_pageurl")
                    + " live=1\" test.avi";
            System.out.println(ffmpegCommand);
        } catch (Exception e) {
            e.printStackTrace();
        }

        //Do something with dataSourceUrl and params
    }

The only requirement to run this would be JSoup: http://jsoup.org/download

wmsgeek commented 10 years ago

im out of ideas, the only thing that happened to me was that Wowza's load balancer redirect app didnt want to work in vitamio(and i guess its being used here aswell.), so i had to get one of the edge's IP and and replace the app name and rtmp with that, so rtmp://cdn.flashstreaming.mobi/live become rtmp://ip/appName