text:
ffmpeg audio sync issue when using hstack filter
I have two .webm videos which I'm trying to process into a horizontally stacked single video with one video on the left and one video on the right.
The individual video files are called left.webm and right.webm. They both have perfect audio/video sync when I play them. I'm using the following command to do the hstack:
/usr/bin/ffmpeg -y -i left.webm -i right.webm -filter_complex "[0:v]setpts=PTS-STARTPTS[left];[1:v]setpts=PTS-STARTPTS[right];[left][right]hstack=inputs=2[v];[a:0][1:a]amerge[a]" -map "[v]" -map "[a]" -ac 2 merged.webm -loglevel error

The command works fine, but I have a synchronisation issue between the audio and the video on the merged result.
Reading through some SE posts (audio sync appears to be quite a common issue) lead me to using ffprobe to try and understand the parameters of each of the left and right videos and to look for anomalies like frame rate differences.
ffprobe produces this for left.webm:
Stream #0:0: Video: vp9 (Profile 0), yuv420p(tv), 320x240, SAR 1:1 DAR 4:3, 1k fps, 1k tbr, 1k tbn, 1k tbc (default)
Stream #0:1: Audio: opus, 48000 Hz, stereo, fltp

And right.webm:
Stream #0:0: Video: vp9 (Profile 0), yuv420p(tv), 320x240, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
Stream #0:1: Audio: opus, 48000 Hz, stereo, fltp (default)

I noticed that left.webm has an fps of 1k, so I tried transcoding that down to 30fps to match right.webm with:
ffmpeg -i left.webm -r 30 -vcodec copy left2.webm

