QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4637|回复: 1

请问如何播放后缀为nsc的在线电视??

[复制链接]
发表于 2007-4-7 13:53:51 | 显示全部楼层 |阅读模式
以前曾发帖问过一次,但没找到解决办法,现在在网上找到解决办法了,但不知如何操作,请高手指教!!!!!!!!!!!!!!!

在一个外国人的论坛上,有人问如何播放后缀为.nsc的流媒体在线电视,呵呵,我也遇到了同样的问题,我们学校也是用的这种格式的在线电视,那个人提问的原文如下,
Hi.

Someone knows how to play asx/nsc stream?

I'm able to play many kinds of stream, but when I try to
play:

mplayer -playlist http://www.radiopopolare.it/live.asx

the buffering starts and reachs an "end of file" after 4188
bytes, that is the dimension of the .nsc file invoked by the
playlist.
The output is:

Playing http://www.radiopopolare.it/live.nsc.
Resolving www.radiopopolare.it for AF_INET...
Connecting to server
www.radiopopolare.it[195.110.125.146]:80 ...
Cache size set to 320 KBytes
Connected to server: www.radiopopolare.it
Cache fill: 1.28% (4188 bytes)

Exiting... (End of file)

The same happens invokind directly the .nsc file.

It could be a codec problem? Someone have a suggestion?
I use mplayer1.0pre4.

Thanks
Lucio

,原文地址为:http://lists.mplayerhq.hu/pipermail/mplayer-users/2004-June/046356.html

然后看到有一个人回帖说,
Please add nsc playlist support to mplayer.

NSC has been hacked by Jon Lech Johansen (The man
behind PyMusique and SharpMusique)

Jons Blog:
"I’ve reverse engineered the encoding used in
the Microsoft NSC format and written a decoder."

http://nanocrew.net/?m=200508


NSC decoder:
http://nanocrew.net/software/nscdec.c

Implementation for VLC:
http://nanocrew.net/software/libvc1-1.0.tar.gz
http://nanocrew.net/software/vlc-libvc1.diff

best regards

Per

大致意思就是说只要将nsc播放列表的支持加入到mplayer里就可以了!nsc的文件已经被一个人破解了,

http://nanocrew.net/?m=200508
这个网址是那个人的博客。我到那个人的博客去一看,它大致意思上就是让下载一个nscdec.c的文件

文件源码如下:

