VideoHelp Forum




+ Reply to Thread
Results 1 to 25 of 25
  1. Member
    Join Date
    Dec 2024
    Location
    North America
    Search Comp PM
    Hello All!

    I've downloaded .m4s files from a live video streaming site. I've managed to get the keys, concatenate with the init file and decrypt. My problem is I'd really like to convert the files to .ts and be able to just use the filesystem to 'cat' them. If I convert to .ts (with ffmpeg -i video.mp4 -codec copy -f mpegts video.ts) and cat them, I get a file that plays good for the first 6 seconds (segment time), and then the video freezes and audio continues.

    I've tried a bunch of different things: ffmpeg concat works - but you need to concat ALL of the segments, and I'm trying to deliver them real time. I've tried concatenating them and re-splitting but I still have the issue. If I build a m3u8 file and add '#EXT-X-DISCONTINUITY' before each segment, it seems to work, but my processing is lagging behind and I get buffering.

    I haven't seen an error message from vlc or other tool that tells we exactly what my problem is - so I don't even know what to try next.

    Has anyone seen this issue ? Is there a way to fix it?

    Any help you can give me would be greatly appreciated - I've been stuck on this issue for 2 months.

    Thanks in advance!
    Image Attached Files
    Quote Quote  
  2. Audio is corrupted. When you check all segments with MediaInfo, at audio section you will get following info "Bitstream parsing ran out of data to read before the end of the syntax was reached, most probably the bitstream is malformed".
    Quote Quote  
  3. Member
    Join Date
    Dec 2024
    Location
    North America
    Search Comp PM
    Thanks noemi7!

    I didn't know about MediaInfo. I now have it installed and I see that error.

    Is there some way to correct it?
    Quote Quote  
  4. Originally Posted by bigdealfred View Post
    Is there some way to correct it?
    Welcome. Unfortunately I was not able to fix it, and I tried number of audio tools. You wrote that you can play audio but I don't hear anything on my comp. Whatever segment is loaded it has just empty audio due to errors. Video plays OK, and can be joined.
    Quote Quote  
  5. Member
    Join Date
    Dec 2024
    Location
    North America
    Search Comp PM
    wow - don't know how that happened. Encoding on a different machine and I usually have it muted so I never noticed.

    attached are new files
    Image Attached Files
    Quote Quote  
  6. Member
    Join Date
    Dec 2024
    Location
    North America
    Search Comp PM
    mp4 segments with audio
    Image Attached Files
    Quote Quote  
  7. Different videos but OK. For ts container you can use TSMuxer: "add" the first video, and then add the rest by clicking on "join". TSMuxer doesn't support your m4s.
    Quote Quote  
  8. Member
    Join Date
    Dec 2024
    Location
    North America
    Search Comp PM
    Thanks - I having trouble getting tsmuxer running.

    I did also attache the MP4 files

    It sounds like your recommended usage of tsmuxer is concatenating all of the m4s files - and what I'm looking for is something to 'fix' the mp4 / ts files so that they could be 'cat'ed (I'll actually have some php code to stream the bytes back to the client - similar to cat).
    Quote Quote  
  9. I didn't use it but it's recommended for corrupted mp4 https://github.com/anthwlock/untrunc No clue if the prog can handle your m4s
    Quote Quote  
  10. Member
    Join Date
    Dec 2024
    Location
    North America
    Search Comp PM
    Thanks for info / link - I'll check it out
    Quote Quote  
  11. Member
    Join Date
    Dec 2024
    Location
    North America
    Search Comp PM
    still not having a lot of luck - any idea anyone?
    Quote Quote  
  12. You can use mkvToolnix to combine your files into one as it recognizes these m4s: add the first file, select it, right mouse click and hit append files. After then TSMuxer to change mkv into transport stream.
    Image
    [Attachment 83868 - Click to enlarge]
    Quote Quote  
  13. Member
    Join Date
    Dec 2024
    Location
    North America
    Search Comp PM
    I think your solutions are just different ways to do what I can do with ffmpeg. What I'm looking for is something that makes my video (mp4 or ts) capable of being cat'ed together to give a smooth, seamless video. Ultimately I'd like to deliver individual files, one right after the other, somewhat real time to have 'live' video.

    For some reason m4s files aren't that way - I'm trying to figure out how to make them be able to run one right after the other without actually merging them.

    Don't get me wrong - I appreciate your help. I'm learning a lot about other tools. But I still don't know what my actual problem is - why does the video freeze and audio continue when cat'ing the ts files?
    Quote Quote  
  14. Member
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    Try your original ffmpeg command with this flag and then see if it will concatenate and play continuously:

    Code:
    ffmpeg -i video.mp4 -codec copy -movflags dash -f mpegts video.ts
    PB
    Quote Quote  
  15. Member
    Join Date
    Dec 2024
    Location
    North America
    Search Comp PM
    Thanks autodidact - I was very hopeful of your suggestion - I think that's probably the only flag I have tried. Unfortunately it's still not working.
    Quote Quote  
  16. I don't understand what is your problem. All the above works, as well as the following code:
    Code:
    ffmpeg -f concat -safe 0 -i mylist.txt -c copy joined.ts
    There is a bit of garbage in the files which cannot be removed by using i.e. -map_metadata -1. To get rid of it you may try to demux and mux files again.
    Quote Quote  
  17. Member
    Join Date
    Dec 2024
    Location
    North America
    Search Comp PM
    Originally Posted by autodidact View Post
    Try your original ffmpeg command with this flag and then see if it will concatenate and play continuously:

    Code:
    ffmpeg -i video.mp4 -codec copy -movflags dash -f mpegts video.ts
    I was hoping that this would make .ts files that could be cat'ed together and have no stuttering. Do you think it does that (aka - did I do something wrong) ?

    This
    Code:
    ffmpeg -f concat -safe 0 -i mylist.txt -c copy joined.ts
    does work but I'd need to feed it all of the segments and get one merged file. I'd like to deliver individual files
    Last edited by bigdealfred; 4th Dec 2024 at 20:15.
    Quote Quote  
  18. Member
    Join Date
    Feb 2004
    Location
    United States
    Search Comp PM
    This example run on linux in a folder of sequential segments generates a list on-the-fly, sends to stdout and pipes to vlc:

    Code:
    ffmpeg -f concat -safe 0 -i <(for f in ./*.m4s; do echo "file '$PWD/$f'"; done) -c copy -f mpegts - | vlc -
    There are other examples on this page including some that relate to streaming.
    https://trac.ffmpeg.org/wiki/Concatenate

    I don't think the standard cat is going to do what you need. There are various ways to use the concat function in ffmpeg and creating an output file may not be necessary. The files are not corrupt but stream segments so a muxer that can handle that is needed.
    PB
    Quote Quote  
  19. bigdealfred - I individually change format from m4s (from post #6) to ts, and then concatenating them, using command lines from above, no freezing after concat, it is ok. Can you describe what "trying to deliver them real time" means?
    Last edited by _Al_; 4th Dec 2024 at 23:30.
    Quote Quote  
  20. Member
    Join Date
    Dec 2024
    Location
    North America
    Search Comp PM
    Attached are example segments - I was hoping to be able to convert .m4s into these type of .ts.

    For systems that deliver encrypted .ts files, I have some php code that downloads the m3u8, download the ts files inside, decrypts them and then 'echo's the data back to the client - and then starts over - giving real time video.

    The ffmpeg concat works well. I'm having issues with the 'looping' concat (adding files to the merge list as they're being downloaded and decrypted) and outputting to the pipe. I can't tell if it's a sync issue with adding the new files or if my processing can't keep up with 'real-time'. Not only is video crappy, VLC is throwing errors

    Image
    [Attachment 83959 - Click to enlarge]


    I thought if I could find out the cause of the freeze - or what ffmpeg does to fix that during a merge, I could do 'that' the m4s to make it a clean .ts.

    I appreciate everyone's help.
    Image Attached Files
    Quote Quote  
  21. Originally Posted by bigdealfred View Post
    can't keep up with 'real-time'
    not exactly what sequence of a procedure you are doing, and on what end (yours, client) but you error say exactly that:
    "No such a file or directory"
    So either file is not ready or there is a syntax error in a path
    Quote Quote  
  22. Tried to concat it on ubuntu now and beginning of cancat file is glitched a bit, but so that first provided 1733100301.ts file as well. That was tested on VLC.
    If using mpv player on Ubuntu, playback of both files was ok.
    Quote Quote  
  23. Member
    Join Date
    Dec 2024
    Location
    North America
    Search Comp PM
    Originally Posted by _Al_ View Post
    Originally Posted by bigdealfred View Post
    can't keep up with 'real-time'
    not exactly what sequence of a procedure you are doing, and on what end (yours, client) but you error say exactly that:
    "No such a file or directory"
    So either file is not ready or there is a syntax error in a path
    "No such a file or directory" happens when I cat video.ts : vlc - (some kind of vlc configuration issue)
    Quote Quote  
  24. Member
    Join Date
    Dec 2024
    Location
    North America
    Search Comp PM
    Originally Posted by _Al_ View Post
    Tried to concat it on ubuntu now and beginning of cancat file is glitched a bit, but so that first provided 1733100301.ts file as well. That was tested on VLC.
    If using mpv player on Ubuntu, playback of both files was ok.
    Yes - I wish I could get the 4ms files to work that way.

    Does anyone know the source of the freezing - or what I can do to fix it?
    Quote Quote  
  25. Error says, that it cannot load file, why it would be configuration issue?

    Source of freezing might be, as always is at the beginning if starting a stream, where audio and video might not start at the same time. vlc tries to start with audio and there is no video, so it stutters. mpv might start with audio and jumps into audio. That is just a guess. Cutting the beginning might work of fixing the ts video by some transport stream fixer. But really I have no idea what you are doing, the more I read about this, the more lost I am. Now you say you wish m4s would be ok to concat, but ffmpeg does not allow to copy to m4s, only to mp4.
    If I copy all ts to mp4 and concat them, in ubuntu, it plays without glitch at the beginning in VLC, it plays ok.
    Quote Quote  



Similar Threads

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