PDA

View Full Version : trying to download a ts packet using command line


wer783
08-22-2012, 01:34 AM
I would like to capture a TS packet using a command line method so that I can automate downloading the entire stream.

Here's an example packet from nbcolympics.com. It is a 5-second transport stream packet.

http://r2---dfw06s22.c.youtube.com/videoplayback/id/04666a084b642e97/itag/96/source/yt_live_broadcast/sq/20?cmbypass=yes&dur=3.960&expire=1345638024&ip=68.102.215.142&ipbits=8&keepalive=yes&key=ck1&live=1&maudio=1&playlist_type=CLEAN&pmbypass=yes&ratebypass=yes&signature=1D0F20738B1CEBEA1711E36FF7DBB94B0645F7BE .01E5AC61B92E677E1D7E423CD01C0325DF83665C&sparams=ip%2Cipbits%2Cexpire%2Cid%2Citag%2Csource% 2Cratebypass%2Ccmbypass%2Cplaylist_type%2Cmaudio%2 Cpmbypass&sver=3&upn=ShJ_MXyWFFM&ms=lv&mv=m&mt=1345615193&cms_redirect=yes&file=seg.ts

I can open this link in VLC player and it will play or let me save it to disk. I can also open it in a web browser and save it to disk. I cannot figure out any way to do it using command line. I tried to do it with VLC's command line options but it says it cannot be opened.

Can anyone give me an example command line string, using any program, to do this?

nwtim
08-22-2012, 01:42 PM
I've found no easy way to do this yet, but I haven't had a lot of time to put into it. As for getting all the 5-second file segments, a really easy way to do it is with Streaming Video Recorder (http://www.apowersoft.com/streaming-video-recorder.html) (apowersoft), but it can't join the files. I've explained this challenge to their support and they say they're working on it and it will be in the next version.

VLC can play the entire folder of these crystal clear files, but there's a short pause at the end of each segment before the following one plays. Perhaps VLC has a way of exporting the playing of this sequential playlist to a file(?).

chap
08-22-2012, 03:01 PM
VLC can play the entire folder of these crystal clear files, but there's a short pause at the end of each segment before the following one plays. Perhaps VLC has a way of exporting the playing of this sequential playlist to a file(?).
simple use ffplay(ffmpeg)

wer783
08-22-2012, 03:14 PM
Thanks for the information on Streaming Video Recorder. I tried it out and was able to get it to give me a bunch of pieces. The only problem is that it just grabs what is currently playing and so there's not any way to automate the process. So it's not any better than using ffmpeg to capture the stream by reading the m3u8 playlist file described in the big nbcolympics.com thread. But I like that program because I have been using GetFlv for a long time and thought it was the only game in town. It looks like this program will do similar things.

By the way, anyone reading this who just wants an easy way to capture videos from nbcolympics.com should see this thread: http://stream-recorder.com/forum/capture-stream-nbcolympics-com-t13287.html

It's explained very well there and is easy to do. The only reason I'm trying to directly download each 5-second segment is that the connections will usually timeout before I can download an entire video. It usually takes a lot of tries to get the full video. Some of the longer ones, like the ones that are 7 hours long, I've been uanble to get.

I've tried to use wget and VLC command line and they don't work, but it's really easy to download these segments if you just paste the link in VLC player or a web browser. But this would take forever and wouldn't be practical. deadmund seemed to have figured out how to download individual packets this with VLC player from a script, but has still not come back to explain. It seems like there should be some way to do this, given that it's so easy to do with a GUI.

nwtim
08-22-2012, 05:38 PM
...
VLC can play the entire folder of these crystal clear files, but there's a short pause at the end of each segment before the following one plays. Perhaps VLC has a way of exporting the playing of this sequential playlist to a file(?).
simple use ffplay(ffmpeg)Please explain. Can ffmpeg/ffplay join all these files into one? What switches would I use?

nwtim
08-22-2012, 05:53 PM
Please explain. Can ffmpeg/ffplay join all these files into one? What switches would I use?I see something about concatenating multiple files into one in para. 3.14.2 on this page (http://ffmpeg.org/faq.html#Concatenating-at-the-file-level). I can't imagine having to join thousands of files using this method - yikes! There must be an easier way.

BTW, if I use ffmpeg to capture the file, is there a simple way to record a 4 hour video in 30 minute segments?

wer783
08-22-2012, 09:23 PM
Please explain. Can ffmpeg/ffplay join all these files into one? What switches would I use?

The method in the thread above doesn't involve concatenating files. First, do this (copied from MrPaul's post in that thread):

•Start Firefox
•Open web console (CTRL-SHIFT-K)
•Optional - Unselect CSS, JS, & Logging on the menu bar
•Type in "m3u8" in the filter on top right
•Start the video you want to see
•Click the gear icon on bottom right of video and select the quality you want (typically 1080) and you'll see a new m3u8 file appear
•Use this URL for the "-i" option of ffmpeg

The m3u8 file is a playlist that contains all those small files. Next, what you do is run this command, where URL is the m3u8 playlist file and output.ts is the name of the output video file:

ffmpeg.exe -i URL -c copy output.ts

nwtim
08-23-2012, 12:47 AM
The method in the thread above doesn't involve concatenating files. First, do this (copied from MrPaul's post in that thread):