But I still have the audio synchronisation (it's about 200-300ms off, at my best guess) in the resulting merged video when I do the hstack filter.
I'm not sure what to check next given both videos appear to have identical parameters and play perfectly individually.
Any thoughts on what to look at or try next would be gratefully received!
Thanks.
ffprobe -show_entries packet=pts_time -select_streams v -read_intervals %5 -of compact=p=0:nk=1 -v 0 left.webm
0.438000
0.439000
0.439000
0.459000
0.487000
0.516000
0.547000
0.579000
0.610000
0.642000
0.675000
0.708000
0.742000
0.774000
0.807000
0.840000
0.873000
0.906000
0.907000
0.940000
0.973000
1.006000
1.039000
1.072000
1.105000
1.139000
1.205000
1.272000
1.338000
1.339000
1.405000
1.471000
1.538000
1.604000
1.671000
1.738000
1.804000
1.871000
1.872000
1.904000
1.937000
1.971000
2.004000
2.037000
2.071000
2.104000
2.137000
2.138000
2.170000
2.204000
2.237000
2.270000
2.304000
2.337000
2.370000
2.404000
2.437000
2.470000
2.471000
2.504000
2.537000
2.570000
2.604000
2.637000
2.670000
2.704000
2.737000
2.770000
2.803000
2.804000
2.837000
2.870000
2.903000
2.937000
2.970000
3.003000
3.037000
3.070000
3.103000
3.137000
3.138000
3.170000
3.203000
3.237000
3.270000
3.303000
3.337000
3.370000
3.403000
3.437000
3.470000
3.471000
3.503000
3.537000
3.570000
3.603000
3.636000
3.670000
3.703000
3.736000
3.770000
3.803000
3.804000
3.836000
3.870000
3.903000
3.936000
3.970000
4.003000
4.036000
4.070000
4.103000
4.136000
4.137000
4.170000
4.203000
4.236000
4.270000
4.303000
4.336000
4.369000
4.403000
4.436000
4.469000
4.470000
4.503000
4.536000
4.569000
4.603000
4.636000
4.669000
4.703000
4.736000
4.769000
4.803000
4.804000
4.836000
4.869000
4.902000
4.936000
4.969000

ffprobe -show_entries packet=pts_time -select_streams v -read_intervals %5 -of compact=p=0:nk=1 -v 0 right.webm
0.007000
0.040000
0.040000
0.074000
0.107000
0.140000
0.174000
0.207000
0.240000
0.274000
0.307000
0.340000
0.373000
0.374000
0.407000
0.440000
0.474000
0.507000
0.540000
0.574000
0.607000
0.640000
0.674000
0.707000
0.707000
0.740000
0.774000
0.807000
0.840000
0.874000
0.907000
0.940000
0.974000
1.007000
1.040000
1.040000
1.074000
1.107000
1.140000
1.174000
1.207000
1.240000
1.274000
1.307000
1.340000
1.373000
1.374000
1.407000
1.440000
1.474000
1.507000
1.540000
1.574000
1.607000
1.640000
1.674000
1.707000
1.707000
1.740000
1.774000
1.807000
1.840000
1.874000
1.907000
1.940000
1.974000
2.007000
2.040000
2.040000
2.074000
2.107000
2.140000
2.174000
2.207000
2.240000
2.274000
2.307000
2.340000
2.373000
2.374000
2.407000
2.440000
2.474000
2.507000
2.540000
2.574000
2.607000
2.640000
2.674000
2.707000
2.707000
2.740000
2.774000
2.807000
2.840000
2.874000
2.907000
2.940000
2.974000
3.007000
3.040000
3.040000
3.074000
3.107000
3.140000
3.174000
3.207000
3.240000
3.274000
3.307000
3.340000
3.373000
3.374000
3.407000
3.440000
3.474000
3.507000
3.540000
3.574000
3.607000
3.640000
3.674000
3.707000
3.707000
3.740000
3.774000
3.807000
3.840000
3.874000
3.907000
3.940000
3.974000
4.007000
4.040000
4.040000
4.074000
4.107000
4.140000
4.174000
4.207000
4.240000
4.274000
4.307000
4.340000
4.373000
4.374000
4.407000
4.440000
4.474000
4.507000
4.540000
4.574000
4.607000
4.640000
4.674000
4.707000
4.707000
4.740000
4.774000
4.807000
4.840000
4.874000
4.907000
4.940000
4.974000

ffprobe -show_entries packet=pts_time -select_streams a -read_intervals %5 -of compact=p=0:nk=1 -v 0 left.webm
-0.007000
0.014000
0.034000
0.054000
0.074000
0.094000
0.114000
0.134000
0.154000
0.174000
0.194000
0.214000
0.234000
0.254000
0.274000
0.294000
0.314000
0.334000
0.354000
0.374000
0.394000
0.414000
0.434000
0.454000
0.474000
0.494000
0.514000
0.534000
0.554000
0.574000
0.594000
0.614000
0.634000
0.654000
0.674000
0.694000
0.714000
0.734000
0.754000
0.774000
0.794000
0.814000
0.834000
0.854000
0.874000
0.894000
0.914000
0.934000
0.954000
0.974000
0.994000
1.014000
1.034000
1.054000
1.074000
1.094000
1.114000
1.134000
1.154000
1.174000
1.194000
1.214000
1.234000
1.254000
1.274000
1.294000
1.314000
1.334000
1.354000
1.374000
1.394000
1.414000
1.434000
1.454000
1.474000
1.494000
1.514000
1.534000
1.554000
1.574000
1.594000
1.614000
1.634000
1.654000
1.674000
1.694000
1.714000
1.734000
1.754000
1.774000
1.794000
1.814000
1.834000
1.854000
1.874000
1.894000
1.914000
1.934000
1.954000
1.974000
1.994000
2.014000
2.034000
2.054000
2.074000
2.094000
2.114000
2.134000
2.154000
2.174000
2.194000
2.214000
2.234000
2.254000
2.274000
2.294000
2.314000
2.334000
2.354000
2.374000
2.394000
2.414000
2.434000
2.454000
2.474000
2.494000
2.514000
2.534000
2.554000
2.574000
2.594000
2.614000
2.634000
2.654000
2.674000
2.694000
2.714000
2.734000
2.754000
2.774000
2.794000
2.814000
2.834000
2.854000
2.874000
2.894000
2.914000
2.934000
2.954000
2.974000
2.994000
3.014000
3.034000
3.054000
3.074000
3.094000
3.114000
3.134000
3.154000
3.174000
3.194000
3.214000
3.234000
3.254000
3.274000
3.294000
3.314000
3.334000
3.354000
3.374000
3.394000
3.414000
3.434000
3.454000
3.474000
3.494000
3.514000
3.534000
3.554000
3.574000
3.594000
3.614000
3.634000
3.654000
3.674000
3.694000
3.714000
3.734000
3.754000
3.774000
3.794000
3.814000
3.834000
3.854000
3.874000
3.894000
3.914000
3.934000
3.954000
3.974000
3.994000
4.014000
4.034000
4.054000
4.074000
4.094000
4.114000
4.134000
4.154000
4.174000
4.194000
4.214000
4.234000
4.254000
4.274000
4.294000
4.314000
4.334000
4.354000
4.374000
4.394000
4.414000
4.434000
4.454000
4.474000
4.494000
4.514000
4.534000
4.554000
4.574000
4.594000
4.614000
4.634000
4.654000
4.674000
4.694000
4.714000
4.734000
4.754000
4.774000
4.794000
4.814000
4.834000
4.854000
4.874000
4.894000
4.914000
4.934000
4.954000
4.974000
4.994000

ffprobe -show_entries packet=pts_time -select_streams a -read_intervals %5 -of compact=p=0:nk=1 -v 0 right.webm
-0.007000
0.014000
0.034000
0.054000
0.074000
0.094000
0.114000
0.134000
0.154000
0.174000
0.194000
0.214000
0.234000
0.254000
0.274000
0.294000
0.314000
0.334000
0.354000
0.374000
0.394000
0.414000
0.434000
0.454000
0.474000
0.494000
0.514000
0.534000
0.554000
0.574000
0.594000
0.614000
0.634000
0.654000
0.674000
0.694000
0.714000
0.734000
0.754000
0.774000
0.794000
0.814000
0.834000
0.854000
0.874000
0.894000
0.914000
0.934000
0.954000
0.974000
0.994000
1.014000
1.034000
1.054000
1.074000
1.094000
1.114000
1.134000
1.154000
1.174000
1.194000
1.214000
1.234000
1.254000
1.274000
1.294000
1.314000
1.334000
1.354000
1.374000
1.394000
1.414000
1.434000
1.454000
1.474000
1.494000
1.514000
1.534000
1.554000
1.574000
1.594000
1.614000
1.634000
1.654000
1.674000
1.694000
1.714000
1.734000
1.754000
1.774000
1.794000
1.814000
1.834000
1.854000
1.874000
1.894000
1.914000
1.934000
1.954000
1.974000
1.994000
2.014000
2.034000
2.054000
2.074000
2.094000
2.114000
2.134000
2.154000
2.174000
2.194000
2.214000
2.234000
2.254000
2.274000
2.294000
2.314000
2.334000
2.354000
2.374000
2.394000
2.414000
2.434000
2.454000
2.474000
2.494000
2.514000
2.534000
2.554000
2.574000
2.594000
2.614000
2.634000
2.654000
2.674000
2.694000
2.714000
2.734000
2.754000
2.774000
2.794000
2.814000
2.834000
2.854000
2.874000
2.894000
2.914000
2.934000
2.954000
2.974000
2.994000
3.014000
3.034000
3.054000
3.074000
3.094000
3.114000
3.134000
3.154000
3.174000
3.194000
3.214000
3.234000
3.254000
3.274000
3.294000
3.314000
3.334000
3.354000
3.374000
3.394000
3.414000
3.434000
3.454000
3.474000
3.494000
3.514000
3.534000
3.554000
3.574000
3.594000
3.614000
3.634000
3.654000
3.674000
3.694000
3.714000
3.734000
3.754000
3.774000
3.794000
3.814000
3.834000
3.854000
3.874000
3.894000
3.914000
3.934000
3.954000
3.974000
3.994000
4.014000
4.034000
4.054000
4.074000
4.094000
4.114000
4.134000
4.154000
4.174000
4.194000
4.214000
4.234000
4.254000
4.274000
4.294000
4.314000
4.334000
4.354000
4.374000
4.394000
4.414000
4.434000
4.454000
4.474000
4.494000
4.514000
4.534000
4.554000
4.574000
4.594000
4.614000
4.634000
4.654000
4.674000
4.694000
4.714000
4.734000
4.754000
4.774000
4.794000
4.814000
4.834000
4.854000
4.874000
4.894000
4.914000
4.934000
4.954000
4.974000
4.994000

Can you share the files?

Hi Mulvya - that would be tricky as it's two people talking in a video conference (confidentiality etc). I can see if I can produce a couple of test videos to use.
Is there something in particular you would look at in the two videos that I could look at and report on?

The timestamps for the audio and video in both the files. Run and capture output of ffprobe -show_entries packet=pts_time -select_streams v -read_intervals %5 -of compact=p=0:nk=1 -v 0 file.webm. Run same command with v changed to a. Do this for both files.

OK, thanks for the help. Output is <too long for SE - will past up somewhere else and link>

I have edited the main post and added the output there. Thanks Mulvya.

The left video has a late starting video but not audio, so first try is to skip the setpts filters for both videos.

And bingo. Now everything is in sync.
I am batch processing these. Should I generally skip the setpts filter or is it a good idea in certain circumstances ?

If A and V don't start at same time, and if V is significantly delayed then that video will have a frozen first frame till its start PTS is reached. Other than that, it should be fine.

Got it, so as part of any pre-processing I should check those start values and then act accordingly. Thanks for your help Mulvya (and for all your other help all over the internet - I've seen your name in countless threads that have helped me!).

I'm not sure how I confirm that as the answer @mulvya ?
Also, the input videos were produced by me from separate audio and video streams which I merged with an offset (to correct original lipsync in the individual videos) using:
/usr/bin/ffmpeg -y -itsoffset 0.43064 -i video.webm -i audio.opus -c:v copy -c:a copy left.webm
Is there a way I can merge them and reset these timestamps so that they do not get offset in this way when I do the horizontal stack to combine them?

Apply a negative offset to the audio.

For files with differing start times of video and audio streams, the PTS values should not be changed else sync will be lost.
So,
ffmpeg -y -i left.webm -i right.webm -filter_complex "[0:v][1:v]hstack=inputs=2[v];[a:0][1:a]amerge[a]" -map "[v]" -map "[a]" -ac 2 merged.webm


text:
Is this video 50p or 25p?
I have some footage shot with a Lumix DMC-FZ38 with the video format set to AVCHD and the SH (super high?) quality setting.
The manual says:

[AVCHD Lite] (With audio)
When set to [SH]: 1280x720 pixels
(50p recording * /17 Mbps, only when card is used) /
When set to [H]: 1280x720 pixels
(50p recording * /13 Mbps, only when card is used) /
When set to [L]: 1280x720 pixels
(50p recording * /9 Mbps, only when card is used)
*CCD output is at 25 fps

I think 50p means 50 progressive frames per second. According to advice given in the comments, CCD means "Charge Coupled Device", which is the type of sensor my camera uses. That would seem to indicate that the sensor outputs 25 frames per second.
When I import a video from the camera (00000.MTS) into Blender's Video Sequence Editor and tell it to use the frame rate from the video, it sets the project frame rate to 50fps. However, when I render it, the video plays at double speed, which seems to indicate that it was 25fps after all.
If I extract PNGs from the first second of the video using ffmpeg -i 00000.MTS -to 1 tmp%d.png, it gives me 25 png files, indicating 25fps.
ffprobe 00000.MTS reports:
Input #0, mpegts, from '01.MTS':
  Duration: 00:29:58.18, start: 0.366667, bitrate: 14025 kb/s
  Program 1
    Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], 50 fps, 25 tbr, 90k tbn, 100 tbc
    Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s

According to this mailing list,

tbr is guessed from the video stream and is the value users want to
  see when they look for the video frame rate, except sometimes it is
  twice what one would expect because of field rate versus frame rate.

So ffprobe reports both 50 fps and 25 tbr. Here tbr is half of fps, not double. What's the distinction here?
SMPlayer and VLC both report 50 frames per second.
What is the actual frame rate of my footage?

CCD means charge-coupled device, a type of camera sensor. But you really should split this into two questions or change the title to emphasize your second question, since I suspect that is the more important one to you.

I changed the title, rephrased slightly, placing emphasis on the second question. I also added info about what SMPlayer, VLC and Blender does with the file in question.

Run ffmpeg -i 00000.MTS -vsync 0 -to 1 tmp%d.png for an accurate count of no of frames in first second.

With or without -vsync 0, I get 25 png files.

AVCHD Lite uses 25p/30p shooting rate and records it to 50p/60p container using frame doubling. Panasonic did that because, I presume, they were unable to shoot true 50p/60p at that time, on the other hand AVCHD and Blu-Ray specifications do not support 720p25 and 720p30 videos. Panasonic did this to stay compatible with the AVCHD format.
I guess the reason was that this way you can author the original clips as-is onto AVCHD Disc or Blu-Ray Disc, and they will be fully compliant and playable by standard Blu-Ray Player.
Nowadays a camera simply stores whatever it records in one of the standard containers like MP4, then you edit/author in whatever format you prefer. But ten years ago the compatibility between AVCHD and Blu-Ray was a selling point for both formats.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
How can i crop part of a video while recording from desktop in real time using ffmpeg?
I'm using this line to record from the desktop to a video file:
ffmpeg -f gdigrab -framerate 24 -i desktop -preset ultrafast -pix_fmt yuv420p out.mp4

But this will record the whole desktop.
Is there any way to record in real time only specific area/part of the desktop ?

Two ways:
#1 By specifying gdigrab options:
ffmpeg -f gdigrab -framerate 24 -video_size 960x540 -offset_x 240 -offset_y 450 -i desktop -preset ultrafast -pix_fmt yuv420p out.mp4

This captures a 960x540 video whose top-left corner is at (240,450) measured from the top-left corner of the display.
#2 By cropping it post-capture
ffmpeg -f gdigrab -framerate 24 -i desktop -vf crop=960:540:240:450 -preset ultrafast -pix_fmt yuv420p out.mp4

The former is preferable.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Creating rigid grid structures for arranging video clips
I'm quite new to video editing but I am not new to graphic design.
One of the most effective methods of organizing content in design is to use a grid. A grid lets things look good, stay consistent, and be predictable. I want to use a design grid to arrange video clips beside text and images.

I wanted to know how to create a grid arrangement with columns, rows, gutters... I looked things up and all I could find were tutorials for resizing elements, without grids. If I were to start trying on my own I would go about it the following way: draw off-colour pixels in the corners of the areas where I want to put elements. It would probably take a very long time and be imprecise if I tried that though. Another idea I had was that I could use a green screen effect to create the boxes on the grid and then just place the images as the greenscreen content but that also feels like a hack and would surely end up losing parts of my clips at the edges.
The way I imagine things I would have a nice "snap to grid" system that would let me resize clips to fill in grid spaces easily like in indesign/illustrator.
Through my workplace I have access to Sony Vegas but I own a mac so I could jump to any editor that would allow me to have this effect.
Any help is appreciated.

Use markers and regions to note your columns.


text:
Import Excel file with subtitles and timestamps
I typed up a transcript of a video, and inserted time stamps at the beginning of each change of speaker, using https://transcribe.wreally.com/.  Then I put everything into Excel.  I copied the timestamp column and pasted it into a new column to its right, but moving the whole thing up one row.  I figured that would make the segments abut perfectly.  I added an empty additional column where the program would expect to see where each segment ended (where the new one start.
Then I followed the instructions at https://video.stackexchange.com/a/14518/19609 and installed Subtitle Edit.  I tried pasting the columns of data in, and I tried opening the tab-delimited file I had made.  It's giving me nonsense in the second column (which indicates the end timestamp).
What software and method can I use for getting my typed transcript into a properly formatted srt file, so I can publish it with Youtube?

Sometimes YouTube will generate subtitles for you. You might be doing work you don't have to do anyway.

Turns out my timestamps were all shifted.  When I corrected them things worked. "Subtitle Edit" (free, open source) was helpful and not as resource-hoggy as Aegisub -- https://en.wikipedia.org/wiki/Subtitle_Edit. // @DigiVisionMedia - as I was fiddling around, I experimented with the automatic captioning.  It worked on a short segment but not on the whole recording, which was quite long.  Also, since there were multiple speakers, less than optimal audio quality, and some overlapping voices, the automatically generated transcript was of limited usefulness.

Yes, that's been my experience too. I can't seem to find any logic behind YouTube's automatic caption decisions. It seems there's a sweet spot for length and content. It's not too useful to me either (my content is mostly one hour lectures) mostly because it's unpredictable.


text:
How can I replicate Google's "Glamour" effect in Premiere Pro?
I need to replicate the video effect named "Glamour" in the Google Photo app using Adobe Premiere or any other video editor with professional tools. Here is a sample. Can someone point me in the right direction?

It's a simple matter of combining motion and scaling keyframes for the animation of the photos with a dip to white transition. The background can be achieved by duplicating each photo to a lower layer, scaling them up and applying a gaussian blur.

There are a few things going on here:

The image is enlarged, slightly blurred and scaling up in the background
Another copy of the image has a white border added to it, and both fades in and scales down in front of the background. Some of these copies are at a slight angle.
Once the foreground image has reached its final position, a bloom filter is applied to the entire image with the amount of bloom increasing over time. It's used as a transition, so that the outgoing clip gets more and more bloom, and also fades into the incoming clip, which starts out with a lot of bloom and gets less and less over time.

So you'll need 2 layers - one for the foreground and one for the background. You'll need to blur, scale, and animate the scale of the background layer. Then you'll need to add a border to the foreground layer, animate its scale over time, and possibly rotate it. You may need to precompose that into a single layer and apply the bloom filter as a transition as described above.


text:
Licence for including (with HTML embed tag) others YouTube videos
Do I need any Licence for including (with HTML embed tag) others YouTube videos in my website?
I just want to show some cool YouTube videos in my website, but those videos aren't neither created by me nor by my friends. I don't want to add any download link; just to include the videos

I'm voting to close this question as off-topic because this is not about video production, but rather a question about law and websites.

If you use the YouTube embed feature then it is allowed according to the YouTube terms of service. If the uploader doesn't want their video to be embedded they can simply turn it off in the video manager.
What is not allowed, whether the embed feature is enabled or not, is that you rip the video from YouTube and then distribute it from your own servers. The only exception is that the video author gave you permission to do this.
Also, you may get a cease and desist letter if you have a habit of just putting a ton of YouTube videos on your webpages and some ads and no original content of your own.

Do I need the author's permission, for Uploading the video to my web server?

@user Yes. As a general rule of thumb, you are not allowed to save other people's content unless they give you permission. Since it is on youtube, as a user of the youtube site you submit yourself to the YouTube terms of service which are that you will not download videos from youtube and upload them somewhere else.

In practicality, this really only matters on videos that make money from ads. Videos of your mom's cat probably don't count.

If the author gave me the permission for Uploading the video into my website, do I have to upload any files (like permission.txt/license.txt/the author's E-sign or something like that) in my server?

@user Not legally, but it's a good idea to get things in writing.

Except there's creative commons and gnu licenses that do require such a thing. Those are generic licenses that authors can just publicize that their content falls under.

Do I need any Licence for just downloading a video from YouTube, with vidmate Android app?

Is it legal, to download YouTube videos with vidmate?

@user Technically against YouTube terms of service, which can bring legal action theoretically, but I've never heard of that happening. If you have the creator's permission it doesn't really make a difference. It all comes down to acquiring the creator's permission.

If it's available on the videos you want, just use the YouTube embed feature. https://developers.google.com/youtube/player_parameters#Embedding_a_Player You don't need permission if it's available.


text:
[ac3]Estimating duration from bitrate, [matroska]Starting new cluster due to timestampe and muxing overhead errors when muxing .mkv and .ac3 in .mkv
when I muxyng .mkv file and .ac3 file without converting I had next errors:

[ac3]Estimating duration from bitrate, this may be inaccurate
[matroska]Starting new cluster due to timestampe
muxing overhead: 0.078666%

ac3 error output appears before .ac3 file information

mkv and muxing overhead in end of console output appears

Script that i use:
ffmpeg -i input1.mkv -i input2.ac3 -map 0:v -map 1:a -map 0:a -map 0:s -c:v copy
-c:a:1 copy -c:s copy -metadata:s:a:0 language={lang} -metadata:s:a:0 title="title1"
-metadata:s:a:1 title="title2" output.mkv

I try to copy .mkv file and .ac3 separately and .mkv copying only with muxing overhead and .ac3 cppying with ac3 error(without muxing overhead).
Could you explain what the reason of this problem, and help me with it?
Also after muxing in the end of output video file absent small part of audio stream from second file! How To manage with this issue?
Thanks

There aren't any errors, only info messages.

Yes, but there is no small part of audio stream in the end of output film

Run ffmpeg -i input2.ac3 -c copy input2.mp4 and then try your command with this new file.

Mulvya, no, I do it even with ac3 encoding, but in the end, when I copy this streams in 1 output files I have 3 minutes empty audio stream in the end of film. As I understand this issue appears because size of concrete video frame not comparable with audio stream frame... Do you have any idea what argument should I set in script to solve this issue? May be set bitrate or buffer size?

Share the full log of the command.

What part of console log you interest in?


text:
FIXED - AfterEffect graph editor is stuck on displaying one particular curve and does not refresh

The graph editor constantly displays the curves for the positions of a puppet pin, even when I'm not selecting anything and when I select something else.
Deleting the layer will get rid of it. But I want to find an alternative because I've spent a lot of time animating the pin.
Does anyone have any ideas?
FIXED:  It seems to be a bug with AE. My solution was by just duplicating the old layer and then deleting the old layer.

Please put your solution into an answer, not the question. You can accept your own answer. That way it will be easier to find the solution too.

It seems to be a bug with AE. My solution was by just duplicating the old layer and then deleting the old layer.


text:
Melt transitions from command line
I have a source video file (@60 fps), and a "list" of frames of interest. I'm trying to get a "compilation" of 6 seconds clips (3 before, 3 after the said frame), add a fade in between them and output said video.
This is what I'm currently using:

melt test1.mp4 in=2340 out=2700 -mix 120 test1.mp4 in=4140 out=4500 -mix 120 test1.mp4 in=5220 out=5580 -blank 1500 -consumer sdl

The transition between the first and second clips is done correctly, the one between the 2'nd and 3'rd however is NOT processed.
Any ideas?

As a side note, I will have about 10-15 clips per movie, so I plan to move this to either a textfile or xml scheme later, but I'm trying to make this work from the command line for the time being.
Edit:
Ok, so I figured it out. Turns out you need to apply the "-mix" flag to the SECOND clip, and it will mix between the previous and current clip.

melt test1.mp4 in=2340 out=2700 test1.mp4 in=4140 out=4500 -mix 120 -mixer luma test1.mp4 in=5220 out=5580 -mix 120 -mixer luma -blank 1500

This now works correctly, and adds a fade between the first and second clip, as well as between the second and the third.

Ok, so I figured it out. Turns out you need to apply the "-mix" flag to the SECOND clip, and it will mix between the previous and current clip.

melt test1.mp4 in=2340 out=2700 test1.mp4 in=4140 out=4500 -mix 120 -mixer luma test1.mp4 in=5220 out=5580 -mix 120 -mixer luma -blank 1500

This now works correctly, and adds a fade between the first and second clip, as well as between the second and the third.


text:
Problem converting TS to MP4 container with ffmpeg
I have a video stream I captured with VLC and saved as a TS file. The codecs within the file are h.264/AAC, so I thought it would be trivial to use ffmpeg to convert the file from a TS container to MP4 container, so that I can play the file in QuickTime. I used the following command:
ffmpeg -i vlc-output.ts -acodec copy -vcodec copy car-free\ tourism.mp4

All seemed fine, but whilst the resulting file can be opened in QuickTime, after playing 1s of the file, it jumps back to the beginning and then plays the audio only, with the video staying black. The video plays fine in VLC and MPlayerX. I can't understand why QuickTime won't play the file. The codecs look compatible, and the file length looks fine. Am I doing something wrong? Is there additional metadata that QuickTime needs?
I somehow suspect that the issue lies with a lack of complete bit rate metadata, but am out of my depth.
Thanks for any help.
The output from ffprobe for both files is as follows:
vlc-output.ts
[~/Desktop] 113: ffprobe vlc-output.ts                                                   10:51:13
ffprobe version 3.3.3 Copyright (c) 2007-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma --enable-vda
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'vlc-output.ts':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: mp41avc1
    creation_time   : 2015-06-23T20:48:30.000000Z
    playback_requirements: QuickTime 6.0 or greater
    playback_requirements-eng: QuickTime 6.0 or greater
    encoder         : vlc 2.2.1 stream output
    encoder-eng     : vlc 2.2.1 stream output
  Duration: 00:01:50.09, start: 0.000000, bitrate: 1149 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x360, 1051 kb/s, 25 fps, 25 tbr, 1000k tbn, 50 tbc (default)
    Metadata:
      creation_time   : 2015-06-23T20:48:30.000000Z
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 93 kb/s (default)
    Metadata:
      creation_time   : 2015-06-23T20:48:30.000000Z
      handler_name    : SoundHandler

car-free tourism.mp4
[~/Desktop] 114: ffprobe car-free\ tourism.mp4                                           10:51:36
ffprobe version 3.3.3 Copyright (c) 2007-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma --enable-vda
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'car-free tourism.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.71.100
  Duration: 00:01:50.09, start: 0.000000, bitrate: 1150 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x360, 1051 kb/s, 25 fps, 25 tbr, 1000k tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 93 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

When I use the -report option when running the rewrap command, I get the following log file:
ffmpeg-20170824-164217.log
ffmpeg started on 2017-08-24 at 16:42:17
Report written to "ffmpeg-20170824-164217.log"
Command line:
ffmpeg -i vlc-output.ts -acodec copy -vcodec copy -report "car-free tourism.mp4"
ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma --enable-vda
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Splitting the commandline.
Reading option '-i' ... matched as input url with argument 'vlc-output.ts'.
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'copy'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'copy'.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option 'car-free tourism.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url vlc-output.ts.
Successfully parsed a group of options.
Opening an input file: vlc-output.ts.
[NULL @ 0x7f8f8e004200] Opening 'vlc-output.ts' for reading
[file @ 0x7f8f8ce00300] Setting default whitelist 'file,crypto'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] Processing st: 0, edit list 0 - media time: 0, duration: 109960000
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] Processing st: 1, edit list 0 - media time: 0, duration: 4854784
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] Before avformat_find_stream_info() pos: 76497 bytes read:98304 seeks:0 nb_streams:2
[h264 @ 0x7f8f8e008400] nal_unit_type: 9, nal_ref_idc: 0
[h264 @ 0x7f8f8e008400] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x7f8f8e008400] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x7f8f8e008400] nal_unit_type: 6, nal_ref_idc: 0
[h264 @ 0x7f8f8e008400] nal_unit_type: 5, nal_ref_idc: 3
[h264 @ 0x7f8f8e008400] user data:"x264 - core 118 r2085 8a62835 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=5 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=36 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=50 keyint_min=25 scenecut=0 intra_refresh=0 rc_lookahead=40 rc=cbr mbtree=1 bitrate=1200 ratetol=1.0 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 vbv_maxrate=1200 vbv_bufsize=600 nal_hrd=none ip_ratio=1.40 aq=1:1.00"
[h264 @ 0x7f8f8e008400] Reinit context to 640x368, pix_fmt: yuv420p
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8f8e004200] After avformat_find_stream_info() pos: 99278 bytes read:131072 seeks:0 frames:2
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'vlc-output.ts':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: mp41avc1
    creation_time   : 2015-06-23T20:48:30.000000Z
    playback_requirements: QuickTime 6.0 or greater
    playback_requirements-eng: QuickTime 6.0 or greater
    encoder         : vlc 2.2.1 stream output
    encoder-eng     : vlc 2.2.1 stream output
  Duration: 00:01:50.09, start: 0.000000, bitrate: 1149 kb/s
    Stream #0:0(eng), 1, 1/1000000: Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x360, 1051 kb/s, 25 fps, 25 tbr, 1000k tbn, 50 tbc (default)
    Metadata:
      creation_time   : 2015-06-23T20:48:30.000000Z
      handler_name    : VideoHandler
    Stream #0:1(eng), 1, 1/44100: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 93 kb/s (default)
    Metadata:
      creation_time   : 2015-06-23T20:48:30.000000Z
      handler_name    : SoundHandler
