How to remove a specific line from multiple text file at once? - windows

I have several m3u text files that include links to streams. To be able to store them on my computer, I'm trying to convert them all to mp4. However, when I attempt to convert it, VLC just produces a 4 second video, not the actual stream.
However, if I modify each of those files to remove the extra m3u links and leave only the 1080p stream, VLC will then output the proper stream.
So my goal is to delete all lines from several text files except for the linesĀ 1, 2, 3, 4, 9, and 10.
I hope someone can help, since I have hundreds of those files and don't want to spend the next three weeks manually correcting each one.
Here's an exemple of how those files are written:
#EXTM3U
#EXT-X-VERSION:5
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-STREAM-INF:BANDWIDTH=2516370,AVERAGE-BANDWIDTH=2516370,CODECS="mp4a.40.2,avc1.640020",RESOLUTION=1280x720,CLOSED-CAPTIONS=NONE
https:link.com
#EXT-X-STREAM-INF:BANDWIDTH=1640580,AVERAGE-BANDWIDTH=1640580,CODECS="mp4a.40.2,avc1.640020",RESOLUTION=960x540,CLOSED-CAPTIONS=NONE
https:link.com
#EXT-X-STREAM-INF:BANDWIDTH=4755240,AVERAGE-BANDWIDTH=4755240,CODECS="mp4a.40.2,avc1.64002a",RESOLUTION=1920x1080,CLOSED-CAPTIONS=NONE
https:link.com
#EXT-X-STREAM-INF:BANDWIDTH=994068,AVERAGE-BANDWIDTH=994068,CODECS="mp4a.40.2,avc1.64001f",RESOLUTION=640x360,CLOSED-CAPTIONS=NONE
https:link.com
#EXT-X-STREAM-INF:BANDWIDTH=697078,AVERAGE-BANDWIDTH=697078,CODECS="mp4a.40.2,avc1.64001e",RESOLUTION=480x270,CLOSED-CAPTIONS=NONE
https:link.com

Related

How to Concat with FFMPEG?

I'm having an issue where I'm trying to concat 4 audio files into one file, I want them to not play on each other, only after each other. I was wondering if this was possible.
I have it working somewhat right now, however, the final result is weird, the first, second, and 4th ones sound okay, but the 3rd one, the longest in my case, is sped up like a chipmunk.
Here is the command I typed
ffmpeg -f concat -i mylist.txt -c copy output.wav
And here is the mylist.txt:
file 'Alert.wav' file 'Attention.wav' file 'voice.wav' file 'Clear.wav'
I am trying to get the results to be the same length, and the same quality as their source files. Just, connected in one file, kind of like if you open a video editor and attach them into one, but that in my case will not work because I need it to be automated.

Determining the original recording date of a video file

I received a video file that I am trying to determine when the video was originally recorded. The file is a .mov video that is muxed with an audio file. The EXIF data shows multiple creation/modification dates which I recognize as the dates that the file was saved to my local computer, but the last creation date shown is from an earlier date that is adjusted to Eastern Time (UTC -4), which I believe may be the date the file was originally recorded. However, for that earliest creation date, it shows Lavf58.20.100 as the Encoder tag which I am unsure if that earlier creation date is just the date the video file was muxed or if it is in fact the date the video was originally recorded.
I used exiftool v. 12.44 to view the EXIF data from the video and attempted to validate the results against other known video and image files. In doing so, the last creation dates displayed on my known files were consistent with the dates the original files were recorded, however, they lacked the Lavf58.20.100 Encoder tag. I ran additional files that were muxed using FFMPEG, which show the Lavf Encoder tag, but those files did not return Creation Dates. Included is the screen capture of the EXIF data from the .mov file I am trying to determine its original recording date.
First a minor nitpick. Not all metadata is EXIF data. Your output shows mostly Quicktime data (and file system data), which is the standard used in video. EXIF data can exist in a video file, but it is non-standard.
Because a lot of video editing programs do not copy or save metadata when creating new files, it can be hard, if not impossible to know the original date of a video file. For example, using ffmpeg at any point in the workflow without including the -map_metadata option will strip the file of all embedded metadata.
The fact that CreationDate still exists and that the Track*Date and Media*Date tags, as well as the CreateDate/ModifyDate tags have values at all indicates a better quality program was used with this file. But that still depends upon what happened further upsteam in the workflow.
Your output is missing a lot of data due to the fact that many video tags are duplicates with the same name. This especially pertains to the Track*Date and Media*Date tags, as there would be copies of these for every track, meaning there would be at least one set for the video track and one set for the audio track, more if there are additional tracks.
Run this command on your file to see all the date/time related tags in the file, including duplicates and the groups they belong to. It is a variation of the command from exiftool FAQ #3, (always use the FAQ #3 command). From there you can try and determine what the original date was, if it is possible. Also note that most of these time stamps are supposed to be set to UTC, though the accuracy of that depends upon the program that created the file in the first place
exiftool -time:all -G1 -a -s file.mov