•Start Firefox
•Open web console (CTRL-SHIFT-K)
•Optional - Unselect CSS, JS, & Logging on the menu bar
•Type in "m3u8" in the filter on top right
•Start the video you want to see
•Click the gear icon on bottom right of video and select the quality you want (typically 1080) and you'll see a new m3u8 file appear
•Use this URL for the "-i" option of ffmpeg

The m3u8 file is a playlist that contains all those small files. Next, what you do is run this command, where URL is the m3u8 playlist file and output.ts is the name of the output video file:

ffmpeg.exe -i URL -c copy output.tsThat's what I'm doing. I was just hoping there was a way to avoid the time involved in getting all that video all over again. Oh well, I guess I'll just batch record them over the next few nights. I wonder how long the NBCOlympics site will continue to host those videos?

wer783
08-23-2012, 01:31 PM
That's what I'm doing. I was just hoping there was a way to avoid the time involved in getting all that video all over again. Oh well, I guess I'll just batch record them over the next few nights. I wonder how long the NBCOlympics site will continue to host those videos?

You can download the m3u8 file and edit it so that you only download part of the video. You would delete the files in the playlist that you don't want to play. For example, you might leave only 500 files in a playlist. Then you'd cat the ffmpeg output files together with ffmpeg. I tested this method awhile back and it works perfectly and it's the way I'll be doing it if I can't figure out a way to download each segment individually.

If anyone has any ideas how to download each segment individually, I would still like to know how to do it. I have an idea which I haven't tried yet. Use a download manager. I haven't used one in a long time, not since I was using dial-up. I remember being able to use a pretty advanced download list with GetRight, so maybe it would work.

The reason I want to get the segments individually is that you have the most options when you get the raw data. Since it's trivial to cat ts files together (just use a binary file combiner), there's no disadvantage to doing it this way, and if you have raw data you can fix problems. For example, in one stream on nbcolympics.com, there's some bad data that would easily be fixable but causes ffmpeg to make the audio go out of sync. I can fix this in the raw data files I've downloaded of that stream. And I'm not really doing this just to get the Olympics. I all ready have everything I really wanted from the Olympics. I assume I will be able to use what I find out in the future for other things.

thankyousuperman
08-26-2012, 04:15 PM
You can download the m3u8 file and edit it so that you only download part of the video. You would delete the files in the playlist that you don't want to play. For example, you might leave only 500 files in a playlist. Then you'd cat the ffmpeg output files together with ffmpeg. I tested this method awhile back and it works perfectly and it's the way I'll be doing it if I can't figure out a way to download each segment individually.



Just registered to say: Wow, that worked for me. I had to learn a bit about m3u syntax first in order to know exactly what to truncate in the modified m3u8 file, but after that it was smooth sailing. Saved the modified m3u8 to my hard drive and opened it in ffmpeg which started saving it right away. I'd previously used -ss and ffmpeg would go through the entire playlist before saving what I wanted, and by that time the link expired. Editing m3u8 is the way to go with really long videos.

Thanks again!

maberajo1
08-30-2012, 09:08 PM
Just registered to say: Wow, that worked for me. I had to learn a bit about m3u syntax first in order to know exactly what to truncate in the modified m3u8 file, but after that it was smooth sailing. Saved the modified m3u8 to my hard drive and opened it in ffmpeg which started saving it right away. I'd previously used -ss and ffmpeg would go through the entire playlist before saving what I wanted, and by that time the link expired. Editing m3u8 is the way to go with really long videos.

Thanks again!

Hi , I also just registered. I've been figuring out this ffmpeg and how to downloading video in the last days. I got 3 videos downloaded but I still can't figure how you can download the m3u8 file and edit it. Could you help. With long videos, I really feel it could help me a lot. I am using FF webdeveloper to spot the file and then I do copy. I dont know (my tech skills are very very below average) how to download it. Thanks in advance...