Successfully opened the file.
Parsing a group of options: output url car-free tourism.mp4.
Applying option acodec (force audio codec ('copy' to copy stream)) with argument copy.
Applying option vcodec (force video codec ('copy' to copy stream)) with argument copy.
Successfully parsed a group of options.
Opening an output file: car-free tourism.mp4.
[file @ 0x7f8f8ce04fe0] Setting default whitelist 'file,crypto'
Successfully opened the file.
Output #0, mp4, to 'car-free tourism.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: mp41avc1
    encoder         : Lavf57.71.100
    playback_requirements: QuickTime 6.0 or greater
    playback_requirements-eng: QuickTime 6.0 or greater
    Stream #0:0(eng), 0, 1/1000000: Video: h264 (Main) ([33][0][0][0] / 0x0021), yuv420p, 640x360, q=2-31, 1051 kb/s, 25 fps, 25 tbr, 1000k tbn, 1000k tbc (default)
    Metadata:
      creation_time   : 2015-06-23T20:48:30.000000Z
      handler_name    : VideoHandler
    Stream #0:1(eng), 0, 1/44100: Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 93 kb/s (default)
    Metadata:
      creation_time   : 2015-06-23T20:48:30.000000Z
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
No more output streams to write to, finishing.
frame= 2749 fps=0.0 q=-1.0 Lsize=   15455kB time=00:01:50.04 bitrate=1150.5kbits/s speed= 588x
video:14120kB audio:1258kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.503515%
Input file #0 (vlc-output.ts):
  Input stream #0:0 (video): 2749 packets read (14459053 bytes);
  Input stream #0:1 (audio): 4741 packets read (1287842 bytes);
  Total: 7490 packets (15746895 bytes) demuxed
