0

I have a (quite large) set of files that is all H264 in an MPEG TS container. Due to time constraints I need to repackage this content into smooth streaming without transcoding it (transcoding would take too long).

I've been trying to figure out how to do this with ffmpeg, as it seems to have 2 different muxers that might be up for the task. I've tried both the 'smoothstreaming' muxer and the 'ismv' muxer, but with both of them I'm running into issues.

ffmpeg -i input.mpg -codec copy -f smoothstreaming ss_out

With this, I get the following error:

ffmpeg version N-79695-g675cfb2 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.3.1 (Debian 5.3.1-14) 20160409
  configuration: 
  libavutil      55. 23.100 / 55. 23.100
  libavcodec     57. 38.100 / 57. 38.100
  libavformat    57. 35.100 / 57. 35.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 44.100 /  6. 44.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  0.101 /  2.  0.101
Input #0, mpegts, from 'input.mpg':
  Duration: 01:28:41.98, start: 2.040000, bitrate: 2500 kb/s
  Program 1 
    Stream #0:0[0x1e1]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 720x576 [SAR 16:11 DAR 20:11], 25 fps, 25 tbr, 90k tbn
    Stream #0:1[0x1e2](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 192 kb/s
[smoothstreaming @ 0x2616340] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
    Last message repeated 1 times
[smoothstreaming @ 0x2616340] No bit rate set for stream 0
Output #0, smoothstreaming, to 'ss_out':
  Metadata:
    encoder         : Lavf57.35.100
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 720x576 [SAR 16:11 DAR 20:11], q=2-31, 25 fps, 25 tbr, 50 tbn
    Stream #0:1(eng): Audio: mp2 (i[0][0][0] / 0x0069), 48000 Hz, stereo, 192 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

The other thing I tried is packaging it with ffmpeg into ismv:

ffmpeg -i input.mpg -c copy -movflags isml+frag_keyframe -f ismv ss_out.ismv

This works fine so far, but then I need the ismindex tool to create the manifest files, but this fails:

ismindex -n ss_out ss_out.ismv

Unable to read the MFRA atom in ss_out.ismv (mfra size mismatch)

Is there something I'm doing wrong, or is there maybe something wrong with my input file?

  • Your audio is MP2. ISMV seems to accept either AAC-LC or WMA Pro. So, try encoding audio to AAC. – Gyan May 3 '16 at 12:16
  • Thanks for that tip. I think that may have been the cause of some (if not all) of my issues. I've yet to test my files, but right now I've used the ismv muxer while at the same time encoding the audio to aac. I also removed the 'isml' from the movflags, it seems thats not necessary for non-live content (could have also been the issue I guess). ffmpeg -i input.mpg -c:v copy -c:a aac -b:a 192k -movflags frag_keyframe -f ismv ss_out.ismv After this ismindex will also run fine! – Sartsj May 3 '16 at 13:26
  • BTW, the 'smoothstreaming' muxer either only takes 'ismv' as input or there was something wrong with my input MPEGTS file. After packaging to ISMV first and then using the 'smoothstreaming' muxer, that also worked. However I never realized the output of that is actual chunks and manifests (the stuff that a webserver normally does on the fly with smooth streaming). I needed a set of ism/ismc/ismv files, which that does not generate. – Sartsj May 3 '16 at 13:30
0

So, of the 2 possible solutions I thought I had in my question, both can work, but they have a different end result.

ISMV muxer + ismindex

What I needed was a set of server-side files (.ism, .ismc, .ismv). To achieve this, I wound up doing the following 2 things:

ffmpeg -i input.mpg -c:v copy -c:a aac -b:a 192k -movflags frag_keyframe -f ismv ss_out.ismv

The above command copies the video streams without transcoding them, transcodes the audio into AAC (though it seems ffmpeg and ismindex both don't mind MP2 audio either) and packages it into an .ismv.

ismindex -n ss_out ss_out.ismv

The ismindex tool can then create the .ism and .ismc files that I need.

The files I got out of this were streamable through IIS with Media Services.

Smoothstreaming muxer

I also got the 'smoothstreaming' muxer to work in the end, the trick was that it needed an .ismv file as input as well. So I ran the same ffmpeg command as above first after which I could use ffmpeg again to repackage it with the 'smoothstreaming' muxer.

The issue I had with this solution though, is that it results in the files needed for a conventional webserver to do smooth streaming. so it has the video fragments split up and metadata per chunk. Which is all normally handled by the streaming server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.