VideoHelp Forum
+ Reply to Thread
Results 1 to 14 of 14
Thread
  1. I know I can use this ffmpeg to live record this radio stream:
    Code:
    ffmpeg -i https://ais-sa1.streamon.fm/7079_32k.aac -acodec copy output.aac
    I have vlc here:
    C:\Program Files\VideoLAN\VLC\vlc.exe
    Could someone give me the exact ffmpeg script to simultaneously download and play with vlc?
    I know I can just use vlc to play the stream:
    Code:
    https://ais-sa1.streamon.fm/7079_32k.aac
    and then press the red record button in vlc, so this would simultaneously play and record (with vlc), but I would like to see if it is possible to use ffmpeg (for the recording) and have ffmpeg bring up vlc and have vlc play the stream.
    Note: this radio station is a 32kbps stream, and I don't want to use more than that amount of data to do this (recording and playing).
    Last edited by jimdagys; 28th Dec 2019 at 19:27.
    Quote Quote  
  2. Write the ffmpeg output as a transport stream (.TS) and you can play the video while it's downloading:

    Code:
    start /b "ffmpeg" ffmpeg.exe -i "https://ais-sa1.streamon.fm/7079_32k.aac" -c copy  output.ts
    pause
    vlc output.ts
    Wait several second (for the download to start and be flushed to the drive, maybe a minute for audio only downloads) then press Enter to start playing.

    I didn't think this would work with an aac file (instead of ts) but it does.

    Code:
    start /b "ffmpeg" ffmpeg.exe -i "https://ais-sa1.streamon.fm/7079_32k.aac" -c copy  output.aac
    pause
    vlc output.aac
    Last edited by jagabo; 30th Dec 2019 at 08:37.
    Quote Quote  
  3. Average video editor Sviests's Avatar
    Join Date
    Sep 2018
    Location
    USA,Sweden
    Search Comp PM
    It sounds stupid,but it's easier to download it through FFMPEG and just open it again in VLC (so 2 sources) (so do what Jagabo wrote and do your method opening with VLC too)

    But from your message i understand that the stream is cutting out?
    *press the loop button in VLC (if stream cuts out after couple of seconds/minutes),but most likely every time it refreshes your recording stops.
    *Add "keep-connection-alive" to ffmpeg console:
    -multiple_requests 1 -reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 2
    Quote Quote  
  4. Hi ,

    My try , can be improved !!!

    Code:
    @echo on
    
    title Enr-Lect
    
    if exist %systemdrive%\progra~2\videolan\vlc (set "vlc=%systemdrive%\progra~2\videolan\vlc\vlc.exe") else (set "vlc=%systemdrive%\progra~1\videolan\vlc\vlc.exe")
    chcp 28591 > nul
    
    :ENR
    start /b "REC" ffmpeg -i "https://ais-sa1.streamon.fm/7079_32k.aac" -c copy -f mpegts output.ts
    :LECT
    ping localhost -n 30 >nul
    start /b "ECOUTE" "%vlc%" output.ts -
    :Suite
    "%vlc%" output.ts -
    goto Suite
    pause
    
    :fin
    Process for shutdown
    Window "Enr-Lect" : <Ctrl +C> and click on "X" ( right-top corner )
    VLC : click on "X" ( right-top corner )

    Cheers .
    Last edited by aazerty; 30th Dec 2019 at 11:08.
    JE SUIS CHARLIE !!!
    Quote Quote  
  5. Member Emeritus
    Join Date
    May 2014
    Search PM
    streamlink has an option "-r" that both opens the player and writes to a file.

    Code:
    streamlink "hlsvariant://https://ais-sa1.streamon.fm/7079_32k.aac/playlist.m3u8" best -r "file.ts"
    of course, doing this would not be using ffmpeg.
    Quote Quote  
  6. Ponens,
    When I use streamlink v0.12.1 and above code, it brings up vlc and plays the radio station, but it doesn't seem to record anything. There is no evidence of recording in the command window, and I couldn't find any recording (from streamlink) on the computer. Of course I could just press the red record button in vlc, but I wanted to have the streamlink/ffmpeg/youtube-dl record and bring up vlc and play the station in vlc.
    Jagabo,
    I didn't think about just playing the "live" ffmpeg recorded file with vlc. That seems to work, although that seems a little strange to play a file that is still being expanded.

    One issue with pressing the red record button on vlc while playing the radio station - I don't know if that is an analogue sound recording or a digital download. With poor internet, there might be some advantage of capturing the sound with command line software, vs sound recording with vlc.
    Quote Quote  
  7. Member
    Join Date
    Nov 2015
    Location
    Campuchia - Sapoche
    Search Comp PM
    Originally Posted by ..... View Post
    streamlink has an option "-r" that both opens the player and writes to a file.
    It's worked, thank you .

    Quote Quote  
  8. Member Emeritus
    Join Date
    May 2014
    Search PM
    Originally Posted by jimdagys View Post
    When I use streamlink v0.12.1 and above code, it brings up vlc and plays the radio station, but it doesn't seem to record anything. There is no evidence of recording in the command window, and I couldn't find any recording (from streamlink) on the computer.
    Did you check for presence of the output file "file.ts"?

    If you didn't use a path name, the output file would be written in whatever folder/directory that was the current folder for the command prompt window.
    Quote Quote  
  9. Member Emeritus
    Join Date
    May 2014
    Search PM
    Originally Posted by jimdagys View Post
    I didn't think about just playing the "live" ffmpeg recorded file with vlc. That seems to work, although that seems a little strange to play a file that is still being expanded.
    afaik, there is no problem in doing this. That's my preferred method. The file handle(s) of the windows os seem to handle it just fine, even if the stream eventually ends and the file is closed (by whatever program is writing to the file) while the player is still playing it.
    Quote Quote  
  10. I was pretty sure ffmpeg could split the output and send to a file and vlc simultaneously. I finally worked it out. Batch file:

    Code:
    ffmpeg -i "https://ais-sa1.streamon.fm/7079_32k.aac" ^
        -c copy output.aac ^
        -f wav -acodec pcm_s16le -ac 2 - | "G:\Program Files\videolan\vlc\vlc.exe" -
    Change the path to VLC to match where it is on your system. You can pipe to ffplay.exe instead with:

    Code:
    ffmpeg -i "https://ais-sa1.streamon.fm/7079_32k.aac" ^
        -c copy output.aac ^
        -f wav -acodec pcm_s16le -ac 2 - | "G:\Program Files\ffmpeg\bin\ffplay.exe" -
    From those you can see how to pipe to other players.
    Quote Quote  
  11. Jababo,
    Using what you gave:
    Code:
    ffmpeg -i "https://ais-sa1.streamon.fm/7079_32k.aac" ^
        -c copy output.aac ^
        -f wav -acodec pcm_s16le -ac 2 - | "C:\Program Files\videolan\vlc\vlc.exe" -
    this brought up vlc and played the radio station and I could see in the command line that it was recording and after quitting ffmpeg, I could see (output.aac) and play the recording. Thank you.
    Ponens,
    I searched for file.ts on the computer and couldn't find anything. My command window (see below screenshot) does not look like
    therain's command window, where you can clearly see recording going on. Could be my Windows 7 ?
    Image Attached Thumbnails Click image for larger version