Output file #0 (car-free tourism.mp4):
  Output stream #0:0 (video): 2749 packets muxed (14459053 bytes);
  Output stream #0:1 (audio): 4741 packets muxed (1287842 bytes);
  Total: 7490 packets (15746895 bytes) muxed
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x7f8f8ce050a0] Statistics: 60 seeks, 7583 writeouts
[AVIOContext @ 0x7f8f8ce00480] Statistics: 16617055 bytes read, 17 seeks

The video file I'm trying to rewrap is an STV news report stream specified in an m3u8 file, which I captured with VLC. I've put a copy of it here.

Update: The VLC TS is malformed.
First run
ffmpeg -i vlc-output.ts -c copy ffmpeg-output.ts

and then
ffmpeg -i ffmpeg-output.ts -c copy working.mp4

The main thing that looks off is the timebase 1000k tbn.
Try
ffmpeg -i vlc-output.ts -c copy -video_track_timescale 90k car-free\ tourism.mp4

Thanks for the suggestion, unfortunately it has the same result (except that the video stream says 90k tbn:
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x360, 1051 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)

Then try with a low number, like, say 600.

That didn't make a difference to the result. However, I have also realised that the -report option produces a log file (hadn't seen that before), so I've updated the question with the contents of this file from when you first asked me to run the rewrap with a report. Maybe the contents from that file could help identify what's going on? I really appreciate your help, thanks.

Or another approach: is there some way for me to analyse the .ts file and determine what the timescale should be?

The resolution changes mid-way. Try ffmpeg -ss 30 -i vlc-output.ts -c copy -video_track_timescale 600 -report car-free\ tourism.mp4 If it works, try with lower ss values till it still works.

Thanks again for your help. I tried this, and no luck. Same result, both with the initial 0-1s and then jumping back to the beginning, and no video displayed. I tried with -ss 60 and -ss 90 as well, and go the exact same result (except that the audio obviously starts 60s and 90s in, and the total length is shorter). Anything else I can try?

Share the source file, if you can.

Thanks Mulvya. I've added information and a link to the source file at the end of the original post ⬆.

Sorry, I only just noticed that you updated this answer. Thanks so much, first copying to a new TS file worked! No need for me to mess with the timebase, when I followed your instruction to copy to a new TS file, then copy from that to an MP4, all works well. So good to finally have this archived properly, your help is much appreciated.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
FFMPEG LIBVMAF segmentation fault
I am trying to compare two videos using the libvmaf in ffmpeg 4.0. I have compiled and installed from source VMAF and FFMPEG and FFMPEG has built-in support for libvmaf. That's the ffmpeg configuration:
$ ffmpeg -version
ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
configuration: --pkg-config-flags=--static --extra-libs='-lpthread -lm' --toolchain=hardened --enable-gpl --enable-nonfree --enable-version3 --disable-stripping --enable-avisynth --enable-libass --enable-libfontconfig --enable-libfreetype --enable-libvmaf --enable-libfribidi --enable-libgme --enable-libgsm --enable-librubberband --enable-libshine --enable-libsnappy --enable-libssh --enable-libtwolame --enable-libwavpack --enable-libzvbi --enable-openal --enable-sdl2 --enable-libdrm --enable-frei0r --enable-ladspa --enable-libpulse --enable-libsoxr --enable-libspeex --enable-avfilter --enable-postproc --enable-pthreads --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --disable-ffplay --enable-libopenjpeg --enable-libsrt --enable-libwebp --enable-libxvid --enable-libvidstab --enable-libopenh264 --enable-zlib --enable-openssl
libavutil      56. 14.100 / 56. 14.100
libavcodec     58. 18.100 / 58. 18.100
libavformat    58. 12.100 / 58. 12.100
libavdevice    58.  3.100 / 58.  3.100
libavfilter     7. 16.100 /  7. 16.100
libswscale      5.  1.100 /  5.  1.100
libswresample   3.  1.100 /  3.  1.100
libpostproc    55.  1.100 / 55.  1.100