ffmpeg read the current segmentation file

I'm developing a system using ffmpeg to store some ip camera videos.
i'm using the segmentation command for store each 5 minutes a video for camera.
I have a wpf view where i can search historycal videos by dates. In this case i use the ffmpeg command concat to generate a video with the desire duration.
All this work excelent, my question is: it's possible concatenate the current file of the segmentation? i need for example, make a serch from the X date to the current time, but the last file is not generated yet by the ffmpeg. when i concatenate the files, the last one is not showing because is not finish the segment.
I hope someone can give me some guidance on what I can do.
Some video formats can always be playable during the build process. That is, you can make a copy of the unfinished segmentation directly and use it to merge.
I suggest you use flv or ts format to do this. mp4 is not supported. Also note that there is a delay from encoding to actually writing to the disk.
I'm not sure if direct copy will cause some data problems at the end of the segmentation file, but ffmpeg will ignore this part of the data during the merge process, so the merged video should be fine.

When recording MP4 using ffmpeg suddenly power off

Now I used C language and ffmpeg realize a multiplex real-time audio and video to MP4 files of the program and everything works fine, but when in the process of reuse of sudden power failure, the recording is MP4 file is damaged, VLC can not play this file.
I think reason is no call to write the trailer function av_write_trailer , causing index and time stamp information lost, I use araxis merge tool compared the successful call av_write_trailer function of file and a no av_write_trailer to call the damaged files and found two different points:
1. Damaged files in the file header box number value not right
2. The damaged file no end of file.
Now I want to repair after power on my program can automatically repair the damaged files, in Google did not find effective methods.
my train of thought is in the normal recording process saves per second a damaged file is missing two information: box number and end of file, save it to a local file, when writing the MP4 file integrity delete this file after, if power off damaged, then in the next power, read the file and the corresponding information to write the damaged files corresponding position to. But now the problem is that I don't know how to save the number of box and the end of the file, I this is feasible? If possible, what should I do? Looking forward to your reply!
The main cause of MP4 file damage is due to header or trailer not written properly on the file , then , whole file become a junk data. Thus none of the media player able to play the broken mp4 file.
So,
First , broken file has to be repaired before playing the file.
there are some applications and tricks available to repair and get the data back
links are given below :
http://grauonline.de/cms2/?page_id=5 (Windows / Mac)(paid :( )
https://github.com/ponchio/untrunc (Linux based OS)(ofcourse,free!!!)
Second, Manually repairing the corrupt file using HEX editor.
Logic behind this hack :
This hack requires a broken mp4 file and good video file where both videos are captured from the same camera .Also its size should be larger than the broken mp4 file.
Open both video file in any HEX editor. Copy trailer part from good video file to broken video file and save it!Done!!
Note : Always have a backup of video file.
follow these links for detailed informations :
http://janit.iki.fi/repair-corrupted-mp4-video/
https://www.lfs.net/forum/thread/45156-Repair-a-corrupt-mp4-file%3F
http://hackaday.com/2015/04/02/manual-data-recovery-with-a-hex-editor/
http://www.hexview.org/hex-repair-corrupt-file.html
Third, Even tough MP4 file has many advantages , this kind of error is unpredictable and difficult to handle it.
Thus , Using format such as MPG and AV_CODEC_ID_MPEG1VIDEO/AV_CODEC_ID_MPEG2VIDEO (FFMPEG) may help to avoid this kind of error. The mentioned MPG format does not require any header/trailer.if there is any sudden power failure MPG file can play the file whatever frames are stored so far.
Note : there are other formats and codec also available with this kind of properties.

How to play different video files as one file?

I want to concatenate different video files (playlist) as one file, so user can play them as if they were one movie, I read about pre-buffering, but I didn't find a clear way to do so, also is it possible to just play a certain portion of a file without downloading the whole file,
Regards,

Resources