Name:	Clipboard01.jpg
Views:	209
Size:	81.6 KB
ID:	51287  

    Last edited by jimdagys; 30th Dec 2019 at 19:41.
    Quote Quote  
  12. Member Emeritus
    Join Date
    May 2014
    Search PM
    Originally Posted by jimdagys View Post
    I searched for file.ts on the computer and couldn't find anything. My command window (see below screenshot) does not look like
    therain's command window, where you can clearly see recording going on. Could be my Windows 7 ?
    I don't know. It could be a permissions issue.

    You could try writing the file to another folder. Or, running the command prompt as admin.

    Code:
    streamlink "hlsvariant://https://ais-sa1.streamon.fm/7079_32k.aac/playlist.m3u8" best -r "C:\Users\John\Documents\file.ts"
    Quote Quote  
  13. Well, one problem solved, but another mystery started.
    I tried this (write ts file to root of c drive):
    Code:
    streamlink "hlsvariant://https://ais-sa1.streamon.fm/7079_32k.aac/playlist.m3u8" best -r "c:/file.ts"
    and this
    Code:
    streamlink "hlsvariant://https://ais-sa1.streamon.fm/7079_32k.aac/playlist.m3u8" best -r "C:\Users\John\Documents\file.ts"
    and also right click on command prompt icon and run as admin, and let vlc come up and play the radio station, but in all cases the command window just sits there (like my above screenshot), and there is no recording.
    Quote Quote  
  14. Problem solved. I uninstalled my streamlink v0.12.1 and downloaded and installed the latest streamlink 1.3.0 (November 22, 2019) and then used the script that Ponens gave:
    Code:
    streamlink "hlsvariant://https://ais-sa1.streamon.fm/7079_32k.aac/playlist.m3u8" best -r "file.ts"
    VLC came up and the radio station played, and after about 4 seconds, I see the recording process in the command window. The recorded music file (file.ts) was where expected (c/users/john) and I could play the file no problem.
    Then I changed the recorded file extension to aac (because the radio station stream is aac, as far as I know):
    Code:
    streamlink "hlsvariant://https://ais-sa1.streamon.fm/7079_32k.aac/playlist.m3u8" best -r "file.aac"
    and that also played and recorded fine.
    Thank you for the help.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!