My VMAF is version:
VMAF Development Kit (VDK) Version 1.3.5
VMAF Version 0.6.3

When I try to run the VMAF on both files using the following command I get a segmentation fault error and error about unknown format and segmentation fault. The syntax of my command is the following:

ffmpeg -i distorted.nut -i reference.nut -lavfi libvmaf -f null -

The NUT files in this case are both in raw format. I have tried to convert the nut to mp4 using libx264 but the result was exactly the same. I have uploaded the log file to wetransfer_link with the debug information.
If I run the VMAF manually from the VMAF install directory I got the results:
./run_vmaf yuv420p 1280 720 reference.nut distorted.nut --out-fmt json

This is the aggregated VMAF score:
"aggregate": {
        "VMAF_feature_adm2_score": 0.989985319391465,
        "VMAF_feature_motion2_score": 12.065062245699426,
        "VMAF_feature_vif_scale0_score": 0.6955497705160056,
        "VMAF_feature_vif_scale1_score": 0.956442334512976,
        "VMAF_feature_vif_scale2_score": 0.9785004960696057,
        "VMAF_feature_vif_scale3_score": 0.9873306412919364,
        "VMAF_score": 99.37877231666236,
        "method": "mean"
    }

I have checked and the library header libvmaf.h is under /usr/local/include, the library libvmaf.a under /user/local/lib and all the model files under /usr/local/share, so everything looks OK.

VMAF have changed their API yet again. Compile against 1.3.4.

I confirm that ffmpeg 4.0 and even the latest nightly are compatible only with VMAF VDK v. 1.3.4 or lower. I have opened a ticket in the ffmpeg bug tracker and also with VMAF.


text:
FFMPEG 4.0 skipping frames
I have noticed today that when I use ffmpeg 4.0 stable to decode some TS files into y4m or ffv1 it occasionally skips some frames. My input file has all the frames burned into the picture and I am extracting some frames at regular intervals. Sometimes it works just fine without any skipped frames but sometimes it skips one or two frames. I am using the following command to decode my input:
ffmpeg -i input.ts -vsync 0 output.y4m

and I am extracting the frames using:
ffmpeg -ss xxx -i output.y4m -vframes 1 xxx.png

I am substituting xxx with 0, 100, 200, etc and sometimes I see 1-2-3 frame dropped which is very annoying since I am trying to evaluate the PSNR afterwards and this is messing up the whole PSNR/SSIM evaluation.
[EDIT] I have executed the command which @Gyan suggested:
ffmpeg -v 99 -loglevel 99 -i test.ts \
-c:v rawvideo -vsync 0 \
-enc_time_base 1/1000 output.nut &> test.log

And here is the log file test.log

Y4M has no timestamps, only framerate in its header. So, if your source has any variability in its framerate, you'll see a shift in apparent timestamp in the Y4M.
e.g.
n     src     y4m
0       0       0
1    0.04    0.04
2    0.07    0.08
3    0.12    0.12
4    0.21    0.16
5    0.24    0.20
6    0.27    0.24
...

Over a long period, these perturbations can add up. Here frame #6 in src is at TS of src #5 in Y4M.
Edit: the sample TS file has VFR timestamps.
Use -c:v rawvideo -vsync 0 -vf setpts=N/FRAME_RATE/TB -an and save to .nut.

I have tested your solution and executed ffmpeg -i input.ts -c:v rawvideo -vsync 0 -enc_time_base 1/1000 output.nut but unfortunately I am losing one frame every ~1000 frames and this is pretty consistent loss. I have tried to add -an, remove the -enc-time-base  but it is always dropping a frame every ~1000 frames. As a matter of fact ffmpeg 3.2.4 works better in this regard and not dropping frames with the same input.

Share the full log of your command.

I have uploaded the test.log file using a link from wetransfer. It is rather bulky: 19Mb and my original video sequence has ~37000 frames. The link and the command could be seen in my original post, in the EDIT section.

Can you share the source file?

you can download it from here @Gyan

Can you upload it elswhere? Wetransfer is very slow. Drive or Dropbox..etc

Google Drive Link

Can't reproduce. I ran ffmpeg -i input.ts -vsync 0 output.y4m and then ffmpeg -ss xxx -i output.y4m -vframes 1 xxx.png and ffmpeg -ss xxx -i input.ts -vframes 1 xxx-ts.png to compare. I get the same frame for 5-6 values that I tried. Can you identify a few ss values that show the problem?

If you are using: ffmpeg -i test.ts -c:v rawvideo -vsync 0 -enc_time_base 1/1000 output.nut I am getting roughly one frame drop every 1000 frames. You can try to extract the frames every 3000 frames (60 sec). I believe the whole duration is 5 minutes so you can use -ss 0 - to get the first frame in the sequence and then -ss 60, -ss 120, -ss 180, -ss 240, -ss 300. With ffmpeg -i input.ts -vsync 0 output.y4m I am getting more random drops, sometimes it is only one frame for the whole duration, sometimes more. Please note that actually the file is looping and there is a skipped frame:14998.

You can confirm easily by comparing the burned-in frame number of the extracted frames and you should have exactly 3000 frames difference between the exported frames in case you use -ss 0, -ss 60, etc.

See edited cmd.

Thanks @Gyan, I will check later on the updated command, but the variable frame rate doesn't explain why the ffmpeg -i input.ts -vsync 0 output.y4m command was sometimes skipping a frame or two or sometimes it was working perfectly fine. How did you also checked the file for VFR and CFR? Is there a command in ffprobe to check for it?

There's a filter recently added: vfrdet. For the sample, it shows VFR:0.400005 (15185/22777) min: 1801 max: 3604). 40% of frames have non-standard duration. All should have 1800 units in this file.

You are absolutely right, @Gyan, I have tried your command and it works very well, I have also tried the detvfr filter and it showed me the deviation. I am wondering why the TS file has VFR, since I have recorded it with ffmpeg and I am pretty sure the input has CFR. Do I need to use -re in the recording command in this case in order to preserve the input frame rate(duration)? Can you also suggest a recording command not cutting the null padding (stuffing) from the TS?

TS is a VFR container, so in output you need to add -vsync cfr and also -r if that value is different than nominal input fps.

and what about the preserving the null padding at the output? By default ffmpeg is erasing all null PIDs which is creating PCR errors on the recorded stream, is it possible to preserve them?

Do you mean when creating the TS or when transferring to NUT?

When I am making the TS recording? Is there a way to tell ffmpeg not to trim the null padding?

Have you added -muxrate?

assuming that I am making a TS recording from Internet, do I need first to probe for the MUX rate and then configure it in the recording command? And if yes, how can I probe the mux rate with ffmpeg? And what if the input stream is not CBR but VBR with variable bitrate but still some null pad stuffing?


text:
ffmpeg MPTS detection of scrambled streams
I have couple of streams recorded with couple of services which are encrypted. Is there a way to check which streams/programs are scrambled in ffmpeg. I have tried with ffmpeg -i mpts.ts but it doesn't provide me a straight forward information about it. I have tried to google it but also didn't find any information.
This is the output of ffmpeg -i mpts.ts
ffmpeg version 3.3.3-1ubuntu1~16.04.york0 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
  configuration: --prefix=/usr --extra-version='1ubuntu1~16.04.york0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] SPS unavailable in decode_picture_timing
[h264 @ 0x55f7925f7ea0] non-existing PPS 0 referenced
[h264 @ 0x55f7925f7ea0] decode_slice_header error
[h264 @ 0x55f7925f7ea0] no frame!
[mpegts @ 0x55f7925d3780] Stream #10: not enough frames to estimate rate; consider increasing probesize
[mpegts @ 0x55f7925d3780] Stream #15: not enough frames to estimate rate; consider increasing probesize
[mpegts @ 0x55f7925d3780] Stream #19: not enough frames to estimate rate; consider increasing probesize
[mpegts @ 0x55f7925d3780] start time for stream 10 is not set in estimate_timings_from_pts
[mpegts @ 0x55f7925d3780] start time for stream 11 is not set in estimate_timings_from_pts
[mpegts @ 0x55f7925d3780] start time for stream 12 is not set in estimate_timings_from_pts
[mpegts @ 0x55f7925d3780] start time for stream 15 is not set in estimate_timings_from_pts
[mpegts @ 0x55f7925d3780] start time for stream 16 is not set in estimate_timings_from_pts
[mpegts @ 0x55f7925d3780] start time for stream 17 is not set in estimate_timings_from_pts
[mpegts @ 0x55f7925d3780] start time for stream 19 is not set in estimate_timings_from_pts
[mpegts @ 0x55f7925d3780] start time for stream 20 is not set in estimate_timings_from_pts
[mpegts @ 0x55f7925d3780] start time for stream 21 is not set in estimate_timings_from_pts
[mpegts @ 0x55f7925d3780] start time for stream 22 is not set in estimate_timings_from_pts
[mpegts @ 0x55f7925d3780] start time for stream 23 is not set in estimate_timings_from_pts
[mpegts @ 0x55f7925d3780] PES packet size mismatch
    Last message repeated 9 times
