humble has asked for the wisdom of the Perl Monks concerning the following question:

Can not run mplayer unpacking .ape to .wav :

use utf8::all; while( my $count==0 || ( $count<3 && $@ =~ /does not map to Unicode/ ) + ){ print "Trying $encoding[$count] encoding.\n\n"; eval{ $stat=qx#$mplayer_bin_conf -nolirc -vo null -vc dummy -cache $mp +layer_cache_size_conf -cache-min $mplayer_cache_perc_min_conf -ao pcm +:waveheader:file=$o_tot_cmd $i_file_cmd# }; if( $@=~m#does not map# ){ warn $@; $count++; }elsif( $@ ne '' ){ die $@; # bail out on other eval errors }else{ print "Found: $encoding[$count] .\n\n"; $stat=decode( $encoding[$count], ( qx#$mplayer_bin_conf -nolirc -vo n +ull -vc dummy -cache $mplayer_cache_size_conf -cache-min $mplayer_cac +he_perc_min_conf -ao pcm:waveheader:file=$o_tot_cmd $i_file_cmd# ) ); last; } }

receiving

utf8 "\xC2" does not map to Unicode at r.pl line 30. Trying cp1251 encoding. utf8 "\xC2" does not map to Unicode at r.pl line 30. Trying koi8-r encoding. Cache not responding! utf8 "\xC2" does not map to Unicode at r.pl line 30. MPlayer interrupted by signal 13 in module: demux_open2 MPlayer interrupted by signal 13 in module: read_subtitles_file

Do you have an idea how i can accomplish this? - I use mplayer for covertion because it gives me usable errors so that i can more correctly convert from that format. So i would use it prefarbly that ony other, also, under Debian there is not much option for command line convertion at least.

Replies are listed 'Best First'.
Re: $stat=qx## under utf8::all
by wjw (Priest) on Oct 18, 2013 at 10:14 UTC
    Your real problem does not seem to be with Perl here.

    Suggest you might want to take a look at the following -> link ... .

    Better yet: If you have ffmpeg installed, it is enough to do: ffmpeg -i file.ape output.wav

    Hope that is helpful


    ...the majority is always wrong, and always the last to know about it...
    Insanity: Doing the same thing over and over again and expecting different results.
      I think debian uses avconv these days, but it's much the same. The schism between the ffmpeg crowd and the libav crowd is annoying, though.
        Thanks! I was totally unaware of there being a conflict when I answered. I simply tossed out what I had used in the rare case that I have to mess with an audio conversion(about twice in my life). I did a search to find out what you were talking about and came up with this which I found interesting.

        Also interesting is that a search on CPAN for avconv turns up FFmpeg::Command.

        Another example of how hanging out here informs one of more than Perl, whether by design or otherwise. Thanks for pointing out avconv....


        ...the majority is always wrong, and always the last to know about it...
        Insanity: Doing the same thing over and over again and expecting different results.
      Thank you. Weird to say, but it worked (ffmpeg) - i even saw garbage w /encodings - like w/ mplayer variant but what was marvelous w/ PERL: it did not complain about non-UTF char.s. So. i'm pondering on what to do: either it is PERL's error that just did not triger here for some unknown to me reason, and therefore i will yet have same problems that i do have now w/ mplayer, if i choose ffmpeg.
Re: $stat=qx## under utf8::all
by Anonymous Monk on Oct 18, 2013 at 10:11 UTC
    Get rid of use utf8::all; it breaks your program :p

    or Encode::encode the string properly before you qx{} it

    see perlunitut: Unicode in Perl#I/O flow (the actual 5 minute tutorial)

    Also, qx## while legal is very irritating to me because # is for comments :P Maybe next time you can pick qx\\ because that is legal too

    $ perl -MO=Deparse -E " say qx\echo it\ use feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch' +, 'unicode_strings', 'unicode_eval'; say `echo it`; -e syntax OK
      1. Thank you for answer! 2. I can not get rid of the pragma, i want to make my program working according to nowadays requirements. 3. I can not encode my "string properly" as there is nothing more to encode than what has being done already. 4. qx## is alright to me, pardon. 5. I did cast a glance at the links you've provided: seems to me you did not read my question carefuly. Next time, if would like to help, please consider the fact it takes some time, not just typing effort.

        2. I can not get rid of the pragma, i want to make my program working according to nowadays requirements.

        Its a lexical pragama, turn it off where it breaks your program :)

        3. I can not encode my "string properly" as there is nothing more to encode than what has being done already.

        The program you're talking to doesn't like the bytes you're giving it -- purportedly utf8 -- give the program what it wants, not everything understands utf8

        Also, don't assume utf8::all did everything correctly, trust but verify, so verify -- I don't see any mention of locale in utf8::all

        5. I did cast a glance at the links you've provided: seems to me you did not read my question carefuly. Next time, if would like to help, please consider the fact it takes some time, not just typing effort.

        Cute, but maybe you'd like to do more than glance? qx{} deals in bytes -- if the bytes being sent aren't working, qx{} isn't to blame