Which (meta)data in video to correct (and how) when ...

Using applications, configuring, problems
Post Reply
Message
Author
Mysp
Posts: 47
Joined: Mon 08 Jun 2009, 10:39
Location: Czech Republic

Which (meta)data in video to correct (and how) when ...

#1 Post by Mysp »

(English is not my native language. I hope explanation of the problem will be clear enough).

Background information: I have a lot of recordings from satellite TV. They are all in TS (Transport stream) container and the format is:
(a) video in MPEG2 in standard resolution (PAL 720x576)
(b) video in MPEG4 in HD resolution
Finally, I am about to edit all the recordings I want to keep. I do not want to change the container or format. All I want is just to cut off some unneeded parts of the video at the very beginning and/or at the end and leave the rest of file unchanged (without reencoding).
Originally, I planed to use Avidemux: I know it and use it for similar task for DV-AVI video. However, Avidemux 2.4 or 2.5 seems to have several problems with MPEG in TS. (I did not tried Avidemux 2.6 - I did not find any PET or SFS for Puppy.) I have tried some other video editors, but all seem to be dedicated to other tasks. Finally, I have found that ffmpeg can relatively easily and fast do that (Yes, I know ffconvert GUI for Puppy/Slacko, too. But for my task I need to deal directly with CLI switches.) Currently, I am using the latest 32bit static build by Burek (ffmpeg.static.32bit.2012-09-28.tar.gz from http://ffmpeg.gusari.org/static/). The static build is huge (16 MB) compared to Puppy built-in ffmpeg, but there were some issues with older ffmpeg both in Quirky and Slacko and they seem not to support "copy all streams" option. The number of options for CLI is enormous and difficult for me, but after several hours with ffmpeg documentation and some test it seem to be quite easy and probably all I need is something like this (I just do some shorter test, did not convert full-length video yet):

Code: Select all

ffmpeg-static -i "88.001.uropa Jagellonica.ts" -codec copy -ss 65 -t 250 Test1.ts
where:
-i is of course input filename
-codec copy will copy all streams from source video (it is much easier syntax then explicitly specify each stream: this seems to be necessary in older FFMPEG built-in Quirky/Slacko)
-ss will discard specified numbers of seconds from the very beginning of the video
-t just specified number of second (after -ss) wil be copied

The problem: is not related to "copy all streams" procedure above, but it is in original video recording. I can play original video both on satellite recorder and on PC in Quirky or Slacko with built-in GNOME player, but the satellite recorder is probably setting wrong length of the video and/or some timestamps. The GNOME player will still play it, but: it will show wrong length of the video, (sometimes) wrong current position and (the most important) have problems with seeking specific position in video (including using "Fast forward" and "Rewind" buttons and all related "move" keyboard short cuts.

First, I have tried to add option ‘-timestamp time (output)’
Set the recording timestamp in the container. I use -timestamp now
but it seem not to have the desired effect. Then I looked for several hours at many other options (and tried some of them like -vsync -copyts, -copytb) but I do know understand these options too much and my tests did not have the desired effect (maybe I just use them in wrong way.
What is the right option(s) and where exactly to add them inside the whole command to correct the above described problem?
Thank you very much in advanced.

Final note: Sometimes the video is divided in 2 or 3 TS files (the recorder create new file every time 1 GB size is reached). Then I will (for example) join them as: (a) cut off 90 second from 1st file, copy the rest (b) copy the whole 2nd file (c) copy just 180 second from very beginning ot the 3rd file.
The correction method for timestamps and metadata should work in this situation, too (if possible).

Example 1: Very short test video (about 40 seconds: 39.88 seconds acording to ffmpeg).

Code: Select all

Input #0, mpegts, from 'AutosalonPokus40.ts':
  Duration: 00:00:39.88, start: 1.475333, bitrate: 6272 kb/s
  Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 15000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101](slo): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16, 192 kb/s
When playing this video in GNOME-player
a) initially Gnome player will show position/length at status bar as 0:00/0:16 (instead of 0:00/0:40)
b) after reaching second 16, the current position will be 17, 18, ... 40, but length will stay 0:16

Example 2: Real video divided in two files
88.000.uropa Jagellonica.ts with 1 GB size limit (1 078 067 200 bytes exactly)
88.001.uropa Jagellonica.ts with rest of the video (about 275 MB)

Code: Select all

Input #0, mpegts, from '88.000.uropa Jagellonica.ts':
  Duration: 00:24:45.14, start: 21122.168844, bitrate: 5807 kb/s
  Stream #0:0[0x2b](cze): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
    Stream #0:1[0x5c](cze): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16, 256 kb/s
    Stream #0:2[0x60](qaa): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16, 192 kb/s
    Stream #0:3[0xa3]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 15000 kb/s, 27 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:4[0x3b6]: Unknown: none ([5][0][0][0] / 0x0005)
  
  Input #0, mpegts, from '88.001.uropa Jagellonica.ts':
  Duration: 00:07:34.74, start: 22607.208844, bitrate: 4966 kb/s
    Stream #0:0[0x2b](cze): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
    Stream #0:1[0x5c](cze): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16, 256 kb/s
    Stream #0:2[0x60](qaa): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16, 192 kb/s
    Stream #0:3[0xa3]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 15000 kb/s, 25.58 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:4[0x3b6]: Unknown: none ([5][0][0][0] / 0x0005)
You can notice that start value in each part are very high and Gnome-player then display very nonsense values for current position and video length. Ant the most important: fast forward, rewind and seek problems (as described above) are really big.
For the first part Gnome say 5:52:03/9:27, for the second part 6:16:47/2:28

I can upload test video to some server, if it help to solve the problem, but even the very short (40 second video) is about 30 MB.

Once more, thank you very much for your help.

Post Reply