I'm seeking for a way how to manipulate timestamps of PCAP files.
For example, substract amount of times from packets or add.
Is it possilbe to do so on wireshark or tshark? Or do I need to write some lua code to do so?
Please let me know if you've known a way.
Thanks
You can adjust timestamps with editcap. For example, to adjust the timestamp of all packets 1 hour later:
editcap -t 3600 file.pcap file_plus1hour.pcap
You can also adjust the timestamps in Wireshark using "Edit -> Time Shift..."; however, it's currently not possible to save the time-shifted file from Wireshark.
Related
In normal case, saving a live stream in a local file is easy. But I'm looking for a way to keep last X amount of time of the stream. i.e last 2 days.
Obviously the file must be updated constantly.
Any help? Thanks.
I'm writing a player for an RTMP stream using the ffmpeg API. I know the usual way to get the stream info into an input format is with avformat_find_stream_info. And that works. However, because it's RTMP it takes a long time for it to scan enough of the stream to pick up the info. I've played with max_analyze_duration and probesize and it's a bit better, but it still takes 10-15 seconds to load. That's way too long for my application.
But I'm the one making the stream on the other end, so I know exactly what's in it. It seems like it would make more sense for me to tell the input format what the stream info is rather than asking it to search for it. But I can't find any examples of this, and my attempts to use avformat_new_stream with an input format aren't working.
Does anyone know if this is possible? And if so, could you point me in the direction of how?
Thanks!
This is what is known as an XY problem
Yes, you can spoof the sequence header (assuming h.264/aac). But it won't accomplish what you want. What is happening is your RTMP server (reflector) is eating the first GOP. So even if the analyze was done faster, you must first wait for the first video key frame anyway.
You need to configure your RTMP server to send the full GOP (in nginx+rtmp the setting is wait_key on)
I'm using 'vlc/ffmpeg' package to grab the screen and convert it to H.264 file.
The problem arises when the host is heavily loaded. I need to maintain correct time stamps and use the 5 fps (relatively low frame rate). Yet sometimes the resulting file jumps few seconds forward, apparently due to frame loss.
I can deal with the frame loss, it's OK, but I need to duplicate lost frames to maintain correct timing.
My configuration file:
vlc.exe screen:// -I dummy --verbose=2 --one-instance :screen-fps=5 :screen-caching=10000 :sout=#transcode{venc=x264{preset=ultrafast,tune=zerolatency},vcodec=h264,fps=5,vb=3000,width=1024,height=576,acodec=none}:file{dst="C:\tmp\output.mp4"}
What should I add/config to preserve proper time stamps and clip duration?
Many thanks for your help.
OK, I found adding 'copyts' option does exactly what I need.
Is there any way to insert User Data (Start code = 0X1B2) in a MPEG stream?
What I am looking for is a simple tool, script or some tips using and Hex Editor...
Or you may have a patch for ffmpeg (libavcodec and libavformat) that allows to do that?
If you're going to insert user data into a Transport Stream, the easiest solution is when it is in a PID of its own not overlapping with any of the existing PIDs in the stream - where you need not worry about adjusting the continuity counter of the original stream packets following the insertion points.
But it is really impossible to make assumptions about what PIDs you can expect in a TS stream, and if you're trying to generalize it - you would need to take care of adjusting the continuity counter in the TS header for packets of the same PID.
How can I determine the length (in ms) of an audio file (e.g .wav) using RubyAudio
s = RubyAudio::Sound.open("1.wav")
You can get the SongInfo by:
songInfo = s.info
And then the song info contains the sample rate and the number of frames which you can use to calculate the duration of the sound file:
duration = songInfo.frames / songInfo.samplerate
From a cursory look at the docs, it looks like you can't do that with RubyAudio.
Have you tried looking at ruby-mp3info? I don't know if it's still actively developed, nor if it works for multiple audio formats, but it claims to be able to give you the duration of an mp3.
An alternate way would be to do an estimate based on the bitrate and the file length.
RubyAudio doesn't appear to have been updated in six years and its documentation is sparse. If you're able I'd recommend using rtaglib instead.
However, if you're married to RubyAudio it looks like you can get both a frame count (Audio::Soundfile#frames) and a sample (frame) rate (Audio::Soundfile#samplerate). Knowing this you should be able to divide the number of frames by sample rate to get the length of the file in seconds.