Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Streaming an MP2 file without reencoding?

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Source Clients
View previous topic :: View next topic  
Author Message
Christopher



Joined: 24 Feb 2011
Posts: 12

PostPosted: Sat Feb 21, 2015 7:58 pm    Post subject: Streaming an MP2 file without reencoding? Reply with quote

I've been trying to stream an .MP2 file, using ezstream, expressly to avoid transcoding it using sox, darkice, ices2, lame, whatever.

Frustratingly ezstream bombs out when I load it:

ezstream: Streaming ``birdsong-trimmed'' (file: /usr/share/icecast/media/test.mp2)
ezstream: Exiting ...m00s]

I tried specifying the file directly in the XML and with an M3U but neither worked.

Sidenote: before the "Exiting" text, I saw what appeared to be reltime playback status, which would figure given the switches I was specifying, but it stuck at 0m00s before timing out.

I assumed it'd be able to handle MP2, is this not so? I've done loads of Googling and I know it'd be easy to transcode and stream, but I'm deliberately trying to live stream (not fileserve) bit-accurate to the original source.

Pipe dream or doable?
_________________
.
Back to top
View user's profile Send private message
dm8tbr



Joined: 09 Feb 2013
Posts: 45
Location: icecast.org

PostPosted: Mon Feb 23, 2015 3:50 pm    Post subject: yuck Reply with quote

In theory MPEG 1 layer 2 (aka MP2) should also work with Icecast. After all we just forward the raw bitstream in case of "unsupported" formats (this includes MP3 and by extension MP2).

The challenge will be to find a player that plays this without barfing up its intestines.

I'm unsure, but maybe avconv/ffmpeg would work in such a setting, with the copy flag set on audio and the output set to Icecast mode.

TBH: It would probably be easier to just live encode it to Opus and at sufficient bitrate there should be no discernible quality loss.
Back to top
View user's profile Send private message Visit poster's website
Christopher



Joined: 24 Feb 2011
Posts: 12

PostPosted: Wed Feb 25, 2015 3:50 pm    Post subject: Reply with quote

Ah, I'd never considered trying with ffmpeg! I'll give it a shot and see what happens.

Back when I used a Psion Wavefinder to listen to DAB, the DABBar third party control software had an integrated streaming server which exposed each PID as a .mp2 URL and streamed them live without transcoding. Winamp 2 handled it just fine, so I have high hopes for VLC and Foobar...
_________________
.
Back to top
View user's profile Send private message
dm8tbr



Joined: 09 Feb 2013
Posts: 45
Location: icecast.org

PostPosted: Wed Feb 25, 2015 4:08 pm    Post subject: Reply with quote

VLC should work for sure.
It would happily play MPEG-TS with MPEG1L2 audio from my DBOX2 back in the days, also exposed as a (horribly unstable) HTTP stream.
Back to top
View user's profile Send private message Visit poster's website
Christopher



Joined: 24 Feb 2011
Posts: 12

PostPosted: Fri Feb 27, 2015 11:45 pm    Post subject: Reply with quote

All manner of problems. Got avconv and ffmpeg just for comparison's sake (I'm aware the former is a fork of the latter) and set about trying to make it stream to my icecast 2.3.3 server.

I thought I was getting the formatting wrong... Now I'm just wondering if there's a massive undetected regression in the code.

Looks what happens when I try to stream the MP2 to stdout:

Code:
[me /dev] $ ffmpeg -c:a:0 mp2 -i /tmp/file.mp2 -
ffmpeg version N-70284-g0a23129 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11)
  configuration:
  libavutil      54. 19.100 / 54. 19.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 23.106 / 56. 23.106
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
[mp3 @ 0x1e470e0] Format mp3 detected only with low score of 1, misdetection possible!
[mp3 @ 0x1e470e0] Could not find codec parameters for stream 0 (Audio: mp2, 0 channels, s16p): unspecified frame size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
/tmp/file.mp2: could not find codec parameters
Input #0, mp3, from '/tmp/file.mp2':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Audio: mp2, 0 channels, s16p
[NULL @ 0x1e48680] Unable to find a suitable output format for 'pipe:'
pipe:: Invalid argument


The same thing happens if I don't specify the input codec.

I'm really confused now.
_________________
.
Back to top
View user's profile Send private message
dm8tbr



Joined: 09 Feb 2013
Posts: 45
Location: icecast.org

PostPosted: Sat Feb 28, 2015 8:08 am    Post subject: Reply with quote

Just tried this on my machine and it worked flawlessly:
Code:
$ avconv -re -i sample-256kbps.mp2 -acodec copy -content_type audio/mpeg icecast://source:password@icecast.example.org:8000/test.mp2
avconv version 11.2-6:11.2-1, Copyright (c) 2000-2014 the Libav developers
[…]
  • -re sets it to real time reading, else it would run too fast
  • -i sets the input file
  • -acodec copy tells it not to touch the encoded data, but just pass it on
  • -content_type audio/mpeg sends the right content type (required with newer Icecast!)
  • icecast:// is the URL to stream to, including credentials
  • In case your Icecast is older than 2.4, you'll need to pass the -legacy_icecast protocol option and live with some protocol limitations like lack of disconnection detection in avconv.

Conclusion:
As Icecast doesn't touch the stream in any way for legacy encodings, it just works.
Recent avconv works well in this context.
Back to top
View user's profile Send private message Visit poster's website
Christopher



Joined: 24 Feb 2011
Posts: 12

PostPosted: Sat Feb 28, 2015 11:46 am    Post subject: Reply with quote

Oh, I wonder if it's because my avconv is 11_beta1 ... I thought I'd grabbed the most recent version.

When I tried your oneliner, I got:

Code:
[christof ~] $ avconv -re -i /usr/share/icecast/media/birdsong-trimmed.mp2 -acodec copy -content_type audio/mpeg icecast://source:bluefox50qwe@localhost:8000/birdsong
avconv version 11_beta1, Copyright (c) 2000-2014 the Libav developers
  built on Feb 27 2015 21:39:27 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11)
[mp3 @ 0x1fa7120] Format detected only with low score of 25, misdetection possible!
[mp3 @ 0x1fa7120] Could not find codec parameters (Audio: mp3, 0 channels, s16p)
[mp3 @ 0x1fa7120] Estimating duration from bitrate, this may be inaccurate
/usr/share/icecast/media/birdsong-trimmed.mp2: could not find codec parameters


I upgraded to avconv 11.2, and it still gives me the same error. There's something odd going on. (It's a valid MP2, VLC has no problem playing or even copying the ES to a new MP2 which has the same filesize). Time to make some more MP2 test files!
_________________
.
Back to top
View user's profile Send private message
Christopher



Joined: 24 Feb 2011
Posts: 12

PostPosted: Sat Feb 28, 2015 12:19 pm    Post subject: Reply with quote

Haha, so a new and interesting error this time. Encoded a test file with twolame from FLAC...

Ugpraded to Icecast 2.4.1. libavconv 11.2. CentOS 6.6 x64.

Code:
[christof /usr/share/icecast/media] $ avconv -re -i /usr/share/icecast/media/test2.mp2 -acodec copy -content_type audio/mpeg icecast://source:xxx@localhost:8000/birdsong
avconv version 11.2, Copyright (c) 2000-2014 the Libav developers
  built on Feb 28 2015 11:59:48 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11)
[mp3 @ 0x3310120] max_analyze_duration 5000000 reached
[mp3 @ 0x3310120] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for  Input Stream #0.0 : stereo
Input #0, mp3, from '/usr/share/icecast/media/test2.mp2':
  Metadata:
    title           : Ol' MacDonald
    album           : Boys Night Out
    publisher       : Capitol Records
    genre           : Vocal
    Artistsort      : Sinatra, Frank
    track           : 06/19
    artist          : Frank Sinatra
    album_artist    : The Rat Pack
    ALBUMARTISTSORT : Rat Pack, The
    date            : 2004
  Duration: 00:02:41.06, start: 0.000000, bitrate: 224 kb/s
    Stream #0.0: Audio: mp2, 44100 Hz, 2 channels, s16p, 224 kb/s
Unable to find a suitable output format for 'icecast://source:xxx@localhost:8000/birdsong'


Same error if I use the FQDN for the server.

Have you got a special magic version of libavconv? Wink

Forcing the MP2 format got me further, but it seemed initially to bomb immediately after starting to stream. But after that, it began to work, as long as I used the force format flag. Unfortunately though neither VLC nor Foobar begin to play the stream.


Code:
[christof /usr/share/icecast/media] $ avconv -re -i /usr/share/icecast/media/test2.mp2 -c:a copy -f mp2 -content_type audio/mpeg icecast://source:xxx@my.domain.tld:8000/birdsong
avconv version 11.2, Copyright (c) 2000-2014 the Libav developers
  built on Feb 28 2015 11:59:48 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11)
[mp3 @ 0x16ee140] max_analyze_duration 5000000 reached
[mp3 @ 0x16ee140] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for  Input Stream #0.0 : stereo
Input #0, mp3, from '/usr/share/icecast/media/test2.mp2':
  Metadata:
    title           : Ol' MacDonald
    album           : Boys Night Out
    publisher       : Capitol Records
    genre           : Vocal
    Artistsort      : Sinatra, Frank
    track           : 06/19
    artist          : Frank Sinatra
    album_artist    : The Rat Pack
    ALBUMARTISTSORT : Rat Pack, The
    date            : 2004
  Duration: 00:02:41.06, start: 0.000000, bitrate: 224 kb/s
    Stream #0.0: Audio: mp2, 44100 Hz, 2 channels, s16p, 224 kb/s
Output #0, mp2, to 'icecast://source:xxx@my.domain.tld:8000/birdsong':
  Metadata:
    title           : Ol' MacDonald
    album           : Boys Night Out
    publisher       : Capitol Records
    genre           : Vocal
    Artistsort      : Sinatra, Frank
    track           : 06/19
    artist          : Frank Sinatra
    album_artist    : The Rat Pack
    ALBUMARTISTSORT : Rat Pack, The
    date            : 2004
    encoder         : Lavf56.1.0
    Stream #0.0: Audio: mp2, 44100 Hz, stereo, 224 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press ctrl-c to stop encoding
size=    1968kB time=71.99 bitrate= 223.9kbits/s


VLC borks with the following:

Quote:
es debug: did not sync on first block
mpeg_audio debug: emulated startcode (no startcode on following frame)


More investigation required.
_________________
.
Back to top
View user's profile Send private message
dm8tbr



Joined: 09 Feb 2013
Posts: 45
Location: icecast.org

PostPosted: Sat Feb 28, 2015 12:31 pm    Post subject: Reply with quote

I suspect it's the output format guessing.

In general having a "file extension" on your mountpoint is useful as there are still many broken players out there.
The alternative is probably to force output format by adding "-f mp2" right before icecast://
_________________
I maintain the Icecast project. If you want to show your appreciation.
Back to top
View user's profile Send private message Visit poster's website
Christopher



Joined: 24 Feb 2011
Posts: 12

PostPosted: Sat Feb 28, 2015 1:11 pm    Post subject: Reply with quote

Yep, did both, sadly still doesn't work. Been trying all sorts, even transcoding experimenting with bitstream filters, specifying timecode options, etc - just looks like this won't work.

Transcoded Opus it is! Smile
_________________
.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Source Clients All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber