[FFmpeg-devel] [PATCH] ffplay: support rotated video.

Clément Bœsch u at pkh.me
Tue May 20 19:57:14 CEST 2014


On Sat, Apr 19, 2014 at 12:15:50AM +0200, Marton Balint wrote:
[...]
> >+    last_filter = filt_out;
> >+
> >+#define INSERT_FILT(name, arg) do {                                         \
> 
> I think a comment would be useful describing that this actually adds a
> filter before the lastly added filter, so the processing order of the
> filters will be in reverse...
> 

Added.

> >+    AVFilterContext *filt_ctx;                                              \
> >+                                                                            \
> >+    ret = avfilter_graph_create_filter(&filt_ctx,                           \
> >+                                       avfilter_get_by_name(name),          \
> >+                                       "ffplay_" name, arg, NULL, graph);   \
> >+    if (ret < 0)                                                            \
> >+        goto fail;                                                          \
> >+                                                                            \
> >+    ret = avfilter_link(filt_ctx, 0, last_filter, 0);                       \
> >+    if (ret < 0)                                                            \
> >+        goto fail;                                                          \
> >+                                                                            \
> >+    last_filter = filt_ctx;                                                 \
> >+} while (0)
> >+
> >    /* SDL YUV code is not handling odd width/height for some driver
> >     * combinations, therefore we crop the picture to an even width/height. */
> >-    if ((ret = avfilter_graph_create_filter(&filt_crop,
> >-                                            avfilter_get_by_name("crop"),
> >-                                            "ffplay_crop", "floor(in_w/2)*2:floor(in_h/2)*2", NULL, graph)) < 0)
> >-        goto fail;
> >-    if ((ret = avfilter_link(filt_crop, 0, filt_out, 0)) < 0)
> >-        goto fail;
> >+    INSERT_FILT("crop", "floor(in_w/2)*2:floor(in_h/2)*2");
> >+
> >+    if (autorotate) {
> >+        AVDictionaryEntry *rotate_tag = av_dict_get(is->video_st->metadata, "rotate", NULL, 0);
> >+        if (rotate_tag) {
> >+            if (!strcmp(rotate_tag->value, "90")) {
> >+                INSERT_FILT("transpose", "1");
> >+            } else if (!strcmp(rotate_tag->value, "180")) {
> >+                INSERT_FILT("hflip", NULL);
> >+                INSERT_FILT("vflip", NULL);
> >+            } else if (!strcmp(rotate_tag->value, "270")) {
> >+                INSERT_FILT("transpose", "2");
> >+            } else {
> 
> You may want to check if the rotation is zero or emtpy string and not insert
> a filter in that case.
> 

Added.

> >+                INSERT_FILT("rotate", rotate_tag->value);
> >+            }
> >+        }
> >+    }
> >
> >-    if ((ret = configure_filtergraph(graph, vfilters, filt_src, filt_crop)) < 0)
> >+    if ((ret = configure_filtergraph(graph, vfilters, filt_src, last_filter)) < 0)
> >        goto fail;
> >
> >    is->in_video_filter  = filt_src;
> >@@ -3527,6 +3557,7 @@ static const OptionDef options[] = {
> >    { "acodec", HAS_ARG | OPT_STRING | OPT_EXPERT, {    &audio_codec_name }, "force audio decoder",    "decoder_name" },
> >    { "scodec", HAS_ARG | OPT_STRING | OPT_EXPERT, { &subtitle_codec_name }, "force subtitle decoder", "decoder_name" },
> >    { "vcodec", HAS_ARG | OPT_STRING | OPT_EXPERT, {    &video_codec_name }, "force video decoder",    "decoder_name" },
> >+    { "autorotate", OPT_BOOL, { &autorotate }, "automatically rotate video", "" },
> >    { NULL, },
> >};
> >
> 
> The used filters should be added to ffplay_select in configure.
> 

Added.

New patchset incoming, thanks.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140520/158e2884/attachment.asc>


More information about the ffmpeg-devel mailing list