[mpegts @ 0x55f7925d3780] Could not find codec parameters for stream 0 (Unknown: none ([5][0][0][0] / 0x0005)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x55f7925d3780] Could not find codec parameters for stream 10 (Video: h264 ([27][0][0][0] / 0x001B), none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x55f7925d3780] Could not find codec parameters for stream 11 (Audio: ac3 ([6][0][0][0] / 0x0006), 0 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x55f7925d3780] Could not find codec parameters for stream 12 (Audio: ac3 ([6][0][0][0] / 0x0006), 0 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x55f7925d3780] Could not find codec parameters for stream 13 (Unknown: none ([5][0][0][0] / 0x0005)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x55f7925d3780] Could not find codec parameters for stream 14 (Unknown: none ([11][0][0][0] / 0x000B)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x55f7925d3780] Could not find codec parameters for stream 15 (Video: h264 ([27][0][0][0] / 0x001B), none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x55f7925d3780] Could not find codec parameters for stream 16 (Audio: ac3 ([6][0][0][0] / 0x0006), 0 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x55f7925d3780] Could not find codec parameters for stream 17 (Audio: ac3 ([6][0][0][0] / 0x0006), 0 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x55f7925d3780] Could not find codec parameters for stream 18 (Unknown: none ([5][0][0][0] / 0x0005)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x55f7925d3780] Could not find codec parameters for stream 19 (Video: h264 ([27][0][0][0] / 0x001B), none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x55f7925d3780] Could not find codec parameters for stream 20 (Audio: mp3 ([4][0][0][0] / 0x0004), 0 channels): unspecified frame size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x55f7925d3780] Could not find codec parameters for stream 21 (Audio: mp3 ([4][0][0][0] / 0x0004), 0 channels): unspecified frame size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x55f7925d3780] Could not find codec parameters for stream 22 (Audio: ac3 ([6][0][0][0] / 0x0006), 0 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x55f7925d3780] Could not find codec parameters for stream 23 (Audio: eac3 ([6][0][0][0] / 0x0006), 0 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpegts, from 'TS1007_ServusTV_HD_15min.ts':
  Duration: 02:47:55.81, start: 47397.187422, bitrate: 3808 kb/s
  Program 4911
    Metadata:
      service_name    : ORF1 HD
      service_provider: ORF
    Stream #0:10[0x780]: Video: h264 ([27][0][0][0] / 0x001B), none, 90k tbr, 90k tbn
    Stream #0:11[0x781](deu): Audio: ac3 ([6][0][0][0] / 0x0006), 0 channels
    Stream #0:12[0x782](mis): Audio: ac3 ([6][0][0][0] / 0x0006), 0 channels
    Stream #0:8[0x785](ger): Subtitle: dvb_teletext
    Stream #0:13[0x1c8e]: Unknown: none ([5][0][0][0] / 0x0005)
    Stream #0:14[0x1c8f]: Unknown: none ([11][0][0][0] / 0x000B)
  Program 4912
    Metadata:
      service_name    : ORF2W HD
      service_provider: ORF
    Stream #0:15[0xb68]: Video: h264 ([27][0][0][0] / 0x001B), none, 90k tbr, 90k tbn
    Stream #0:16[0xb69](deu): Audio: ac3 ([6][0][0][0] / 0x0006), 0 channels
    Stream #0:17[0xb6a](mis): Audio: ac3 ([6][0][0][0] / 0x0006), 0 channels
    Stream #0:7[0xb6d](ger): Subtitle: dvb_teletext
    Stream #0:13[0x1c8e]: Unknown: none ([5][0][0][0] / 0x0005)
    Stream #0:14[0x1c8f]: Unknown: none ([11][0][0][0] / 0x000B)
  Program 4913
    Metadata:
      service_name    : ServusTV HD Oesterreich
      service_provider: ServusTV
    Stream #0:18[0x5c]: Unknown: none ([5][0][0][0] / 0x0005)
    Stream #0:19[0xdff]: Video: h264 ([27][0][0][0] / 0x001B), none, 90k tbr, 90k tbn
    Stream #0:20[0xe00](ger): Audio: mp3 ([4][0][0][0] / 0x0004), 0 channels (clean effects)
    Stream #0:21[0xe01](eng): Audio: mp3 ([4][0][0][0] / 0x0004), 0 channels (clean effects)
    Stream #0:22[0xe03](ger): Audio: ac3 ([6][0][0][0] / 0x0006), 0 channels (clean effects)
    Stream #0:9[0xe04](ger): Subtitle: dvb_teletext
    Stream #0:23[0xe05](ger): Audio: eac3 ([6][0][0][0] / 0x0006), 0 channels
  Program 4914
    Metadata:
      service_name    : ServusTV HD Deutschland
      service_provider: ServusTV
    Stream #0:0[0x5b]: Unknown: none ([5][0][0][0] / 0x0005)
    Stream #0:1[0x1338]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:2[0x1339](ger): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 160 kb/s (clean effects)
    Stream #0:3[0x133a](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 160 kb/s (clean effects)
    Stream #0:4[0x133c](ger): Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, 5.1(side), fltp, 448 kb/s (clean effects)
    Stream #0:5[0x133d](ger): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
    Stream #0:6[0x133e](ger): Audio: eac3 ([6][0][0][0] / 0x0006), 48000 Hz, 5.1(side), fltp, 256 kb/s
  Program 4916
    Metadata:
      service_name    : ORF2N HD
      service_provider: ORF
    Stream #0:15[0xb68]: Video: h264 ([27][0][0][0] / 0x001B), none, 90k tbr, 90k tbn
    Stream #0:16[0xb69](deu): Audio: ac3 ([6][0][0][0] / 0x0006), 0 channels
    Stream #0:17[0xb6a](mis): Audio: ac3 ([6][0][0][0] / 0x0006), 0 channels
    Stream #0:7[0xb6d](ger): Subtitle: dvb_teletext
    Stream #0:13[0x1c8e]: Unknown: none ([5][0][0][0] / 0x0005)
    Stream #0:14[0x1c8f]: Unknown: none ([11][0][0][0] / 0x000B)

when you say straightforward...what information do you get from it?

@DrMayhem I have added the output of ffmpeg -i mpts.ts. Please note that in this MPTS only Servus TV HD Deutschland is FTA, the rest of the services are encrypted.

I'm not convinced this is on topic. @AJH - what do you think?

@DrMayhem what do you mean by that this might not be on topic?

This appears to be entirely an ffmpeg syntax question, so I don't think that is useful here. I haven't closed it, as I'd like wider opinion, but as per @AJHenderson's meta post on this, having the site end up as an ffmpeg usage and syntax site is not where we think it should be.

@DRMayhem This is a broadcast engineering question, so I'd argue that is on topic.

It doesn't appear that FFmpeg can decode the relevant information. You need something that can analyze the Conditional Access Table (CAT) and probably the other tables (PMT, PAT, etc.). DVB Inspector or DVBSnoop might display the relevant information, but I don't have first hand experience with either and working with the CAT.

Thanks for the hint Michael, I also think that what I am trying to do cannot be made with ffmpeg, and it is a pity, because initially when I tried to encode my stream with ffmpeg, it was crashing and it took me a while to figure out that it was crashing because of the scrambled streams in it.

Dealing with conditional access with even the best commercial tools is not easy.

So I found some solution, even though, the output is not very pretty. You can use either dvbsnoop or demuxtoy to do that. I didn't find a proper solution for dvbsnoop though. What you can do is to run:
$ dvbsnoop -s ts -pd 9 -tssubdecode -nph -if mpts.ts 0x01

TS sub-decoding (1 packet(s) stored for PID 0x0001):
    =====================================================
    TS contains Section...
    SI packet (length=88):

    SI packet hexdump:

        PID:  1 (0x0001)  [= assigned for: ISO 13818-1 Conditional Access Table (CAT)]

        Guess table from table id...
        CAT-decoding....
        Table_ID: 1 (0x01)  [= Conditional Access Table (CAT)]
        section_syntax_indicator: 1 (0x01)
        (fixed): 0 (0x00)
        reserved_1: 3 (0x03)
        Section_length: 85 (0x0055)
        reserved_2: 262143 (0x3ffff)
        Version_number: 10 (0x0a)
        current_next_indicator: 1 (0x01)  [= valid now]
        Section_number: 0 (0x00)
        Last_Section_number: 0 (0x00)

               MPEG-DescriptorTag: 9 (0x09)  [= CA_descriptor]
               descriptor_length: 4 (0x04)
                 0000:  09 04 06 48 e2 58                                  ...H.X
               CA_system_ID: 1608 (0x0648)  [= Irdeto]
               reserved: 7 (0x07)
               CA_PID: 600 (0x0258)

               MPEG-DescriptorTag: 9 (0x09)  [= CA_descriptor]
               descriptor_length: 4 (0x04)
                 0000:  09 04 06 50 e2 59                                  ...P.Y
               CA_system_ID: 1616 (0x0650)  [= Irdeto]
               reserved: 7 (0x07)
               CA_PID: 601 (0x0259)

               MPEG-DescriptorTag: 9 (0x09)  [= CA_descriptor]
               descriptor_length: 4 (0x04)
                 0000:  09 04 06 e2 e2 5a                                  .....Z
               CA_system_ID: 1762 (0x06e2)  [= Irdeto]
               reserved: 7 (0x07)
               CA_PID: 602 (0x025a)

               MPEG-DescriptorTag: 9 (0x09)  [= CA_descriptor]
               descriptor_length: 4 (0x04)
                 0000:  09 04 0d 95 e2 bd                                  ......
               CA_system_ID: 3477 (0x0d95)  [= Philips (Cryptoworks)]
               reserved: 7 (0x07)
               CA_PID: 701 (0x02bd)

               MPEG-DescriptorTag: 9 (0x09)  [= CA_descriptor]
               descriptor_length: 4 (0x04)
                 0000:  09 04 0d 98 e2 be                                  ......
               CA_system_ID: 3480 (0x0d98)  [= Philips (Cryptoworks)]
               reserved: 7 (0x07)
               CA_PID: 702 (0x02be)

               MPEG-DescriptorTag: 9 (0x09)  [= CA_descriptor]
               descriptor_length: 4 (0x04)
                 0000:  09 04 09 8c e3 3e                                  .....>
               CA_system_ID: 2444 (0x098c)  [= News Datacom (Videoguard)]
               reserved: 7 (0x07)
               CA_PID: 830 (0x033e)

               MPEG-DescriptorTag: 9 (0x09)  [= CA_descriptor]
               descriptor_length: 4 (0x04)
                 0000:  09 04 09 c4 e3 3e                                  .....>
               CA_system_ID: 2500 (0x09c4)  [= News Datacom (Videoguard)]
               reserved: 7 (0x07)
               CA_PID: 830 (0x033e)

               MPEG-DescriptorTag: 9 (0x09)  [= CA_descriptor]
               descriptor_length: 32 (0x20)
                 0000:  09 20 05 00 e3 84 13 01  20 14 03 04 25 00 14 03   . ...... ...%...
                 0010:  04 25 10 14 03 04 25 02  14 03 04 25 30 14 03 05   .%....%....%0...
                 0020:  19 00                                              ..
               CA_system_ID: 1280 (0x0500)  [= France Telecom (Viaccess)]
               reserved: 7 (0x07)
               CA_PID: 900 (0x0384)
               Private Data:
                    0000:  13 01 20 14 03 04 25 00  14 03 04 25 10 14 03 04   .. ...%....%....
                    0010:  25 02 14 03 04 25 30 14  03 05 19 00               %....%0.....

        CRC: 2807244644 (0xa7532764)

So using this command you can see the defined CAS in the CAT table PID 0x01.
With demuxtoy you can actually check which channels are scrambled and which are not:

$ demuxtoy --out=directory/ tmpts.ts

This will save the TS data in directory/ so you can navigate to there and check in directory/mpts/SUMMARY/ either CASMessages.txt or Programs.txt. This is the output of directory/mpts/SUMMARY/Programs.txt:
$ cat Programs.txt
Program                                                         PID             Component                                               Tag(s)          Comments
ORF1 HD                                                         0x0078          Program 4911 ECM Irdeto (0x0648)                        -
                                                                0x007A          Program 4911 ECM Irdeto (0x0650)                        -
                                                                0x010E          Program 4911 ECM CrytoWorks (Irdeto) (0x0D95)           -
                                                                0x0110          Program 4911 ECM CrytoWorks (Irdeto) (0x0D98)           -
                                                                0x0140          Program 4911 ECM Irdeto (0x06E2)                        -
                                                                0x01CD          Program 4911 ECM France Telecom (0x0500)                -
                                                                0x01E0          Program 4911 ECM News Datacom (0x09C4)                  -
                                                                0x01EA          Program 4911 ECM News Datacom (0x098C)                  -
                                                                0x0780          Program 4911 H.264 AVC Video Stream                     1
                                                                0x0781          Program 4911 AC-3 Audio Stream (deu)                    2
                                                                0x0782          Program 4911 AC-3 Audio Stream (mis)                    3
                                                                0x0785          Program 4911 Teletext (ger)                             5
                                                                0x1C8E          Program 4911 AIT (HbbTV)                                11
                                                                0x1C8F          Program 4911 HbbTv Carousel (0x1C8F)                    12
                                                                0x0780          PCR PID                                                 -
ORF2N HD                                                        0x0079          Program 4916 ECM Irdeto (0x0648)                        -
                                                                0x007B          Program 4916 ECM Irdeto (0x0650)                        -
                                                                0x010F          Program 4916 ECM CrytoWorks (Irdeto) (0x0D95)           -
                                                                0x0111          Program 4916 ECM CrytoWorks (Irdeto) (0x0D98)           -
                                                                0x0141          Program 4916 ECM Irdeto (0x06E2)                        -
                                                                0x01CE          Program 4916 ECM France Telecom (0x0500)                -
                                                                0x01E1          Program 4916 ECM News Datacom (0x09C4)                  -
                                                                0x01EB          Program 4916 ECM News Datacom (0x098C)                  -
                                                                0x0B68          Program 4916 H.264 AVC Video Stream                     1
                                                                0x0B69          Program 4916 AC-3 Audio Stream (deu)                    2
                                                                0x0B6A          Program 4916 AC-3 Audio Stream (mis)                    3
                                                                0x0B6D          Program 4916 Teletext (ger)                             5
                                                                0x1C8E          Program 4916 AIT (HbbTV)                                11
                                                                0x1C8F          Program 4916 HbbTv Carousel (0x1C8F)                    12
                                                                0x0B68          PCR PID                                                 -
ORF2W HD                                                        0x0079          Program 4912 ECM Irdeto (0x0648)                        -
                                                                0x007B          Program 4912 ECM Irdeto (0x0650)                        -
                                                                0x010F          Program 4912 ECM CrytoWorks (Irdeto) (0x0D95)           -
                                                                0x0111          Program 4912 ECM CrytoWorks (Irdeto) (0x0D98)           -
                                                                0x0141          Program 4912 ECM Irdeto (0x06E2)                        -
                                                                0x01CE          Program 4912 ECM France Telecom (0x0500)                -
                                                                0x01E1          Program 4912 ECM News Datacom (0x09C4)                  -
                                                                0x01EB          Program 4912 ECM News Datacom (0x098C)                  -
                                                                0x0B68          Program 4912 H.264 AVC Video Stream                     1
                                                                0x0B69          Program 4912 AC-3 Audio Stream (deu)                    2
                                                                0x0B6A          Program 4912 AC-3 Audio Stream (mis)                    3
                                                                0x0B6D          Program 4912 Teletext (ger)                             5
                                                                0x1C8E          Program 4912 AIT (HbbTV)                                11
                                                                0x1C8F          Program 4912 HbbTv Carousel (0x1C8F)                    12
                                                                0x0B68          PCR PID                                                 -
ServusTV HD Oesterreich                                         0x007C          Program 4913 ECM Irdeto (0x0648)                        -
                                                                0x007D          Program 4913 ECM Irdeto (0x0650)                        -
                                                                0x0112          Program 4913 ECM CrytoWorks (Irdeto) (0x0D95)           -
                                                                0x0113          Program 4913 ECM CrytoWorks (Irdeto) (0x0D98)           -
                                                                0x011D          Program 4913 ECM News Datacom (0x09C4)                  -
                                                                0x0127          Program 4913 ECM News Datacom (0x098C)                  -
                                                                0x0142          Program 4913 ECM Irdeto (0x06E2)                        -
                                                                0x01D0          Program 4913 ECM France Telecom (0x0500)                -
                                                                0x005C          Program 4913 AIT (HbbTV)                                21
                                                                0x0DFF          Program 4913 H.264 AVC Video Stream                     1
                                                                0x0E00          Program 4913 MPEG-2 Audio Stream (ger)                  2
                                                                0x0E01          Program 4913 MPEG-2 Audio Stream (eng)                  3
                                                                0x0E03          Program 4913 AC-3 Audio Stream (ger)                    4
                                                                0x0E04          Program 4913 Teletext (ger)                             5
                                                                0x0E05          Program 4913 EAC-3 Audio Stream (ger)                   7
                                                                0x0DFF          PCR PID                                                 -
ServusTV HD Deutschland                                         0x005B          Program 4914 AIT (HbbTV)                                21
                                                                0x1338          Program 4914 H.264 AVC Video Stream                     1
                                                                0x1339          Program 4914 MPEG-2 Audio Stream (ger)                  2
                                                                0x133A          Program 4914 MPEG-2 Audio Stream (eng)                  3
                                                                0x133C          Program 4914 AC-3 Audio Stream (ger)                    4
                                                                0x133D          Program 4914 Teletext (ger)                             5
                                                                0x133E          Program 4914 EAC-3 Audio Stream (ger)                   7
                                                                0x1338          PCR PID                                                 -

From the output is obvious that only ServusTV HD Deutschland is FTA, the only program which doesn't have ECM PIDs.
I have also tried to get the same information using tsreport and tsinfo part of the tstools but I was unable to do that.

Based on ffmpeg output, restricted streams are: 0, 10 - 23
stream 0 is probably the unscramble information/table for the encrypted streams, like program/stream descriptor tags (8 bits)
ffmpeg "Could not find codec parameters" nor "start time for stream"
for 3 of the restricted streams, therefore ffmpeg could not "estimate rate" of frames.
Solution suggested to fix the problem was to "Consider increasing the value for the 'analyzeduration' and 'probesize' options", which won't work without knowing how to implement/interpret stream 0
Stream 0 contains PAT (Program Association Table), has information about all the programs contained in the Transport Stream. The PAT contains information showing the association of Program Map Table PID and Program Number. The PAT should end with a 32-bit CRC
Streams 1-9 seems to be unrestricted:

1 - 1080p video at 25 fps
2,3 - German/English audio dubbing
4 - German surround sound 5.1
5 - German subtitle
6 - German surround sound (Enhanced ac3 format - newer Dolby Digital Plus format)
7,8,9 - subtitle (could be audio describing for hearing impaired)

Looks like at the time of recording, you were tuned into "ServusTV HD Deutschland", therefore the other channels/programs have been left encrypted.


text:
Extract PTS, Frame Number from a TS file using the bytes representation of it
I am trying to write a Python script which will connect the TDT with the PTS in a MPEG-2 TS. So far I have managed to convert the TS file into a .dat file where I have all the hex representation of the 188 bytes on a different line. I have couple of problems:

I want to separate the frames and put an incremental number in front of the packets from this frame. For example, all the packets belonging to frame Nr. 1 to have fr%5d in front. I can easily do that using Python as long as I know how I can separate between the frames.
I want to decode the PTS from the PCR. So far I have extracted the PTS values using FFMPEG and I have a list for each frame which PTS it has. I have tried to grep the .dat file for the hex representation of the PTS but it doesn't find any matches. So I guess the PTS is coded in a different form, but so far I wasn't able to figure out the syntax of it.

My .dat file has the following content:
b'4700ff1de05ca7686c2b43f5e37e6dafd388761c36900ab37e10409a1dcbdd95dd1b9492ccbf4d75518e357d00cdb41536b54c2e5eb093d46f006835f9ebc39d6e5fe2401f1495cb8d2f9a6190ac3f3d2e519115ca05df63295d94a2c4b4b1c1b921e1a5610e9b7f6ccc69693a142807f4d09ac1ae53b61125f8a0e3efe1f11cb95f0e75dd49231dc0aa02aa3e72045783cb27ecfb591cdae658b04fd75e3f68968da6710f3a08ec3dc84d1eb04fac0e337b21d47560d457b58ad7f6'  b'4700ff1e59ab778d0013a08a07f9733c31daab4375ce1b44b39e9426d26963dff9a87601533d3a7c326849248ee8f0ab6f9677c8b19c198f3da107a76a10bda99dfec628136c5dd7508ec2c7546db32eef7027ed91d8dffe1c64672d41b5d848478bb2ae8c41c62f3305b29005912965a222948a77a81de7cf59cfd745c4a469d595d50432ce05704e7e4e8edadeb250cb792780a410223d4810e72bc67ddba39b7c5d0bf48e6aea508f2dec5c1a2573210610c412f4020d3e0bd130'
b'4700ff1f2b05cbec47587f67c444b52f95d51cf52f2e54ad60cb2089015c1286b88bde1ada2290f7de9a8955c112d122dd83884127a85d60d783d0c7ac62ce7d2176d98f8b7ffa82c45d661394e3f6765ba4226e030c485f709f8cd57da40dfbaceed7332d82f4dc8bce05ca6ed5bc3262399b606f9c16daada74b65691729a48659f63aa847c96d41467a98134ee2eda6edf7e5569f3b5ec04fc274d8026bf182542be6529985159df52fda6db38908853577ac3ecb716126186b3a'
b'4700ff10625a2814a692660f91c9802011f0cfefd21029bc4d574921a5ff61daed60f4865765272d7885a5f6d1f00a6b911566041f9b09d5fb8543286f027e5d1790c883e9fc30f11e67e64b4eba58845563976d5055333c9b5292c28b202dd74457d7900356ce4581e63e7be76ac741685039f37f345adcaab4d77c38b9cc98c9969dbd5016b361c6a641b60f76773f3b0e11fee995bded7012f80fad299ca44c4a7c4715114c52edcaf44521d1bbe12cddb89a4711094a8853920d'
b'4700ff1179fb10469aedae24c5e85cdda33de151c1bd83e8f7573f44d101d3a11b42ba9599c02f134a4bd4795e5afcdade291bc1a3e8a1da4da150cbe94c863e8cd0c04ce686333af6ba25f2f645170c387c4346df8c7e85cda2be546136e09e12b612104ada9990c12d745e1de68a587114c9e268b1e14dd5f68c5037ed2c3acb2aa65e988ac990f2ae1089e962ffd495e5580e8f3525fa3386ed752432d443ff3ca93ce86a20b9114c3d2554b5e701e41d9548c903a3c17498a49b'

So as you can see each packet starts with 0x47 which is the sync byte. I have all kind of PIDs inside the TS. Here I have shown only the VPID 0x00ff. The 0x47 is the sync byte and immediately after it comes the PID.
[EDIT]: I have uploaded the binary file here: wetransfer_link

What is the timestamp of the first packet above supposed to be? Your 2nd, 3rd and 5th lines don't look like actual data.

@Gyan, yes, that's because I have stuffing in my TS. 0x47 is the syncing byte and then there are 4 bytes for the PID. My VPID is 0x00ff, corresponds to the first and third line. PID 0x1fff is actually the last PID, which is also the null PID, so you should ignore line 2, 3, 5. As a matter of fact, my file is much larger. If you want I can upload it somewhere.

Anyway, I have put only information about the VPIDs in the thread, so no more stuffing bytes. I just want to know to which frame the packets in the TS belong, in order to be able to connect the PTS with the TDT.

What is the timestamp of the first packet above supposed to be?

@Gyan, this is what I want to know, I want to connect the frames with their respective PTS timestamps and with human time extracted from the TDT. I have already written a script decoding the TDT time, I just need to define which packet to which frame belong and to find a way to extract the PTS from the PCR PID. I have also added a link to the binary file. Each packet is starting on a new line similar to the format from my main post.

As per my reading of the demuxer, this is the method to derive the PTS from a base 16 dump.
b'4700ff1de05ca7686c2b43f5e37e6dafd388761c36900ab37...

Skip the first 7 bytes, or more precisely, the first 3 bytes after the PID (00ff). The timestamp is derived from the next 6 bytes.
a7686c2b43f5

There are two components to the PCR - the 90 kHz clock and a 27 Mhz extension.
First left-shift the initial 4 bytes by 1
a7686c2b << 1 = 14ed0d856

Then right-shift the 5th byte by 7 i.e. isolate the high bit.
43 >> 7 = 0

Bitwise-OR the above two results.
14ed0d856 | 0 = 14ed0d856

The above result is the first component C1.
Now, isolate the low bit of the 5th byte and left-shift it by 8
(43 & 1) << 8 = 1

Bitwise-OR this result with the 6th byte
100000000 | f5 = 01f5

This is the 2nd component C2.
The timestamp in the 27 Mhz timebase is C1 * 300 + C2. In seconds, that is
(5617277014 * 300 + 501) / 27000000 = 62414.189063s

You can ignore C2 and just divide C1 by 90000 to get a less precise timestamp.

I have used a TS analyzer software to extract the PCR from the payload and for this payload: 4700FF36071001922857FE9AC1EFE05B1A54D5EFD373CA543CA6C9F07D50E442 the PCR is constituted by the 7th till 11th byte: 01 92 28 57 FE so for these 5 bytes form the PCR base: 32450AF (527115999 or 27MHz  15813479854 and the human time is 00:09:45:6844). So apparently your approach for calculating the PCR isn't correct.

What is the PCR supposed to be?

PCR is the program clock reference. I found a source where this is all explained and I have answered my own question. I have made a mistake in my previous comment and actually, for the PCR calculation, you need 6 bytes, between the 7th and the 12th.

on top of that, I have figured out that this packet has the adaptation_field_control = 01 which means that there isn't adaptation field present in the packet and after the header starts the payload directly and PCR is actually carried in the adaptation field.

The PCR is constructed by two components PCR base and PCR extension. In order to extract it you need to get the binary(hex) data between the 7th and 12th bytes (6 in total). So the first 33 bits are constructing the pcr_base, then there are 6 bits which are reserved and 9 bits constructing the pcr_extension. The PCR = pcr_base * 300 + pcr_extension. So in my example for this VPID:
4700ff1de05ca7686c2b43f5e37e6dafd388761c36900ab37e10409a1dcbdd95dd1b9492ccbf4d75518e357d00cdb41536b54c2e5eb093d46f006835f9ebc39d6e5fe2401f1495cb8d2f9a6190ac3f3d2e519115ca05df63295d94a2c4b4b1c1b921e1a5610e9b7f6ccc69693a142807f4d09ac1ae53b61125f8a0e3efe1f11cb95f0e75dd49231dc0aa02aa3e72045783cb27ecfb591cdae658b04fd75e3f68968da6710f3a08ec3dc84d1eb04fac0e337b21d47560d457b58ad7f6

The PCR will be 0xa7686c2b43f5 so when we convert the bytes into binary we have 0b101001110110100001101100001010110100001111110101, so the first 33 bits constitute the pcr_base and the last 9 the pcr_extension, the six bits in between are reserved, so you can ignore them.
pcr_base = 0b101001110110100001101100001010110 = 5617277014
pcr_extension = 0b111110101 = 501
PCR = 5617277014 * 300 + 501 = 1685183104701

Ok, I got the offset wrong - it's 3 bytes after the PID, not 6.

I think you don't need to left shift the initial 4 bytes, the Bitwise-OR also isn't needed in the case, you just need to concatenate the high bit of the 5th byte to the binary representation of the first 4 bytes at the end and then to add at the beginning the lower bit of the fifth byte to the binary representation of the last byte.

Yes, when doing this manually or as a string op. The code I demonstrated is when working in C or similar env.