/*****************************************************************************
* nscdec.c: NSC decoder 1.0
*****************************************************************************
* Copyright (C) 2005 Jon Lech Johansen <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/

#include <stdio.h>
#include <ctype.h>
#include <iconv.h>
#include <string.h>
#include <stdlib.h>

static const unsigned char inverse[ 128 ] =
{
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C,
0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E,
0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
0x3B, 0x3C, 0x3D, 0x3E, 0xFF, 0x3F, 0xFF, 0xFF
};

static int load_byte( unsigned char encoding_type,
unsigned char *output, char **input,
unsigned char *j, unsigned char *k )
{
*output = 0;

if( encoding_type == 1 )
{
if( isxdigit( **input ) == 0 )
return -1;

if( isdigit( **input ) == 0 )
*output = (toupper( **input ) - 7) * 16;
else
*output = **input * 16;

(*input)++;

if( isxdigit( **input ) == 0 )
return -1;

if( isdigit( **input ) == 0 )
*output |= toupper( **input ) - 0x37;
else
*output |= **input - 0x30;

(*input)++;
}
else if( encoding_type == 2 )
{
unsigned char **uinput = (unsigned char **)input;

if( **uinput > 127 || inverse[ **uinput ] == 0xFF )
return -1;

if( *k == 0 )
{
if( (*uinput)[ 1 ] > 127 || inverse[ (*uinput)[ 1 ] ] == 0xFF )
return -1;

*output = (inverse[ (*uinput)[ 0 ] ] * 4) |
(inverse[ (*uinput)[ 1 ] ] / 16);

*j = inverse[ (*uinput)[ 1 ] ] * 16;
*k = 4;

(*uinput) += 2;
}
else if( *k == 2 )
{
*output = *j | inverse[ **uinput ];

*j = 0;
*k = 0;

(*uinput)++;
}
else if( *k == 4 )
{
*output = (inverse[ **uinput ] / 4) | *j;

*j = inverse[ **uinput ] * 64;
*k = 2;

(*uinput)++;
}
}

return 0;
}

int main( int argc, char **argv )
{
int ret = 0;

unsigned int i;
unsigned char tmp;
unsigned char j, k;
unsigned int length;
unsigned char encoding_type;
unsigned char *buffer;

if( argc != 2 )
{
fprintf( stderr, "Usage: nscdec string\n" );
return 1;
}

char *p_input = &argv[ 1 ][ 0 ];

if( strlen( p_input ) < 15 )
{
fprintf( stderr, "Input string less than 15 characters\n" );
return 1;
}

if( load_byte( 1, &encoding_type, &p_input, NULL, NULL ) )
{
fprintf( stderr, "Unable to get encoding type\n" );
return 1;
}

if( encoding_type != 1 && encoding_type != 2 )
{
fprintf( stderr, "Encoding type %d is not supported\n",
encoding_type );
return 1;
}

printf( "Encoding type: %d\n", encoding_type );

j = k = 0;

if( load_byte( encoding_type, &tmp, &p_input, &j, &k ) )
{
fprintf( stderr, "load_byte failed\n" );
return 1;
}

for( i = 0; i < 4; i++ )
{
if( load_byte( encoding_type, &tmp, &p_input, &j, &k ) )
{
fprintf( stderr, "load_byte failed\n" );
return 1;
}
}

length = 0;
for( i = 4; i; i-- )
{
if( load_byte( encoding_type, &tmp, &p_input, &j, &k ) )
{
fprintf( stderr, "load_byte failed\n" );
return 1;
}
length |= tmp << ((i - 1) * ;
}

if( length == 0 )
{
fprintf( stderr, "Length is 0\n" );
return 1;
}

buffer = (unsigned char *)malloc( length );
if( buffer == NULL )
{
fprintf( stderr, "Out of memory\n" );
return 1;
}

for( i = 0; i < length; i++ )
{
if( load_byte( encoding_type, &buffer[ i ], &p_input, &j, &k ) )
{
fprintf( stderr, "load_byte failed\n" );
free( (void *)buffer );
return 1;
}
}

if( buffer[ length - 1 ] != 0 && buffer[ length - 2 ] != 0 )
{
printf( "Decoded data:\n" );
for( i = 0; i < length; i++ )
{
printf( "0x%02X, ", buffer[ i ] );
if( ((i + 1) % 12) == 0 )
printf( "\n" );
}
printf( "\n" );
}
else
{
iconv_t conv;

char *buf8;
char *p_buf8;
char *p_buffer;
size_t buffer_size = length;
size_t buf8_size = length;

buf8 = (char *)malloc( buf8_size + 1 );
if( buf8 == NULL )
{
fprintf( stderr, "Out of memory\n" );
free( (void *)buffer );
return 1;
}

conv = iconv_open( "UTF-8", "UTF-16LE" );
if( conv == (iconv_t)-1 )
{
fprintf( stderr, "iconv_open failed\n" );
free( (void *)buffer );
free( (void *)buf8 );
return 1;
}

p_buf8 = &buf8[ 0 ];
p_buffer = (char *)&buffer[ 0 ];

if( iconv( conv, &p_buffer, &buffer_size,
&p_buf8, &buf8_size ) == -1 )
{
fprintf( stderr, "iconv failed\n" );
ret = 1;
}
else
{
buf8[ length - buf8_size ] = 0;
printf( "Decoded string: [%s]\n", buf8 );
}

iconv_close( conv );

free( (void *)buf8 );
}

free( (void *)buffer );

return ret;
}

然后它还写出了一个example usage:
$ nscdec 02AW000000000SLm1D0580HG1C0440MG0m0380800i0200GG0000
Encoding type: 2
Decoded string: [WMRELAY02 , A]
仅此而己。
但我想了半天也想不明白应如何来用它。
我试着用 gcc编译了一下,生成一个a.out的文件,我试着运行了./a.out,显示
floyd@floyd-laptop:~/Desktop$ ./a.out
Usage: nscdec string
我试着运行./a.out http://210.28.16.73/iptv-1.nsc
出现了
floyd@floyd-laptop:~/Desktop$ ./a.out http://210.28.16.73/iptv-1.nsc
Unable to get encoding type
至此,我再也不知道该怎么办了!

请高手一定要帮我啊!!!!!!!!!!!
发表于 2009-4-2 11:11:46 | 显示全部楼层
不知道提问的朋友还有没有留意这个帖子,不过最近也遇到了同样的问题,网上搜到这份代码研究了一下,终于搞清楚了它的使用方法,下面分享给大家:

先编译:
gcc nscdec.c -o nscdec
然后用wget把需要看的.nsc文件下载下来(其实是一个纯文本的播放列表),用vi或者emacs打开,可以看到里面的内容,里面一般会有类似下面这行的文本:
Unicast URL=02H00000000012RG1j07C0E...
把等号后面的内容复制出来,然后执行
./nscdec 02H00000000012RG1j07C0E...
也就是说把复制出来的文本作为nscdec的命令行参数运行

运行以后程序会给出解码结果:
Encoding type: ...
Decoded string: [...]
方括号里的就是真正的视频网址,用支持的视频播放器打开就ok了
其实nsc文件的每一行都是用类似的方法编码的,所以都可以用nscdec来解码,方法就不重复了

希望能帮到大家,呵呵

[ 本帖最后由 lkangaroo 于 2009-4-2 11:17 编辑 ]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-4-20 20:40 , Processed in 0.133130 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表