Search code examples
ffmpeghttp-live-streamingm3u8

Send ffmpeg segmented files to Remote location


I would like to segment a video file using ffmpeg and send the segmented files to a remote http url instead local server disk

I can run this command, which will store files in a directory

ffmpeg -i [input url] -map 0 -codec:v libx264 -codec:a mp2 -f segment -flags -global_header -segment_format mpegts -segment_time 10 segment%03d.ts

What I would like to do is

ffmpeg -i [input url] -map 0 -codec:v libx264 -codec:a mp2 -f segment -flags -global_header -segment_format mpegts -segment_time 10 http://url/ts_file

It gives error as Could not write header for output file #0 (incorrect codec parameters ?): Error number -22 occurred

Is it possible to do in ffmpeg?


Solution

  • I got solution, the trick is append the segment%03d.ts at end of url

    val output_url =  "http://"+request.host+"/ts_file/"
    
    ffmpeg -i [input url] -map 0 -codec:v libx264 -codec:a mp2 -f segment -flags -global_header -segment_format mpegts -segment_time 10 "+output_url+"segment%03d.ts
    

    in my route file (I am using Play with Scala)

    POST   /ts_file/:file_name                       controllers.Application.ts_file(file_name: String)