avformat_open_input -2 error (no such file or directory) with a live streaming

968 views
Skip to first unread message

cesare moschini

unread,
May 17, 2016, 5:38:35 AM5/17/16
to Native-Client-Discuss
Hi all, 

i have successfully ported the ffmpeg libraries. My goal is to transcode a mpeg-ts http live streaming in a packaged chrome app. Given that:

  1. i have correctly configured the manifest file sockets permissions.
  2. i have compiled ffmpeg nacl libraries with the correct options.

my (considerable)  code is:

////

void *openstreaming(void* hti){
  HelloTutorialInstance *inst = (HelloTutorialInstance*)hti;

   av_register_all();
   avformat_network_init();
   AVFormatContext* context = avformat_alloc_context();
   int err;
   if((err = avformat_open_input(&context, "/http/<relative http mpeg-ts path> ",NULL,NULL)) >= 0){
  inst->PostMessage("ok");
       }
   else{
char errbuf[50];
av_strerror(err, errbuf, sizeof(errbuf));
std::string str = "can't open input, error  : " + std::to_string(err) + " -- " +  errbuf;
inst->PostMessage(str);
  }

   return 0;
}
.....
.....

nacl_io_init_ppapi(pp::Instance::pp_instance(), pp::Module::Get()->get_browser_interface());
 
 umount("/");
 mount("", "/", "memfs", 0, "");
 
 int ret= mount("<mpeg-ts http url>",
  "/http",  /* target */
  "httpfs", /* filesystemtype */
  0,        /* mountflags */
"allow_cross_origin_requests:true allow_credentials:false"
);  

std::string s = "mount ret code: " + std::to_string(ret);
 PostMessage(s);
 
 pthread_t t1;
 pthread_create(&t1, NULL, &openstreaming, this);
...
...

///////

unfortunately i can't show my mpeg-ts link for many reason and i have not found a sample on the web ( i will try to find it again).
So, i am able to mount and then open correctly these sample files:


but not my mpeg-ts live streaming file. The avformat_open_input function return the -2 error code  "no such file or directory" and the mount function return 0 (success).
ah , outside nacl env my link works with no problem.

The chrome dev tools network tab show me this result:


      1. Request URL:
        <http mpeg-ts live streaming path>
      2. Request Method:
        HEAD
      3. Status Code:
        404 Not Found
      4. Remote Address:
    1. Response Headersview parsed
      1. HTTP/1.1 404 Not Found Server: nginx Date: Tue, 17 May 2016 09:20:04 GMT Content-Type: text/html Content-Length: 564 Connection: keep-alive
    2. Request Headersview parsed
      1. HEAD <relative mpeg-ts live streaming path> HTTP/1.1 Host: <host> Connection: keep-alive Pragma: no-cache Cache-Control: no-cache Allow_cross_origin_requests: true allow_credentials:false: TRUE User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36 Accept: */* Accept-Encoding: gzip, deflate, sdch Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4,es;q=0.2
Name

876.ts


I think the problem is the missing of file size (being a live streaming it have not a file size) in the http response. I try to search a solution on the web with no success.
There is a way, a workaround to access a no fixed file size on the web? i have already spent a lot of time on my project , so please don't say me that this is impossible :-)

Thanks in advance.

Cesare

cesare moschini

unread,
May 18, 2016, 8:50:17 AM5/18/16
to Native-Client-Discuss
Update : 

After a little investigation with curl maybe i understand the problem:

The http response header contains 302 status : 'Moved Temporarily' and a location field with a url generated on the fly by the server , which is what i need.
I don't know how httpfs works in details but i expected that redirection is handled correctly. I'm wrong?
Reply all
Reply to author
Forward
0 new messages